Hello Team,
We are having an issue with HTML to PDF conversion. first, we tried with the aspose.pdf package(24.2.0 package). At that time we were getting the error “The Type Initializer for ‘Gdip’ Threw Exception”.
after that, we tried with aspose.pdf.drawing package (24.6.0) and we were not getting above mentioned gdip error but we were getting 502 bad getaway error.
below is our code for HTML to PDF conversion -
using MemoryStream memoryStream = new MemoryStream(documentContent);
//documentContent - Byte array of Html Document
HtmlLoadOptions htmlLoadOptions = new HtmlLoadOptions();
var pdfDocument = new Document(memoryStream, htmlLoadOptions);
using MemoryStream generatedStream = new();
pdfDocument.Save(generatedStream, SaveFormat.Pdf);
generatedStream.Position = 0;
var byteArray = generatedStream.ToArray();
return Convert.ToBase64String(byteArray);
we tried with aspose online HTML to pdf converter, and by using this we are getting converted pdf without any error.
I have attached multiple HTML files in the attached zip file.
Downloads.7z (8.7 KB)
The above code is working fine locally on Windows machine but when we deploy the same code on server (Linux), we are getting the above-mentioned error
Note - I am part of the Conga organization, and we already have a paid license. If needed, we will post the question from the paid account.