Aspose running on AWS Lambda or Linux

Is Aspose.PDF supported when running the .net code on linux? We are evaluating your product and have encountered some issues running in a linux environment. We are attempting to read a HTML file and save as PDF.

@dalley,

Kindly send us all details of the scenario, including source HTML document, code and highlight the problematic area with the help of the snapshot. We will investigate your scenario in our environment and share our findings with you.

Here is a link to the source.

https://www.dropbox.com/s/u23ci3i6irkcxvm/asposeTest.zip?dl=0

And here is the error I am receiving.

dalley$ dotnet run

Hello World!

Unhandled Exception: System.TypeInitializationException: The type initializer for ‘Gdip’ threw an exception. —> System.DllNotFoundException: Unable to load DLL ‘libgdiplus’: The specified module could not be found.
at System.Runtime.InteropServices.FunctionWrapper`1.get_Delegate()
at System.Drawing.SafeNativeMethods.Gdip.GdiplusStartup(IntPtr& token, StartupInput& input, StartupOutput& output)
at System.Drawing.SafeNativeMethods.Gdip…cctor()
— End of inner exception stack trace —
at System.Drawing.SafeNativeMethods.Gdip.GdipGetGenericFontFamilySansSerif(IntPtr& fontfamily)
at System.Drawing.FontFamily.GetGdipGenericSansSerif()
at System.Drawing.FontFamily.get_GenericSansSerif()
at System.Drawing.Font.CreateFont(String familyName, Single emSize, FontStyle style, GraphicsUnit unit, Byte charSet, Boolean isVertical)
at System.Drawing.SystemFonts.get_DefaultFont()
at . ​ ​()
at .(String , FontStyle , String )
at . ​ ​(Int32 , )
at . , [] )
at ​ …ctor , String , , Stream)
at …ctor , String , Stream )
at ​ . , String , Stream )
at …ctor )
at ​ ​()
at .( , , )
at . ​ ​( , )
at . ​ ​( , )
at .(Stream , Document , HtmlLoadOptions , String)
at Aspose.Pdf.Document.(Stream , LoadOptions )
at Aspose.Pdf.Document…ctor(String filename, LoadOptions options)
at asposeTest.Program.Main(String[] args) in /Users/dalley/Downloads/asposeTest/Program.cs:line 16

@dalley,

The Document class implements IDisposable and you can add a finally block in which you call Dispose() on mypdf object when it is not nothing (Or a using statement is doing the same. Maybe you prefer that.). Please also try to call GdiplusStartup when your application is starting and call GdiplusShutdown when your application is stopped. Please refer to this help topic: GdiplusStartup (gdiplus)

If the above recommendations do not help, then kindly share all details of the Linux environment and steps to replicate the error.

We tried to load html and to convert it into PDF on Mac and On Linux. We are getting error on both platform.
Code:
Aspose.Pdf.HtmlLoadOptions options = new Aspose.Pdf.HtmlLoadOptions();
Aspose.Pdf.Document mypdf = new Aspose.Pdf.Document("./testSection.html", options);
mypdf.Save(“output.pdf”);

Html file is too simple and contains some text (with bold formatting) only.

Error on Mac platform:
Unhandled Exception: System.TypeInitializationException: The type initializer for ‘Gdip’ threw an exception. —> System.DllNotFoundException: Unable to load DLL ‘libgdiplus’: The specified module could not be found.
at System.Runtime.InteropServices.FunctionWrapper`1.get_Delegate()
at System.Drawing.SafeNativeMethods.Gdip.GdiplusStartup(IntPtr& token, StartupInput& input, StartupOutput& output)
at System.Drawing.SafeNativeMethods.Gdip…cctor()

Error on Linux:
The type initializer for ‘Gdip’ threw an exception.: TypeInitializationException
at System.Drawing.SafeNativeMethods.Gdip.GdipLoadImageFromDelegate_linux(StreamGetHeaderDelegate getHeader, StreamGetBytesDelegate getBytes, StreamPutBytesDelegate putBytes, StreamSeekDelegate doSeek, StreamCloseDelegate close, StreamSizeDelegate size, IntPtr& image)

When we installed libdl.so (on linux) we got errors for font:
Unexpected font parsing exception —> System.ArgumentException: Empty path name is not legal.
Parameter name: path
at System.IO.UnixFileSystem.FileSystemEnumerable1..ctor(String userPath, String searchPattern, SearchOption searchOption, SearchTarget searchTarget, Func3 translateResult)
at System.IO.UnixFileSystem.EnumeratePaths(String path, String searchPattern, SearchOption searchOption, SearchTarget searchTarget)
at System.IO.Directory.InternalGetFileDirectoryNames(String path, String userPathOriginal, String searchPattern, Boolean includeFiles, Boolean includeDirs, SearchOption searchOption)
at System.IO.Directory.GetFiles(String path)
at . ​ ​()
— End of inner exception stack trace —
at . ​ ​()
at ​ .(FontSource )
at ​ .()
at ​ .()
at Aspose.Pdf.Text.FontRepository.FindFont(String fontName)
at asposeTest.Program.Main(String[] args) in /home/ubuntu/asposeTest/Program.cs:line 20

@sumitkumarkickdrum,

Thank you for the details. We need to prepare an environment to replicate this error. Kindly share the edition and version numbers of MAC and Linux Operating Systems.

@imran.rafique
Mac OS: 10.12.6 (MacOS Sierra)
Linux: Ubuntu 16.04
Aspose PDF .net version: 18.4
.net core version: 2.1.4

@sumitkumarkickdrum,

We are working to set up an environment to replicate this error and will get back to you early next week.

@imran.rafique
Any update on above issue?

@sumitkumarkickdrum,

It has been logged under the ticket ID PDFNET-44532 in our bug tracking system. We have linked your post to this ticket and will keep you informed regarding any available updates.

@imran.rafique Is there any update on this. It seems like some other features (like Aspose images, Text (Seems like whatever feature access the System.drawing)) is not supported on Linux or Mac environment. Is there any progress made on logged ticket. We can’t access the conversation happening for ticket PDFNET-44532

@sumitkumarkickdrum,

The linked ticket ID PDFNET-44532 is pending for the analysis and not resolved yet. We will investigate as per the development schedules and notify you once it is fixed.

I’m encountering this issue too, on AWS Lambda.

Please can you provide an update on the progress of the related ticket?

@tomrichardsredington

Sadly, the logged ticket is not yet resolved. We will surely update you in this forum thread as soon as it is resolved. Please spare us some time.

We are sorry for the inconvenience.