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! ;)
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!
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
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 ;)
OK, thanks.
I'm looking forward.
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 ;)