Press "Enter" to skip to content

The html content length cannot be greater than 2 MB

When converting HTML to PDF format using the ‘OneDrive for Business‘ connector in Flow there is a 2MB size limit which can be a real problem for anyone generating complex documents or where images are embedded using a Data URI within the HTML. This is a common challenge for anyone trying to capture images within a PowerApp which need to be later embedded within a document.

Fortunately, Encodian’s ‘HTML to PDF‘ action does not suffer this limitation. Furthermore, Encodian’s ‘HTML to PDF‘ action provides an array of additional configuration options such as page orientation, page size, page margins, encoding, viewports and much more.

The Encodian ‘HTML to PDF‘ action also supports HTML documents retrieved from any Flow action/location, removing the need to copy documents to OneDrive temporarily to enable conversion, which can be major information management risk considering Flow’s do fail on occasion and documents could be inadvertently copied and left in an unsecured location!

An example Flow which will be limited by the 2MB limit:

Easily solved with the Encodian ‘HTML to PDF‘ action whilst simplifying your Flow!

REFERENCE: The full error message generated when you attempt to convert an HTML document using the ‘OneDrive for Business’ connector where the file size exceeds 2MB:

{ "status": 412, "message": "The html content length cannot be greater than 2 MB\nInnerExceptionMessage: \nStackTrace: at OneDrive.Media.Transforms.Rasterizers.HtmlToPdfConverter.ValidateLength(String htmlContent, Int64 maxLength) in C:\\agent\\2\\_work\\15\\s\\Transforms\\PdfConverters\\HtmlToPdfConverter.cs:line 116\r\n at OneDrive.Media.Transforms.Rasterizers.HtmlToPdfConverter.<>c__DisplayClass12_1.<GenerateStream>b__1() in C:\\agent\\2\\_work\\15\\s\\Transforms\\PdfConverters\\HtmlToPdfConverter.cs:line 75\r\n at OneDrive.Media.Utilities.MemoryStreamHelper.ExecuteAndDisposeStreamIfErrorOccurs(Stream outputStream, Action method) in C:\\agent\\2\\_work\\15\\s\\Utilities\\MemoryStreamHelper.cs:line 61\r\n at OneDrive.Media.Transforms.Rasterizers.HtmlToPdfConverter.<>c__DisplayClass12_0.<GenerateStream>b__0() in C:\\agent\\2\\_work\\15\\s\\Transforms\\PdfConverters\\HtmlToPdfConverter.cs:line 94\r\n at OneDrive.Media.Transforms.Rasterizers.HtmlRasterizer.ExecuteMethod(Func`1 method) in C:\\agent\\2\\_work\\15\\s\\Transforms\\Rasterizers\\HtmlRasterizer.cs:line 103\r\n at OneDrive.Media.Transforms.Rasterizers.HtmlToPdfConverter.<GeneratePdf>d__11.MoveNext() in C:\\agent\\2\\_work\\15\\s\\Transforms\\PdfConverters\\HtmlToPdfConverter.cs:line 55\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at OneDrive.Media.Utilities.Sandbox.SandboxService.<RunRequestAsync>d__1.MoveNext() in C:\\agent\\2\\_work\\15\\s\\Sandbox\\SandboxService.cs:line 68\n ThrowSite: ", "source": "api.connectorp.svc.ms"}

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *