htmlToPdfConverter generate a blank pdf in deployment server

Hi.

I am using Blink converter in an asp.net MVC core app.

When I run my app in the development machine it successfully generates the PDF, but when I publish the app it generates a black PDF.


My code:

public IActionResult ExportResultadoToPDF(int? id)

{

if (id == null)

return BadRequest();


string cookieName = "UserLoginCookie";


string cookieValue = string.Empty;

if (Request.Cookies[cookieName] != null)

{

cookieValue = Request.Cookies[cookieName];

}


HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(HtmlRenderingEngine.Blink);


BlinkConverterSettings settings = new BlinkConverterSettings();

settings.ViewPortSize = new Syncfusion.Drawing.Size(990, 0);

settings.Cookies.Add(cookieName, cookieValue);

settings.BlinkPath = @"C:\Program Files (x86)\Syncfusion\HTMLConverter\19.4.0.38\BlinkBinaries";

settings.AdditionalDelay = 10000;

htmlConverter.ConverterSettings = settings;


string url = HttpContext.Request.GetEncodedUrl();

url = url.Replace("ExportResultadoToPDF", "ResultadoAnalise");


PdfDocument document = htmlConverter.ConvertPartialHtml(url, "relatorio-analise");

MemoryStream stream = new MemoryStream();

document.Save(stream);

return File(stream.ToArray(), System.Net.Mime.MediaTypeNames.Application.Pdf, $"resultadoAnalise_{id}.pdf");

}



I've already tried everything I found here in the forum, but nothing works.


Thanks! ;)


9 Replies

GK Gowthamraj Kumar Syncfusion Team January 4, 2022 11:27 AM UTC

Hi Flavio, 

We can convert the authenticated web page to PDF using cookies in HTML to PDF converter. We suspect that reported issue may occurs, if the cookies values are not authenticated properly in that webpage URL and return black page. Also when the webpage (HTML) is not available or accessible, it will return blank. Please check the internet connection and check the HTML URL is rendered properly in Chrome browser’s print preview in server machine. Also please confirm us whether the issue occurs with simple webpage (https://www.google.com) in your server and let us know the details.  


We request you to share the input accessible HTML URL, output document, complete code snippet, server environmental details (OS, Bit version, platforms, culture settings), replication sample with steps to check the issue on our end. So, that it will be helpful for us to analyze and assist you further on this.   

Regards, 
Gowthamraj K 



FS Flavio Sidnei Sidnei Baia January 4, 2022 07:35 PM UTC

Thanks for the rapid answer!


I'm sending my test project.

Steps to reproduce:

1-Publish the project

2-In the production app click on the Print menu.

3-Log in (User = test Password = test)

4-Click the Print PDF button.

5-PDF generated is blank (Problem)


Obs 1: As I told you before, the problem only appears in the production server. I've published the test here for demonstration:

Print PDF - WebAppToPDF (sarfcred.com.br) [https://cliente.sarfcred.com.br/Home/Print]


OBS 2: The blank pdf page seems to be related to the ej2 component. 

The app has a dependence on ej2 Syncfusion, If you go to the _Layout page in the Shared folder and remove the script: 

 <script src="https://cdn.syncfusion.com/ej2/dist/ej2.min.js"></script>

The pdf is generated.


Thanks again!


Attachment: WebAppToPDF_f8879ff0.rar


PV Prakash Viswanathan Syncfusion Team January 5, 2022 12:49 PM UTC

Hi Flavio,


Thank you for sharing the details.


We have checked the provided sample and it is working fine in our local machine. Since the issue occurs in production environment, could please share more details about product environment such as OS, Server details, hosting plan if any used, RAM, processor, language, user group details etc., it will be helpful for us to configure the same environment in our side to replicate the issue in our side.


Regards,

Prakash V



FS Flavio Sidnei Sidnei Baia January 5, 2022 02:22 PM UTC

Hi!


The app is hosted in a on-premise server, config below:

Windows Server 2012 R2 Standard 64bits (compilação 9200)

Intel Xeon CPU E5-2407 2.20GHz

24 GB RAM

Lang: pt-br

IIs 8.5.9600.16384

.net 6.0, selfContained = false


Thanks ;)



GK Gowthamraj Kumar Syncfusion Team January 6, 2022 01:01 PM UTC

Hi Flavio, 

Currently, we are creating an same environment for reproducing the issue on our end and we will update the further details on January 10th 2022. 

Regards, 
Gowthamraj K 



FS Flavio Sidnei Sidnei Baia January 6, 2022 01:30 PM UTC

OK, thanks.


I'm looking forward.



GK Gowthamraj Kumar Syncfusion Team January 10, 2022 06:38 PM UTC

Hi Flavio,

 
We have checked the reported issue in same server environment, but it is working properly and the PDF generate with content. We have attached the modified sample with output document for your reference, please try the below sample on your end and let us know the result.

Sample: https://www.syncfusion.com/downloads/support/forum/171642/ze/WebAppToPDF-1742765571
 
 
If still issue occurs, please confirm us whether the simple (https://www.google.com) URL to PDF conversion is working or not? please share the replication steps with video to analyze on this. 

Regards, 
Gowthamraj K 



FS Flavio Sidnei Sidnei Baia January 15, 2022 11:47 PM UTC

Hi!


I found the problem, it was caused by Cloudflare Rocket Loader.


The Rocket Loader (It is a CloudFlare technology with loads javascript files in a different way) was enabled for the app. I disable it and Works!


Thanks for the help ;)



GK Gowthamraj Kumar Syncfusion Team January 17, 2022 06:30 AM UTC

Hi Flavio,

 
Thank you for your update. We are glad to know that your problem has been solved. 

Regards, 
Gowthamraj K 


Loader.
Up arrow icon