I am working with "Syncfusion.HtmlToPdfConverter.QtWebKit.Net.Core" package version 19.2.0.55. Using this package I am converting HTML to pdf. The code works fine on windows 10 x64 but doesn't work on Ubuntu 20.04.
On ubuntu when I convert to pdf I get message "Failed to Load PDF", when I open the converted file.
Following is my code:
on Service:
public byte[] GetPdfSyncfusion(List<string> htmlList, string fileName, string className, string mainClass, int layout)
{
HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter();
WebKitConverterSettings settings = new WebKitConverterSettings();
PdfDocument document = new PdfDocument();
Stream[] streamPages = new Stream[htmlList.Count];
int i = 0;
//document.PageSettings.Orientation = (layout == 0 ? PdfPageOrientation.Portrait : PdfPageOrientation.Landscape);
document.PageSettings.Size = PdfPageSize.A4;
//Set WebKit path
settings.WebKitPath = Path.Combine(Directory.GetCurrentDirectory(), Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), isWindows ? "QtBinariesWindows" : "QtBinariesLinux");
settings.Margin.All = 30;
//Assign WebKit settings to HTML converter
htmlConverter.ConverterSettings = settings;
foreach (string html in htmlList)
{
var htmlContent = "<!DOCTYPE html><html lang=\"en\"><head></head><body>{0}</body></html>";
PdfDocument page = htmlConverter.Convert(string.Format(htmlContent, html), "");
MemoryStream stream = new MemoryStream();
//page.PageSettings.Orientation = (layout == 0 ? PdfPageOrientation.Portrait : PdfPageOrientation.Landscape);
page.PageSettings.Size = PdfPageSize.A4;
page.Save(stream);
streamPages[i] = stream;
i++;
}
PdfDocumentBase.Merge(document, streamPages);
MemoryStream streamDocument = new MemoryStream();
document.Save(streamDocument);
return streamDocument.ToArray();
}
On controller:
public IActionResult GetPDFFromHtmlSyncfusion([FromBody] IEnumerable<string> htmlList, string fileName, string className, string mainClass, int layout)
{
string loggedInUser = HttpContext.User.Identity.Name;
var bytes = _htmlToPdfService.GetPdfSyncfusion(htmlList.ToList(), fileName, className, mainClass, layout);
return File(bytes, MimeTypes.GetMimeType(fileName), fileName);
}
I had already followed the below steps:
Package libssl1.0-dev is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
So I executed the following instead:
$ sudo apt-get install libssl-dev
and it installed
After your reply I added the ssl files to the "
QtBinariesLinux
" folder and redeployed the project. But still the same error.
Regards,