for Microsoft Power Automate and Azure logic apps

By Jay Goodison

27th August 2019

The HTML content length cannot be greater than 2 MB

Seeing that “HTML content length cannot be greater than 2 MB” can be a pain, especially when you’re working with bigger files…

When converting HTML to PDF format using the ‘OneDrive for Business‘ connector in Power Automate, 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 a significant information management risk considering Flow does fail on occasion and documents could be inadvertently copied and left in an unsecured location!

An example Flow with the 2MB size limit

Below is your 2MB size limit is quickly 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": ""}

So hopefully, we can solve your “HTML content length cannot be greater than 2 MB” issue!


  1. Apoorv Upadhyaya says:

    Hello Encodian Team!

    My colleagues and I are creating a PowerApp where we convert text and images into a PDF. We are facing a 2MB Limit on our PowerAuto conversion of html to pdf and wanted to use your tool. Can you provide your pricing information?

    Best Regards,

Leave a comment

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