We need support to use the Aspose.PDF library on a Linux container. We are trying to convert .docx and .tiff files to .PDF, but we encounter errors because Aspose internally uses System.Drawing.common.dll
, which doesn’t work on Linux. It works well on Windows but fails on Linux. Additionally, we need help to determine if there is a direct solution to convert .tiff to .PDF. Currently, we have to convert from .tiff → .PNG → .PDF. We (First American) have an enterprise license and would appreciate any help to guide us in the right direction.
To use the Aspose.PDF library for converting .docx and .tiff files to PDF in a Linux container, follow these steps:
-
Cause: Ensure you are using the .NET Core version of Aspose.PDF, as it is cross-platform and supports Linux environments.
-
Solution: Install the necessary packages for your Linux container. Use the following command to install Aspose.PDF:
dotnet add package Aspose.PDF
-
Convert .docx to PDF: Use the following code snippet to convert a .docx file to PDF:
using Aspose.Words; using Aspose.Pdf; // Load the DOCX file Document doc = new Document("input.docx"); // Save as PDF doc.Save("output.pdf");
-
Convert .tiff to PDF: For converting TIFF files directly to PDF, use the following code:
using Aspose.Pdf; using Aspose.Pdf.Devices; // Load the TIFF file using (var imageStream = new FileStream("input.tiff", FileMode.Open)) { // Create a PDF document Document pdfDocument = new Document(); // Create an image object var image = new Aspose.Pdf.Image(); image.ImageStream = imageStream; // Add image to the PDF document pdfDocument.Pages.Add(image); // Save the PDF document pdfDocument.Save("output.pdf"); }
-
Next Steps: If you encounter issues related to
System.Drawing.Common.dll
, ensure that your container has the necessary dependencies installed. Check the compatibility of the libraries you are using.
If you need further assistance or have specific errors, please let me know!
can you tell what dependency needs to be installed on linux container?
Please note that we have published Aspose.PDF.Drawing for .NET for Linux like environments. It does not have dependency upon System.Drawing.Common. Therefore, instead of Aspose.PDF for .NET, you can please install Aspose.PDF.Drawing for .NET from NuGet Package and try the conversion.
Additionally, please make sure to install msttcorefonts and libgdiplus package(s) to get expected results from conversion. In case you notice any issues, please let us know.
PS: For .docx to .pdf conversion, you need to use Aspose.Words. You can please create an inquiry in respective forum category. You will be assisted there accordingly.