This is a migrated thread and some comments may be shown as answers.

Data Exporting to PDF Questions

10 Answers 379 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Reid
Top achievements
Rank 2
Reid asked on 28 Feb 2019, 05:38 PM

1) My primary question is speed for large data sets.  If Kendo UI exports the data in this grid that contains 3475 records it takes 14-15 minutes.  The resulting PDF is fine but the time taken is not practical.

Are there any options here?

2) Any additional options for this in terms of adding rows, graphics etc.?

3) Are there any options for converting an Excel file to PDF using Kendo?

 

10 Answers, 1 is accepted

Sort by
0
Reid
Top achievements
Rank 2
answered on 01 Mar 2019, 12:57 PM

I found this link for exporting to PDF:
https://docs.telerik.com/devtools/document-processing/libraries/radspreadprocessing/overview

 

Will this work for .NET Core?  And will it be any faster for converting XLSX to PDF?

0
Boyan Dimitrov
Telerik team
answered on 05 Mar 2019, 01:01 PM
Hello,

In general I would suggest to take a look and check the https://docs.telerik.com/kendo-ui/framework/drawing/pdf-tabular-data solution if this will work for your case. Please note that this solution only exports data as pdf tabular data. It does not offer header customization like having images or anything special like this. It only exports the data in tabular format.  It does perform better with large data sets compared to the grid pdf export algorithm. 

Hope that this will be helpful. 

Regards,
Boyan Dimitrov
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Reid
Top achievements
Rank 2
answered on 05 Mar 2019, 01:45 PM

Hello,

This link does bot work for me.  I should have mentioned this application is using Kendo UI Core MVC.

0
Alex Hajigeorgieva
Telerik team
answered on 08 Mar 2019, 12:34 PM
Hi, Reid,

My name is Alex and I am taking over this thread while my colleague Boyan is away.

I believe that the suggestion is still valid and it is worth a shot because the static method uses an algorithm which is better than the built-in one for the grid in terms of performance, partly because it is simpler.

This is the last client-side option that can be tried and to use it in an MVC application, you would need a custom toolbar button, a click handler and the function itself, I tested it with 3475 records and it took 12 seconds:

*Test with server operations false. In case you are happy with the result, we can create another data source which will be a copy of the grid's data source but without a pageSize so all the records can be available at the time of export.

@(Html.Kendo().Grid<SomeModel.Models.OrderViewModel>()
   .Name("grid")
   .ToolBar(t=>t.Custom().IconClass("k-icon k-i-pdf").Name("CustomExport").Text("Export to PDF"))
   .DataSource(ds => ds
   .Ajax()
   .ServerOperation(false)
<script>
 $(document).ready(function () {
   $(".k-grid-CustomExport").on("click", function () {
     var grid = $("#grid").data("kendoGrid");
     kendo.spreadsheet.drawTabularData({
         dataSource: grid.dataSource,
         columns: grid.columns,
         headerBackground: "#567",
         headerColor: "#fff",
         evenBackground: "#eee",
         landscape: true,
         scale:0.8
     }).then(function (group) {
         kendo.pdf.saveAs(group, "test.pdf");
     });
   });
 });
</script>

As far as the server side options, the Kendo UI Document Processing Libraries do not have a dll for ASP.NET Core but they do have an item in their FeedBack portal. Could you please take a moment to upvote it? The more popular it gets, the sooner they will start working on it:

https://feedback.telerik.com/document-processing/1356226-document-processing-provide-version-for-net-core

Kind Regards,
Alex Hajigeorgieva
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Reid
Top achievements
Rank 2
answered on 19 Mar 2019, 10:27 PM

Hi Alex, thank you for providing the help.

I did vote on this.

My followup is this.  With your code it now takes about 1 minute to export to PDF.  That is a lot better than the 15 minutes it took before.  But the resulting PDF still contains two unwanted elements per page, the Grouping Header and the Paging Footer.  Is it possible in the code to remove them?

I includes this and it seems to have no effect :

.Pdf(pdf => pdf
                           .AllPages()
                           .AvoidLinks(true)
                           //.PaperSize("A4")
                           //.Scale(0.8)
                           .Scale(1.5)
                           //.Margin( top: "2cm", left: "1cm", right: "1cm", bottom: "1cm" )
                           .Margin("2cm", "1cm", "1cm", "1cm")
                           //.Landscape()                                        
                           .RepeatHeaders(false)
                           
                           .TemplateId("page-template")
                           .FileName("MCC_DataExport_ZenerDiodes.pdf")
                           //.ProxyURL(Url.Action("Zener_PDF_Export_Save", "DataExport"))
                       )

<script type="x/kendo-template" id="page-template">
      <div class="page-template">
        <div class="header">
          <div style="float: right">Page #: pageNum # of #: totalPages #</div>
          Multi-page grid with automatic page breaking
        </div>
        <div class="watermark">MCC</div>
        <div class="footer">
          Page #: pageNum # of #: totalPages #
        </div>
      </div>
</script>

(styles are included as well but I did not copy them here for brevity)

I also noticed that in setting ServerOperation(false) takes over twice as long for the data to load than it did with ServerOpteration(true).  Why is that?

Thanks

0
Alex Hajigeorgieva
Telerik team
answered on 22 Mar 2019, 01:25 PM
Hello, Reid,

The Kendo UI Grid built-in export has the ability to modify the PDF output by targeting the elements with the help of the .k-pdf-export class.

https://docs.telerik.com/kendo-ui/framework/drawing/drawing-dom#the-k-pdf-export-class

So to exclude the grouping header and the pager, you may add the following CSS rules:

<style>
  .k-pdf-export .k-grouping-header,
  .k-pdf-export .k-pager-wrap
  {
    display: none;
  }
</style>

However, the suggestion I made, uses only the data and it disregards any templates, grouping or pagers so I am a little unsure what is the sought after outcome in regards to that.

Here is a Dojo which has both of these options. Can you let me know what you would like to remove and from which export? Perhaps a screenshot with an indication would be helpful.

https://dojo.telerik.com/@bubblemaster/oHIMAvaJ

Kind Regards,
Alex Hajigeorgieva
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Reid
Top achievements
Rank 2
answered on 27 Mar 2019, 11:40 AM

Hi Alex, thanks for staying with me on this issue.

I took a look at the link you provided and the difference in my solution is that I am not initializing the grid in JavaScript as is used on that demo.

I am using Kendo UI Core MVC and the grid is declared and configured in markup.  The PDF is being generated correctly for the most part but the #template on the page does not get applied.  Yet with the code below the filename is coming through, yet the template is being ignored and other properties like Headers are showing on every page. :The footer is not coming through.

Pdf(pdf => pdf
     .AllPages()
     .AvoidLinks(true)
     .Author("MCC")
      .Title("MCC Zener Diodes")
      .RepeatHeaders(false)    
      .Scale(1.5)    
      .Margin("2cm", "1cm", "1cm", "1cm")                                    
      .RepeatHeaders(false)                          
       .TemplateId("page-template")
        .FileName("MCC_DataExport_ZenerDiodes.pdf")
       
      )

 

 

.                       

0
Boyan Dimitrov
Telerik team
answered on 01 Apr 2019, 11:52 AM
Hello,

The reason for this behavior is due to the fact that paperSize is not set and it is missing from the configuration. Please refer to the pdfTemplate where we state that paperSize should be set in order the template to work. 

.Pdf(pdf => pdf
    .AllPages()
    .AvoidLinks()
    .PaperSize("A4")
    .Margin("2cm", "1cm", "1cm", "1cm")
    .Landscape()
    .RepeatHeaders()
    .TemplateId("page-template")
    .FileName("Kendo UI Grid Export.pdf")
    .ProxyURL(Url.Action("Pdf_Export_Save", "Grid"))
)



Regards,
Boyan Dimitrov
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Reid
Top achievements
Rank 2
answered on 04 Apr 2019, 07:10 PM

Hello,

The only difference from my code to what you just posted was the .PaperSize("A4")
When I un-comment that out the process hangs basically and I have to terminate the browser.  Using Chrome.
Before it hangs the browser flashes the rendered page (flashes for about 1 sec) and you can see many rows with blank data, then it hangs even after stopping the debugger.

0
Alex Hajigeorgieva
Telerik team
answered on 09 Apr 2019, 12:10 PM
Hi, Reid,

The Pako Deflate library if not included can help a lot with any PDF Export over 1MB:

<!-- Load Pako Deflate library to enable PDF compression -->

In case the browser is unresponsive with the library included, then the only other on the client is the static method I mentioned earlier:

https://www.telerik.com/forums/data-exporting-to-pdf-questions#E6543S23WU2FdpeFx95PbQ

If the static method does not help, then the data set must be too large for the browser memory and one should consider using server-side export. Our Document Processing team has been working on a version to support ASP.NET Core and you can check out the latest information about it in this feature request item together with instructions on how to download and use it:

https://feedback.telerik.com/document-processing/1356226-document-processing-provide-version-for-net-core

Kind Regards,
Alex Hajigeorgieva
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
Grid
Asked by
Reid
Top achievements
Rank 2
Answers by
Reid
Top achievements
Rank 2
Boyan Dimitrov
Telerik team
Alex Hajigeorgieva
Telerik team
Share this question
or