The HTML content length cannot be greater than 2 MB

August 27th 2019
Back to all blogs

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

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

Author
Jay Goodison

Managing Director

Back to all blogs

You might also be interested in...