Logo
My Account |  Site Map | Contact Us  
Welcome Guest Search | Active Topics | Sign In | Register

Convert Url Taking much time Options
Deepak
Posted: Wednesday, September 30, 2015 10:33:58 AM
Rank: Member
Groups: Member

Joined: 7/30/2015
Posts: 12
Hi ,

We are using newest version of EO pdf, But we are facing one issue that is when i pass the URl to convert it to PDF file it is taking to much time, We have set MinLoadWaitTime to 2 sec, and Important thing is The page we are exporting contains HighCharts.

Please assist , how could i resolve this issue. if you need any other information please let me know.

Code: C#
var doc = new PdfDocument();
            var stream = new MemoryStream();
            
            HtmlToPdf.Options.NoLink = true;
            HtmlToPdf.Options.RepeatTableHeaderAndFooter = false;

            HtmlToPdf.Options.OutputArea = new RectangleF(0.5f, 0.5f, 7.5f, 10f);
            HtmlToPdf.Options.MinLoadWaitTime = 2000;
            string imgPath = HttpContext.Current.Server.MapPath("Test.png");
            HtmlToPdf.Options.BaseUrl = baseUrl;
            HtmlToPdf.Options.FooterHtmlFormat = "<div style='float: left;'>Page {page_number}</div><div style='float: right;'><img src='" + imgPath + "'/></div>";
            HtmlToPdf.ConvertUrl(exportUrl, doc);

            doc.Save(stream);
            stream.Position = 0;
            string fileName = string.Format("Report_{0}_{1}_{2}.pdf", "Test_", DateTime.Now.ToString("MMddyyyy"), DateTime.Now.Millisecond);


Thanks & Regards,
Deepak
eo_support
Posted: Wednesday, September 30, 2015 1:23:39 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 20,365
Hi,

Please try to avoid using FooterHtmlFormat. This property will run the HTML to PDF converter with the footer for every page and can significiantly increase the amount of time the whole conversion takes. You can use the HTML to PDF converter to convert the main contents and then use the "PDF Creator" interface to create the footer. "PDF Creator" is much less powerful and more difficult to use, but it is also much faster. If you are not familiar with PDF creator interface, you can start from here:

http://www.essentialobjects.com/doc/pdf/acm/getting%20started/hello_world.aspx

Thanks!
Deepak
Posted: Monday, October 5, 2015 5:23:55 AM
Rank: Member
Groups: Member

Joined: 7/30/2015
Posts: 12
Hi eo_support,

Thanks for the above suggestion, I did comment out the code, and it seems that it was little bit improvement in performance,

Some where i read that EO PDF render the PDF file same as Browser renders. so want to know that.

1) When i use Export to Url to export the HighCharts it is taking time, Do we have any way to render the JS file using EO.PDF API and Create SVG formatted HTML. I think it would take less time to convert it into PDF format.

2) Another thing is when i generate the PDF file 5-6 time after that the file was taking much time. I have checked all the SQL connections and related stuff but it was fine.
could you please suggest any thing we are missing here.

Waiting for your response.

Thanks & Regards,
Deepak
eo_support
Posted: Monday, October 5, 2015 8:39:59 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 20,365
Hi,

I believe HighCharts already renders to SVG. So that's not an issue.

To troubleshoot performance issue, you will want to run a network monitor to check whether it has to do with the network/your web server. When EO.Pdf converts a Url, it must load the page and all dependencies in the page (CSS, images, JavaScript, etc) first. That can take considerable amount of time if your server is slow to respond. Using a network monitor can help you to find out whether that is the case, and if that is the case, which request is slowing down the process. After you find that out, you can then troubleshoot your server side code to elimiate the bottleneck.

Thanks
Deepak
Posted: Monday, October 5, 2015 11:35:16 AM
Rank: Member
Groups: Member

Joined: 7/30/2015
Posts: 12
Hi,

Thanks for the reply,
Yes you are correct, HighChart Render the SVG tags,So can i use Convert HTML method to generate the PDF file which contains the HighChart code?.Simply passing the Highchart JS + HTML code and get the PDF output.

If Above approach is not works then shall i use Convert URL for the chart rendering and Convert HTML to render the rest of the HTML Tags

Please suggest best approach for it,Sorry for the multiple posts.

Thanks & Regards,
Deepak
eo_support
Posted: Monday, October 5, 2015 11:50:27 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 20,365
Hi,

Yes. You can do that. However you must set HtmlToPdf.Options.BaseUrl correctly if you use ConvertHtml instead of ConvertUrl.

Thanks!
Deepak
Posted: Monday, October 5, 2015 12:44:24 PM
Rank: Member
Groups: Member

Joined: 7/30/2015
Posts: 12
Hi,

Thanks for the Quick reply,
I'm getting the HTML contents only not the chart using convertHTML method. following is the code which i passed to ConvertHTMl method.


<html>
<head>
<title>PDF Export </title>
<script src="/Scripts/jquery-1.9.1.min.js"></script>

<link href="/Content/css/Test.css" rel="stylesheet"/>

</head>

<body>
<script src="/ScriptsFolder/highcharts.js"></script>
<div>
<div class="MainTable">
<div class="table-content">

<div class="RowData" id="chartId">
<div class=">
<div>
<div id="container">
</div>
</div>
</div>
</div>
<div class="RowData">
<div class="TestClass">
<div>


<style type="text/css">
tr:nth-child(even) {
background-color: #f1f1f1;
}

#TblId th {
color: black;
}

#TblId tr:hover {
background-color: #f7ecc1;
}

#TblId th {
background-color: #ffffff;
}

#TblId tr th{
border-bottom:1px solid #DDD !important;

}
#TblId tr td{
border:1px solid #DDD;

}
#TblId {
border-collapse:collapse;
}
</style>
<table id="TblId">
<thead>
<tr>
<td>Test</td>
<td> Test</td>
<td> Home</td>
<td>9/24/2015 4:18:34 PM</td>
<td>Test</td>
<td>52</td>
<td>274</td>

</tr>
</table>


</div>
</div>
</div>

</div>
</div>
</div>

<script type="text/javascript">

var WebData = {};

WebData.pageData = {
Id:55,
ChartDataUrl:"/Chart/GetWebChartData",
};
</script>
<script src="/ScriptsFolders/CreateChartData.js"></script>
</body>
</html>


and My CreateChartData contains the following code

$('#container').highcharts({
chart: {
type: 'column'
},
title: {
text: Title
},
xAxis: {
categories: result.XasixData,
crosshair: true
},
yAxis: {
min: 0,
title: { text: "" },
},
tooltip: {
headerFormat: '<span style="font-size:10px">{point.key}</span><table>',
},
plotOptions: {
column: {
pointPadding: 0.1,
borderWidth: 0
}
},
series:
result.seriesData
});

I have set the full path of URL for the BaseUrl Attribute as mentioned above
Please let me know what thing stoping me to generate the PDF with Charts, Help would be really appritiable.

Thanks & Regards,
Deepak
eo_support
Posted: Monday, October 5, 2015 3:27:04 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 20,365
Hi,

BaseUrl and full Url are not the same thing. See here for more details:

http://www.essentialobjects.com/doc/eo.pdf.htmltopdfoptions.baseurl.aspx

Thanks!
Deepak
Posted: Tuesday, October 6, 2015 2:52:12 AM
Rank: Member
Groups: Member

Joined: 7/30/2015
Posts: 12
Hi,

Thanks for the reply,
I have set the correct path and it is showing the CSS and other parts correctly, but my Highchart is not visible only i can see the blank space on the PDF file.
Also to add one thing, while generating the charts using HighCharts there is an AJAX call sent to a server side method which returns JSON data to build the charts. So will ConvertToHTML() work for JS which makes ajax calls and builds my charts ?

Code: C#
Runtime.AddLicense(LicenseKey);
            var doc = new PdfDocument();
            var stream = new MemoryStream();
            HtmlToPdf.Options.NoLink = true;
            HtmlToPdf.Options.RepeatTableHeaderAndFooter = false;
            HtmlToPdf.Options.BaseUrl = string.Format("{0}://{1}{2}", Request.Url.Scheme, Request.Url.Authority, Url.Content("~"));;
            HtmlToPdf.Options.OutputArea = new RectangleF(0.5f, 0.5f, 7.5f, 10f);
            HtmlToPdf.ConvertHtml(htmlReport, doc);

One observation that is MyPage is not loading the JS files which are CreateChart.js and Inline JS on the Page(using the convertHTML method).
I can see the HTML content only not the Js contents which are rendered by the HIghChart.JS file in SVG format. Please help me to resolve this issue.

Major thing I can see over here is if i run my code in HTML page it takes Less then a second but while exporting it is taking around 2 min using Convert URL method. Please suggest if we can do the same thing using the ConvertHTML method to improve the Performance.

Thanks & Regards,
Deepak
eo_support
Posted: Tuesday, October 6, 2015 8:45:46 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 20,365
Hi,

Generally you can not use ConvertHtml to call back to your own site. This can cause deadlock. This has to do with ASP.NET session lock. Try to run the code from a separate server and see if it works. If it does work, then please consider using ASPXToPDF or MVCToPDF instead.

You can also try to incease HtmlToPdf.Options.MinLoadWaitTime.

Thanks!
Deepak
Posted: Wednesday, October 7, 2015 8:01:31 AM
Rank: Member
Groups: Member

Joined: 7/30/2015
Posts: 12
Hi eo_support,

Thanking you very much to guide us, It is really helpful, We are able to implement the ConvertHTML method and Export the HighChart with rest of the HTML content.
Now the major issue that we are facing is PDF generation is too much slow. I kept HtmlToPdf.Options.MinLoadWaitTime=2000ms, and we are rendering the same web page on PDF(Web page is hardly taking 1.5 seconds to load the Data and HighCharts) and PDF taking around 2.5 Min to generate the PDF.HTML is just in Table format and there is not much css in the page.

Are we missing any configuration required to speed up the Export. We are continuously monitoring the N/W resources but not found any thing which blocks.
Please suggest what we can do to minimize the timing of Export.

Thanks & Regards,
Deepak
eo_support
Posted: Wednesday, October 7, 2015 9:24:04 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 20,365
Hi,

There isn't much you can tweak on the converter side. As mentioned in our original reply. You can use a network monitor to find out the bottleneck and then you can try to optimize that part. If all network requests are completed very quickly but you see CPU spike for a long time, then it's probabaly because of your page is too complex and it does take more time to convert. In that case you would just need to modify your page to have less contents so that it can convert faster.

Thanks!
Deepak
Posted: Thursday, October 8, 2015 4:53:50 AM
Rank: Member
Groups: Member

Joined: 7/30/2015
Posts: 12
Hi,

Thanks for the Reply,
We tracked one thing, when we export only the HTML content it is too much fast, But in other part if i include the Highchart it is too slow in export.and I checked that i can view that on Web page the chart is rendering too quickly,

I believe that HighChart render SVG graphics as BitMap image on the PDF file as per below url
http://www.essentialobjects.com/forum/postst6690_PDF-File-size.aspx

Could you please suggest us is there any provision we should take to remove this slowness if i include Highcharts.

Thanks & Regards,
Deepak
Deepak
Posted: Friday, October 9, 2015 6:41:04 AM
Rank: Member
Groups: Member

Joined: 7/30/2015
Posts: 12
Hi eo_support,

Please provide your valuable inputs on above post, We are facing the issue when we include the Highchart In PDF.

One more finding If i use below code my Highchart is not coming and Displays only HTML contents
Code: C#
var options = new HtmlToPdfOptions
            {
                NoLink = true,
                RepeatTableHeaderAndFooter = false,
                OutputArea = new RectangleF(0.5f, 0.5f, 7.5f, 10f),
                BaseUrl = baseUrl,

                RetrieveNodeText = false,
                MinLoadWaitTime = 10000,
                PreserveHighResImages = false,
                SaveImageAsJpeg = true,
                AllowLocalAccess=true,
                JpegQualityLevel = 10,
            };
            HtmlToPdf.ConvertHtml(htmlData, doc,options);


And Using Below code Highchart is coming

Code: C#
HtmlToPdf.Options.NoLink = true;
            HtmlToPdf.Options.RepeatTableHeaderAndFooter = false;
            HtmlToPdf.Options.OutputArea = new RectangleF(0.5f, 0.5f, 7.5f, 10f);
            HtmlToPdf.Options.BaseUrl = baseUrl;
            HtmlToPdf.Options.RetrieveNodeText = false;
            HtmlToPdf.Options.MinLoadWaitTime = 1000;
            HtmlToPdf.Options.PreserveHighResImages = false;
            HtmlToPdf.Options.SaveImageAsJpeg = true;
            HtmlToPdf.Options.JpegQualityLevel = 10;
            HtmlToPdf.ConvertHtml(htmlData, doc);


Is there any difference in both the options

Thanks & Regards,
Deepak
eo_support
Posted: Friday, October 9, 2015 10:17:19 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 20,365
Hi,

There should be no difference between these two. So we are not sure what to tell you. You can try to isolate the problem into a small test program and send the test program to us. Once we have that we can take a further look. Please see here for more information about sending test application to us:

http://www.essentialobjects.com/forum/test_project.aspx

Thanks!
Brad Blankenship
Posted: Sunday, November 8, 2015 4:31:46 PM
Rank: Advanced Member
Groups: Member

Joined: 11/8/2015
Posts: 32
Do you have an example of generating a PDF document without header and footer, followed bu using the PDF Creator, adding the header and footer after?

eo_support wrote:
Hi,

Please try to avoid using FooterHtmlFormat. This property will run the HTML to PDF converter with the footer for every page and can significiantly increase the amount of time the whole conversion takes. You can use the HTML to PDF converter to convert the main contents and then use the "PDF Creator" interface to create the footer. "PDF Creator" is much less powerful and more difficult to use, but it is also much faster. If you are not familiar with PDF creator interface, you can start from here:

http://www.essentialobjects.com/doc/pdf/acm/getting%20started/hello_world.aspx

Thanks!
eo_support
Posted: Sunday, November 8, 2015 8:39:03 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 20,365
Hello Brad,

There is nothing particular about "followed by using PDF creator adding the header and footer after". PDF creator can be used to add additional output to an existing PDF page. So this is exactly what you do: you call HTML to PDF converter to get a PdfDocument object first, then use PDF creator interface to add additional output to one or more pages in that PdfDocument object. You can start from the following link to get an idea how to use PDF creator interface:

http://www.essentialobjects.com/doc/pdf/acm/overview.aspx

This link will give you more specific samples on how to modify an existing PDF file:

http://www.essentialobjects.com/doc/pdf/existingfiles/modify.aspx

The code in the above sample creates a PdfDocument object from a physical PDF file. In case you use HTML to PDF converter, you do not have to do so since the output of the HTML to PDF is already a PdfDocument object.

Hope this helps. Please feel free to let us know if you still have any questions.

Thanks!
Israel Romero
Posted: Thursday, May 10, 2018 8:15:35 PM
Rank: Newbie
Groups: Member

Joined: 5/10/2018
Posts: 3
I have a similar performance issue, but not related to charts (already posted on a separate thread). It seems to be related to HTMLToPDF, though... that one seems to be taking very long.

All I want to do is add a footer to most of the pages in an existing PDF document.

Do you have an example of how to add a footer using PDF Creator (as opposed to HTMLToPDF)? It would be ideal, as it seems like it's a very popular request, but slightly more complex than a simple "Hello world" as it needs to be on a specific location (the bottom of the page).
eo_support
Posted: Friday, May 11, 2018 11:27:25 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 20,365
Israel Romero wrote:
I have a similar performance issue, but not related to charts (already posted on a separate thread). It seems to be related to HTMLToPDF, though... that one seems to be taking very long.

All I want to do is add a footer to most of the pages in an existing PDF document.

Do you have an example of how to add a footer using PDF Creator (as opposed to HTMLToPDF)? It would be ideal, as it seems like it's a very popular request, but slightly more complex than a simple "Hello world" as it needs to be on a specific location (the bottom of the page).


Hi,

If you were using HtmlToPdf.Options.HeaderHtmlFormat/FooterHtmlFormat to add header/footer, then make sure you try the latest version. In the latest version this two options works much faster than the old version.

If you still wish to use PDF Creator interface, then you can either use it inside AfterPageRender callback or after the whole conversion is done. See here for more details:

https://www.essentialobjects.com/doc/pdf/htmltopdf/header.aspx

The above code shows how to use HTML to PDF to add header/footer in these two scenarios (AfterPageRender callback and after the whole conversion is done). You will need to switch the code to use PDF Creator interface ---- this part does not have anything to do with header/footer in particular. So you can refer to the PDF creator interface documentation for more details.

Thanks!


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.