We are facing an issue when trying to convert a PostScript file to PDF in containerized Linux environments (.NET 9).
When calling the SaveAsPdf method on a PsDocument, the following exception is thrown:
pgsql
CopyEdit
System.PlatformNotSupportedException: System.Drawing.Common is not supported on this platform.
at System.Drawing.Brush..ctor()
at System.Drawing.SolidBrush..ctor(Color color)
at #=zaAHci2YRwy2gIgZy6g==..ctor()
at #=z7vlhUC9RmhwKmDRWLI$DPZgluIcwWDyp$g==..ctor(Stream #=zfCGqL6g=)
at Aspose.Page.EPS.PsDocument.SaveAsPdf(Stream pdfStream, PdfSaveOptions options)
The Aspose libraries used in the project as a whole are as follows:
The issue you are encountering with the System.PlatformNotSupportedException when trying to convert a PostScript file to PDF in a Linux environment is related to the System.Drawing.Common library, which is not supported on Linux platforms. This is a known limitation when using certain Aspose libraries that rely on System.Drawing.
To resolve this issue, you can consider the following approaches:
Use a Different Library: If your application can be modified, consider using libraries that do not depend on System.Drawing.Common. For example, you might explore using Aspose libraries that are designed to work natively on Linux without relying on System.Drawing.
Check for Updates: Ensure that you are using the latest version of the Aspose libraries. Sometimes, newer versions may have addressed compatibility issues or provided alternative methods for handling graphics.
Run on Windows: If feasible, you could run your application in a Windows environment where System.Drawing.Common is fully supported. This is not always ideal, especially in containerized environments, but it is a workaround.
Monitor Issue Tracking: There is an ongoing investigation regarding this issue, and it may be beneficial to keep an eye on updates from Aspose regarding the resolution of this limitation.
For further assistance, you can refer to the following example that demonstrates how to convert a PostScript file to PDF using Aspose.Page, which may help you adapt your code accordingly:
using Aspose.Page.EPS;
using Aspose.Page.EPS.Device;
using System.IO;
public class PostScriptToPdf
{
public static void Convert(string originalFilePath, string convertedFilePath)
{
using (FileStream fs = new FileStream(originalFilePath, FileMode.Open, FileAccess.Read))
{
PsDocument document = new PsDocument(fs);
PdfSaveOptions options = new PdfSaveOptions(true); // Suppress errors if needed
using (FileStream pdfStream = new FileStream(convertedFilePath, FileMode.Create, FileAccess.Write))
{
document.SaveAsPdf(pdfStream, options);
}
}
}
}
This code snippet initializes a PsDocument and saves it as a PDF, while also allowing for error suppression if needed. Make sure to adapt the paths and options as per your requirements.
If you have further questions or need additional assistance, feel free to ask!
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.
Issue ID(s): PAGENET-756
You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.