PDF is empty

This code downloads a blank file. Why? I am using the latest component. The documentation says the Qt assemblies are put into the bin file automatically now, which is awesome. I verified that as well. Yet, the downloaded pdf is blank/empty. 



 public IActionResult CreateDocument()

        {

            //Initialize the HTML to PDF converter

            HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter();


            WebKitConverterSettings settings = new WebKitConverterSettings();



            //Assign WebKit settings to HTML converter

            htmlConverter.ConverterSettings = settings;


            //Convert URL to PDF

            PdfDocument document = htmlConverter.Convert("https://www.google.com");


            //Saving the PDF to the MemoryStream

            MemoryStream stream = new MemoryStream();


            document.Save(stream);


            //Set the position as '0'.

            stream.Position = 0;


            //Download the PDF document in the browser

            FileStreamResult fileStreamResult = new(stream, "application/pdf");


            fileStreamResult.FileDownloadName = "Sample.pdf";


            return fileStreamResult;

        }


1 Reply

GK Gowthamraj Kumar Syncfusion Team May 27, 2022 12:00 PM UTC

Hi Neil Timmerman


The reported blank issue may occur due to the missing of OPENSSL assemblies in your environment. HTML to PDF converter with WebKit rendering engine requires OPENSSL assemblies for converting HTTPS sites to PDF. For converting/accessing HTTPS sites to PDF, the WebKit rendering engine requires OpenSSL libraries. OpenSSL libraries is an open-source licensed assemblies, it is mandatory for performing HTTPS sites to PDF conversion. So, please make sure the OPENSSL assemblies are available in the machine where the conversion takes place. If it is not available, OPENSSL assemblies can be placed in the Windows system folder of the machine and try the conversion in your project and let us know the result.


Please refer to the below links for more information,

Openssl - https://help.syncfusion.com/file-formats/pdf/convert-html-to-pdf/webkit#openssl

Troubleshooting - https://help.syncfusion.com/file-formats/pdf/converting-html-to-pdf#troubleshooting

KB: https://www.syncfusion.com/kb/8174/how-to-preserve-resources-during-html-string-to-pdf-conversion


You can also get the OPENSSL assemblies from the below link,

OpenSSL Assemblies: https://www.syncfusion.com/downloads/support/directtrac/general/ze/OPENSSL-1135821860


If you are deploying the web application, we have to copy and paste the OpenSSL assemblies inside the QtBinaries folder for performing the HTML (HTTPS sites) to PDF conversion. So that, it will resolve the blank page issue.


Please try the above solution on your end and let us know the result.


Regards,

Gowthamraj K


Loader.
Up arrow icon