Problem while converting Razor View with Highcharts to PDF

Good evening,

I've been trying to convert my HTML page into a PDF to include inside a PdfDocument.
I tried to include my page as explained in the documentation URL to PDF with WebKit Rendering, but I've encountered two problems:
1- I need to include this page inside an existing PdfDocument, not a new one, and I saw that the HtmlToPdfConverter.Convert method accepts as parameter an "out PdfLayoutResult", so I tried to pass my PdfLayoutResult to the method but it seems it didn'add anything inside the PDF, like if it didn't Draw the page.
2- I tried then to create a new PdfDocument from my url, like the documentation, to see if atleast that would have worked. I managed to get and draw my page inside this new Pdf, but it doesn't render correctly the charts I have inside (two Highcharts charts). These charts are initialized but values aren't shown inside, i can see the title and Group names.

My questions are:
am I missing something? Is there any setting to add that waits for the page to complete all it's js/jquery functions?
Is there a way to include this page inside an existing PdfLayoutResult? I already have some grid inside and I need to have those together with my page.


Regards,
     Daniele

3 Replies

SL Sowmiya Loganathan Syncfusion Team April 20, 2020 11:56 AM UTC

Hi Focus Informatica Team,   
  
Thank you for contacting Syncfusion support.    
  
Queries   
Comments   
am I missing something? Is there any setting to add that waits for the page to complete all it's js/jquery functions?   
Yes, you can use the AdditionalDelay property in WebKitConverterSettings to wait for the converter for loading the Js/jquery functions.    
  
Refer below link for more information,   
Is there a way to include this page inside an existing PdfLayoutResult?   
HTML to PDF converter is only generate new PDF document from the URL/HTML converter. We do not have native support to convert the URL into an existing PDF document. However, we can achieve your requirements at the sample level.    
  
  1. Convert the HTML to PDF and get the template of converted PDF pages.
  2. Load the existing PDF document.
  3. We can draw the templates to the new/existing PDF pages at the desired location.
  
Please find the simple sample for your requirements.    
  
Please refer below links for more information,   
  
  
Please let us know if you need any further assistance with this.    
 
Regards, 
Sowmiya Loganathan 



FI Focus Informatica May 20, 2020 05:21 PM UTC

Hi Sowmiya Loganathan, thank you very much for your help.
I managed to convert my HTML page correctly but I've encountered another "problem":
 I've been trying to include the PdfTemplate between two PdfGrid and I managed to do that, but the Template uses a full page height, leaving a white space between this and the trailing Grid (my rendered HTML doesn't completely fill the page).
How can I "reduce" the Template height or remove all unused space, so that the Template will use only the space of the converted HTML?
Is this a thing achievable from code or do I need to do some fixes to my page?


Regards,
Daniele



SL Sowmiya Loganathan Syncfusion Team May 21, 2020 10:53 AM UTC

Hi Daniele,   
  
Thank you for the update.    
  
We have created a sample for your requirement using a single-page layout option. The sample will convert some HTML to PDF, which does not completely fill the page. The existing PDF document has two tables with some spaces in between the tables. The converted PDF page will be rendered in between the tables on the existing PDF document.    
  
  
Please refer below links for more information about the single-page layout,   
  
Kindly try the sample and let me know if it is suites your requirement.    
 
Regards, 
Sowmiya Loganathan 


Loader.
Up arrow icon