External-graphic and linux

Hello,

I’m currently using version 24.9 of aspose.pdf under license.
My deployment environment is Linux. Locally under Windows, external graphics are processed correctly by the FO, and the images are displayed. When I switch to Linux deployment, there are no more images. Which components are still dependent on System.Drawing? I don’t want to install libgdiplus because of its unreliability. I thought system.drawing was only intended for printing. Do you have any information? I don’t get any errors, only a missing element in the PDF.

.net 8, aspose.pdf.drawing 24.9

Regards

@lpachai

It seems that you are experiencing issues with external graphics not being displayed in PDFs when deploying on a Linux environment using Aspose.PDF version 24.9. This problem can occur due to several factors related to font handling and graphics rendering in Linux.

Possible Causes and Solutions

  1. Font Availability:

    • Ensure that the necessary fonts are installed on your Linux system. The absence of required fonts can lead to missing images or text in the generated PDFs. You can install fonts using package managers like apt or yum. For example, on Ubuntu, you can run:
      sudo apt-get update
      sudo apt-get install -y fonts-dejavu-core
      fc-cache -fv
      
  2. Access to Font Directories:

    • The Java process must have access to the font directories. If the fonts are not accessible, it can result in missing graphics. You can use the FontsLoader class to load external fonts programmatically without needing to install them system-wide:
      FontsLoader.loadExternalFonts("pathToFontsFolders");
      
  3. Temporary Directory Access:

    • Ensure that the Java process has access to the temporary directory. If it cannot access the TEMP directory, you can specify a different directory for temporary files:
      String newTempFolder = "pathToTmpFolder";
      String oldValue = System.getProperty("java.io.tmpdir");
      java.io.File file = new java.io.File(newTempFolder);
      if (!file.exists()) file.mkdir();
      System.setProperty("java.io.tmpdir", newTempFolder);
      try {
          FontsLoader.loadExternalFonts("pathToFontsFolders");
          // Your PDF generation code here
      } finally {
          System.setProperty("java.io.tmpdir", oldValue);
      }
      
  4. Dependencies on System.Drawing:

    • While Aspose.PDF does utilize some components that may depend on System.Drawing, it is advisable to check the documentation or release notes for specific dependencies in the version you are using. If you want to avoid installing libgdiplus, ensure that you are using features that do not require it.

If you continue to face issues, consider checking the Aspose documentation or community forums for additional troubleshooting steps or similar cases.

Conclusion

By ensuring that the necessary fonts are installed, accessible, and that your Java process has the correct permissions, you should be able to resolve the issue of missing external graphics in your PDFs on Linux.

If you have further questions or need more assistance, feel free to ask!

Fonts shouldn’t be a problem. We use Windows fonts the same way as Linux fonts (by storing them on S3 and using FontRepository.Sources.Add(new FolderFontSource(localFontsDir));
The question is, how do we know what depends on System.Drawing and what doesn’t?

@lpachai

If possible, could you please share the sample file(s) for comparison generated in both Windows and Linux along with the sample code snippet that you are using? We will test the scenario in our environment and address it accordingly. Also, please try using 25.4 version of the API to see if it resolves your issue as it is the latest one.