Your problem is on the performance issues of a 3rd party component, and I recommend you to ask in their forum instead for better support.
When we don't have the library, we can't do anything to even guess what could help.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi Team,
I am generating a PDF report from the Web Application UI. On the click of button, the PDF report will be downloaded.
I have used Essential Objects (eo.pdf library) to convert HTML to PDF in the api service (.Net Core). The HTML data is 8100 records. Currently it is taking 95 seconds to process and download the PDF report and I believe this might vary based on the data size.
I am facing performance issues with the converting HTML to PDF and the Azure Gateway Timeout limit is set 90 seconds, which is causing Application time out issues.
Need inputs to fix this issue and advise if the below code can be improved/optimized so that the HTML TO PDF conversion is quicker and the REPORT IS DOWNLOADED IN 60 SECONDS.
Below is the code for reference.
ReportHelper.cs file:
public ReportFile GenerateReport(FileType fileType)
{
byte[] result = null;
string contentType = "text/html";
switch (fileType)
{
case FileType.Pdf:
string html = HtmlHelper.ToHtml(Data, ReportSetting, this);
var pdfHelper = new eoPdfHelper();
result = pdfHelper.ConvertToPdf(html, ReportSetting);
if (string.IsNullOrEmpty(ReportSetting.FileName))
{
if (!string.IsNullOrEmpty(ReportSetting.ReportHeaderTitle))
{
ReportSetting.FileName = $"{ReportSetting.ReportHeaderTitle}_Report.pdf";
}
else
{
ReportSetting.FileName = "Report.pdf";
}
}
contentType = "application/pdf";
break;
}
return new ReportFile() { Data = result, ContentType = contentType, FileName = ReportSetting.FileName };
}
eoPdfHelper.cs file:
using System.Drawing;
using System.IO;
using EO.Pdf;
namespace Report
{
public class eoPdfHelper: IPdfHelper
{
public byte[] ConvertToPdf(string html, ReportSetting reportSetting)
{
MemoryStream stream = new MemoryStream();
HtmlToPdfOptions options = new HtmlToPdfOptions();
options.RetrieveNodeText = false;
options.OutputArea = new RectangleF(0.5f, 0.5f, 9f, 12f);
if (reportSetting.ReportOrientation == ReportOrientation.Landscape)
{
options.PageSize = PdfPageSizes.A4;
}
HtmlToPdf.ConvertHtml(html, stream, options);
return stream.ToArray();
}
}
}
Thanks.
Your problem is on the performance issues of a 3rd party component, and I recommend you to ask in their forum instead for better support.
When we don't have the library, we can't do anything to even guess what could help.