Aspose.Pdf.Document.Convert is not working on non-Windows platforms

We are running the below source code in alpine linux container.

Aspose.Words.Document doc = new Aspose.Words.Document("App/test.docx");
using MemoryStream pdfDocStream = new();
Aspose.Words.Saving.PdfSaveOptions options = new Aspose.Words.Saving.PdfSaveOptions();
doc.Save(pdfDocStream, options);
Aspose.Pdf.Document document = new Aspose.Pdf.Document(pdfDocStream);
document.Convert("log.xml",PdfFormat.PDF_A_1A,ConvertErrorAction.Delete,ConvertTransparencyAction.Default);
document.Save( "SathishTest.pdf");

And we get following error

Unhandled exception. System.TypeInitializationException: The type initializer for ‘Gdip’ threw an exception.
web-font | —> System.PlatformNotSupportedException: System.Drawing.Common is not supported on non-Windows platforms. See Breaking change: System.Drawing.Common only supported on Windows - .NET | Microsoft Learn for more information.
web-font | at System.Drawing.LibraryResolver.EnsureRegistered()
web-font | at System.Drawing.SafeNativeMethods.Gdip.PlatformInitialize()
web-font | at System.Drawing.SafeNativeMethods.Gdip…cctor()
web-font | — End of inner exception stack trace —
web-font | at System.Drawing.SafeNativeMethods.Gdip.GdipCreateMatrix2(Single m11, Single m12, Single m21, Single m22, Single dx, Single dy, IntPtr& matrix)
web-font | at Aspose.Pdf.ImagePlacementAbsorber.#=zgJt75F8=(Page #=zl1Idajw=, OperatorCollection #=zFd9wHOI=, Resources #=zWyr5AEE=)
web-font | at Aspose.Pdf.ImagePlacementAbsorber.Visit(Page page)
web-font | at #=zKZIslgV_VTgI_laDaHeWpiZkfC7XbFZq740O6xK8krWe8dvil3HKne8=.#=z0rA10baddDFI(String #=zsmU4xHSeSsAX, String #=zdyoT5oBSVJEd)
web-font | at #=z$anv5esRDEIQyDXPJ_FZOnmbj4ed2viFa8orYkgD4B8rki8xa_LEGzs=.#=z1BLH_J4YGpC4()
web-font | at #=z$anv5esRDEIQyDXPJ_FZOnmbj4ed2viFa8orYkgD4B8rki8xa_LEGzs=.#=zYn6wCy1xwTvr()
web-font | at #=zKZIslgV_VTgI_laDaHeWpiZkfC7XbFZq740O6xK8krWe8dvil3HKne8=.#=zo8is4oM=()
web-font | at #=z$anv5esRDEIQyDXPJ_FZOnmbj4ed2viFa8orYkgD4B8rki8xa_LEGzs=.#=zgJt75F8=(XmlTextWriter #=z$Cn9iBQ=, PdfFormat #=z9oViWV4=, Document #=zqgQFGbg=, Boolean #=zfqQ5_VfFNYR1, ConvertErrorAction #=zNl0gHaM=)
web-font | at Aspose.Pdf.Document.Convert(String outputLogFileName, PdfFormat format, ConvertErrorAction action, ConvertTransparencyAction transparencyAction)
web-font | at Program.$(String[] args) in /app/App/Program.cs:line 37
web-font | at Program.(String[] args)

Our input file is test.docx (63.6 KB)

@sarathisathish90
Please attach the dockerfile you are using.

Please find the docker and docker compose file: Archive.zip (2.1 KB)

And this repo is public which is I am using inside my docker file
https://github.com/sgovindan-conga/CustomFonts

@sarathisathish90
Thank you.
And I missed that App/test.docx file is needed.
Or better pdf document after conversion from doc.
Since this branch of the forum deals with issues related to the work of the pdf library (and the stack shows that exceptions occur in Aspose.Pdf).

Hi

This is the input document App/test.docx test.docx (63.6 KB)

I can’t send you generated PDF A 1A because it was throwing error. But I can send you equivalent pdf document of test.docx test.pdf (42.6 KB). If you use this pdf directly also you should face the same issue.

I am facing this issue even when i run this code locally in my MacBook Pro

To check, I created a .Net 6 console application, loaded the Aspose.Pdf.Drawing library and took the test.pdf file test.pdf (77.1 KB)
obtained after converting from test.docx. At the beginning of the dockerfile I added the lines
FROM mcr.microsoft.com/dotnet/runtime:6.0 AS base
WORKDIR /app
(and changed the paths in it to his own).

In this variant, the console application worked without exceptions.

You are probably using the Aspose.Pdf library - replace it with Aspose.Pdf.Drawing.