BoldSign®Effortlessly integrate e-signatures into your app with the BoldSign® API. Create a sandbox account!
Hi team ,
I am facing an issue when I try to generate a PDF file from HTML. The converted PDF file is blank. I have tried several solutions, but the problem persists. Could you please provide a solution?
This is my code to generate pdf file from html to pdf
dll used Syncfusion.HtmlToPdfConverter.AspNet.22.1.34
In local development machine its working fine when i deployed on production or staging it getting blank pdf file
Syncfusion.Licensing.SyncfusionLicenseProvider.RegisterLicense((ConfigurationManager.AppSettings["SyncfusionLicense"]));
HtmlToPdfConverter htmlToPdfConverter1 = new HtmlToPdfConverter();
BlinkConverterSettings blinkConverterSettings1 = new BlinkConverterSettings();
blinkConverterSettings1.PdfPageSize = PdfPageSize.A4;
blinkConverterSettings1.ViewPortSize = new Size(800, 0);
blinkConverterSettings1.Margin.All = 5;
blinkConverterSettings1.Scale = 1.0F;
//blinkConverterSettings1.SplitTextLines = true;
htmlToPdfConverter1.ConverterSettings = blinkConverterSettings1;
Syncfusion.Pdf.PdfDocument doc1 = htmlToPdfConverter1.Convert(htmldata, baseUrl: "");
MemoryStream memoryStream = new MemoryStream();
doc1.Save(memoryStream);
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.ContentType = System.Net.Mime.MediaTypeNames.Application.Pdf;
HttpContext.Current.Response.AddHeader("content-disposition", "attachment;filename=" + strFileName);
HttpContext.Current.Response.BinaryWrite(memoryStream.ToArray());
HttpContext.Current.Response.End();
We have checked the reported issue with our testing documents, and we are unable to reproduce the reported blank PDF issue on our end. We suspect the reported blank page exception may occur due to the input HTML needing some time to render in the output PDF at the server. So, kindly try the conversion with increased additional delay on your end. We have attached the code snippet for your reference,
HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter();
BlinkConverterSettings blinkConverterSettings = new BlinkConverterSettings(); //Set Blink viewport size blinkConverterSettings.ViewPortSize = new Size(800, 0); blinkConverterSettings.AdditionalDelay = 5000; //Assign Blink converter settings to HTML converter htmlConverter.ConverterSettings = blinkConverterSettings;
|
Kindly try the provided solution on your end and let us know the result, If you still facing the issue, kindly share the input HTML file, Sample, and production/staging environment details with us. It will be helpful for us to analyze and assist you further on this.