pdf generation - Issue with Evo Pdf library in Windows Container - Stack Overflow

admin2025-04-21  2

I have an Asp MVC 4.6 project. I use the Evo PDF dll to convert HTML strings to PDF files. It works fine locally, as expected. But when I run the app in a Windows Docker Container, the PDF content generated in the container is deformed.

To simplify the issue, I try this simple html string: "<p><b>Yes, Hello World</b></p><p>From EVO PDF !</p>"

HtmlToPdfConverter converter = new HtmlToPdfConverter();
byte[] htmlToPdfBuffer = converter.ConvertHtml("<p><b>Yes, Hello World</b></p><p>From EVO PDF !</p>", null);
System.IO.File.WriteAllBytes("HtmlToPdf.pdf", htmlToPdfBuffer);

This is the result in local: Generated in local

And in container: Container

I tried the latest version of EVO Pdf. same issue.

I have an Asp.net MVC 4.6 project. I use the Evo PDF dll to convert HTML strings to PDF files. It works fine locally, as expected. But when I run the app in a Windows Docker Container, the PDF content generated in the container is deformed.

To simplify the issue, I try this simple html string: "<p><b>Yes, Hello World</b></p><p>From EVO PDF !</p>"

HtmlToPdfConverter converter = new HtmlToPdfConverter();
byte[] htmlToPdfBuffer = converter.ConvertHtml("<p><b>Yes, Hello World</b></p><p>From EVO PDF !</p>", null);
System.IO.File.WriteAllBytes("HtmlToPdf.pdf", htmlToPdfBuffer);

This is the result in local: Generated in local

And in container: Container

I tried the latest version of EVO Pdf. same issue.

Share Improve this question edited Jan 23 at 3:16 Farhad Abaei asked Jan 22 at 22:51 Farhad AbaeiFarhad Abaei 11 bronze badge 0
Add a comment  | 

1 Answer 1

Reset to default 0

Most likely, the reason is that the Windows image is missing fonts necessary for this conversion. You can check how to add fonts to Windows containers here: https://learn.microsoft.com/en-us/virtualization/windowscontainers/deploy-containers/font-packages

转载请注明原文地址:http://anycun.com/QandA/1745225018a90449.html