cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
AFD256
Level: Powered On

Convert File - PreconditionFailed

Getting the error "PreconditionFailed" when using Convert File to create a PDF from HTML

The HTML renders as expected but the file contains inline images and is over 2MB

 

{
  "status": 412,
  "message": "The html content length cannot be greater than 2 MB\nInnerExceptionMessage: \nStackTrace:    at OneDrive.Media.Transforms.Rasterizers.HtmlRasterizer.ValidateLength(String htmlContent, Int64 maxLength) in C:\\agent\\1\\_work\\1\\s\\Transforms\\Rasterizers\\HtmlRasterizer.cs:line 202\r\n   at OneDrive.Media.Transforms.Rasterizers.HtmlRasterizer.<>c__DisplayClass18_0.<Generate>b__0() in C:\\agent\\1\\_work\\1\\s\\Transforms\\Rasterizers\\HtmlRasterizer.cs:line 120\r\n   at OneDrive.Media.Utilities.MemoryStreamHelper.ExecuteAndDisposeStreamIfErrorOccurs(Stream outputStream, Action method) in C:\\agent\\1\\_work\\1\\s\\Utilities\\MemoryStreamHelper.cs:line 58\r\n   at OneDrive.Media.Transforms.Rasterizers.HtmlRasterizer.Generate(String htmlContent, ConvertHtmlParameters parameters) in C:\\agent\\1\\_work\\1\\s\\Transforms\\Rasterizers\\HtmlRasterizer.cs:line 114\r\n   at OneDrive.Media.Transforms.Rasterizers.HtmlRasterizer.<ConvertHtmlAsync>d__17.MoveNext() in C:\\agent\\1\\_work\\1\\s\\Transforms\\Rasterizers\\HtmlRasterizer.cs:line 98\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.Transforms.Rasterizers.HtmlRasterizer.<ConvertWithinSandboxAsync>d__16.MoveNext() in C:\\agent\\1\\_work\\1\\s\\Transforms\\Rasterizers\\HtmlRasterizer.cs:line 83\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\\1\\_work\\1\\s\\Sandbox\\SandboxService.cs:line 55\n ThrowSite: ",
  "source": "api.connectorp.svc.ms"
}

 

Has anyone got a work around for this?

2MB is a too small to be workable for my use case 

 

7 REPLIES 7
Community Support Team
Community Support Team

Re: Convert File - PreconditionFailed

Hi @AFD256,

 

I am afraid that you may have to reduce the content length within the limit.

Besides, I would suggest you post a request on Flow Ideas Forum to ask for removing 2MB content length limit at here:

https://powerusers.microsoft.com/t5/Flow-Ideas/idb-p/FlowIdeas

I will suggest other customers who have the same request to vote your idea as well.

 

Best regards,

Mabel

Community Support Team _ Mabel Mao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
AFD256
Level: Powered On

Re: Convert File - PreconditionFailed

Posted on the Ideas forum

 

I can't reduce the content of the file - that would defeat the purpose of having a dynamic report that could contain multiple embeded images 

MetodioTrend
Level: Powered On

Re: Convert File - PreconditionFailed

Could you share the link to the Flow Idea in the forum? I can't find it but would love to vote for it... it's been a year since your original post and I still have the same problem...

AFD256
Level: Powered On

Re: Convert File - PreconditionFailed

https://powerusers.microsoft.com/t5/Power-Automate-Ideas/Remove-the-2mb-limit-for-Convert-File/idi-p...

 

It might not be a straight swap - but if you can, look at the using (Premium) Word Connector for populating Word Templates and then making PDFs 

MetodioTrend
Level: Powered On

Re: Convert File - PreconditionFailed

I saw that solution as well but my HTML is very complicated with lots of dynamic stuff, so a word template would not be a solution...

However, I just came upon this:
https://blog.encodian.com/2019/08/the-html-content-length-cannot-be-greater-than-2-mb/

Will test it soon

Highlighted
AFD256
Level: Powered On

Re: Convert File - PreconditionFailed

Looks good, only question is if there a subscription/usage cost for the Encodian connectors?

 

Other options are:

Plumsail offer a paid solution for generating PDFs from HTML

Hacking something together in Azure with WIKIHTMLtoPDF and a HTTP function call

MetodioTrend
Level: Powered On

Re: Convert File - PreconditionFailed

It seems like there is a subscription, but also a free offer limited to 50 actions per month, all Encodian options included.

Well, this dosn't suit my needs, but some may only need a couple of actions per month so give it a try

Helpful resources

Announcements
firstImage

Power Platform Online Conference

Speakers, submit your sessions now! Call for speakers ends Feb. 10!

firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

firstImage

Incoming: New and improved badges!

We've given our badges an overhaul and also added some brand new ones!

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Power Automate Community Video Gallery!

Top Solution Authors
Top Kudoed Authors (Last 30 Days)
Users online (4,010)