We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Cannot render image when convert from DOCX to PDF in linux (docker)

Hello,

I have an issue when render images from .docx file and convert to .pdf using Aspose PDF on .NET core on Linux. Specific with Docker microsoft/dotnet:2.2-aspnetcore-runtime

Step to reproduce:

  1. Create a .docx file include some images (PNG & JPEG) and text
  2. Read & write file using this code:
using Aspose.Words;
...
private Document _doc;           
_doc = new Document("template.docx");
_doc.Save("output.pdf");
  1. Examine the output file: the output image is blank (with a blank placeholder)

Note: If saving file in .docx, the image is remained.

Template project is attached:AsposeTest.zip (2.2 MB)

Please change config in file appsettings.json to docx file in project: test_template_Aspose.docx:

    "TemplateFolder": "/path/to/docx-file/",
    "OutputFolder": "/path/to/output/"

Some ways I have tried by searching this forum:

  • Update Aspose.Word & Aspose.PDF to latest version
  • Add reference to package SkiaSharp.NativeAssets.Linux
    None of these worked.

Please help me to investigate this problem.

Thanks,
Tien.

@tienlx

Thank you for contacting support.

We are checking the scenario and will share our findings with you soon.

@tienlx

In the shared PDF file (test.pdf), the images are visible. We suggest you please get 30 days temporary license and apply it before converting the document to PDF.

If you still face problem, please use Document.WarningCallback property as shared in the following article. Please share the warnings’ detail along with problematic output PDF. We will investigate this issue and provide you more information on it.
How to Receive Notification of Missing Fonts and Font Substitution during Rendering

Dear @tahir.manzoor,

In our production environment, the Aspose.Total full license is applied. The test.pdf file is generated in our test environment (Windows).
We will try to use the Document.WarningCallback in our production environment and get the result back to you.

Thanks for your support.

@tienlx

Thanks for your feedback. Please share the output PDF file along with warnings detail. We will investigate the issue and provide you more information on it.

@tahir.manzoor

Thank you for your support.
After adding the Warning callback and more investigating, we have successful solve the problem.
The solution by adding SkiaSharp.NativeAssets.Linux does not work, we has to install the library ourself by these commands (Docker):

RUN apt-get install -y libfreetype6
RUN apt-get install -y libfontconfig1

Hope this will help other people facing same problem.

Thanks.

@tienlx

Thanks for your feedback. It is nice to hear from you that your problem has been solved. Please feel free to ask if you have any question about Aspose.Words, we will be happy to help you.