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
-
Font Availability:
-
Access to Font Directories:
-
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);
}
-
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.