Jump to content
dkprojektai

Export to PDF speed

Recommended Posts

Hello, 

 

Does any body face with problem - generating pdf speed...

 

I use Fast Report:

    frxReport9.PrepareReport();
    frxPDFExport9.ShowDialog := False;
    frxPDFExport9.FileName := FormatDateTime('hhnnss', Time)+'_Report.pdf';
    frxReport9.Export(frxPDFExport9);

 

this code works extremely slow with more then 5000 dateset records.

 

Is there any speedy alternative?

 

Share this post


Link to post
5 hours ago, dkprojektai said:

Hello, 

 

Does any body face with problem - generating pdf speed...

 

I use Fast Report:


    frxReport9.PrepareReport();
    frxPDFExport9.ShowDialog := False;
    frxPDFExport9.FileName := FormatDateTime('hhnnss', Time)+'_Report.pdf';
    frxReport9.Export(frxPDFExport9);

 

this code works extremely slow with more then 5000 dateset records.

 

Is there any speedy alternative?

 

That code is not much help in understanding the speed issue. What is the data source for your report? Is it the actual report generation which takes time, or the data preparation? In other words, what is happening in PrepareReport? And what do you mean by "extremely slow?" How many pages are produced, and in what time period?

I work routinely in ReportBuilder, and these are the issues I would look at. One more: If you produce in your report a line saying page x of y, I would guess that FastReport will generate the report twice. Certainly that is how ReportBuilder does it.

Apart from these issues, I found a few years ago that there can be huge performance differences among the different in-memory datasets, so I wonder whether that may be a factor for you.

Share this post


Link to post

Take a profiler and save you time guessing what is slow.

I use Nexus Quality Suite and I like it but there are also some free alternatives. Actually first time I used it I found the bottleneck with the trial version of NQS. I like very much line profiler. If you try it for these 4 lines it is very probably the first line and not the last that is the bottleneck. Then you goo deeper.

 

P.S. If the time is big enough you can see also in debugging if the first or last line is slower. If the last line is slow then not the dataset is bottleneck but maybe some very big picture.

Edited by Cristian Peța

Share this post


Link to post

Thank you all, what I found - disable all to False (for frxPDFExport9). It helps a little. There is picture (8 KB), but I think, it's not this who gives low speed for building PDF. For me 5000 records was build thru 15 seconds. It's too much for me. I use 6.6.9 version and D10.3.

 

Any other thoughts ?

Share this post


Link to post
22 minutes ago, dkprojektai said:

Thank you all, what I found - disable all to False (for frxPDFExport9). It helps a little. There is picture (8 KB), but I think, it's not this who gives low speed for building PDF. For me 5000 records was build thru 15 seconds. It's too much for me. I use 6.6.9 version and D10.3.

Again, with no knowledge of content, it is impossible to speculate. If one row per record, you are talking about roughly 60 pages, and though we always want things to be fast, 15 seconds for 60 pages doesn't sound terrible.

You need to do some profiling. Also isolate the timing of the report production from any data preparation. Lacking any detailed knowledge of your code, we can offer no specifics.

Share this post


Link to post

At Export() that 5000 records doesn't count because the report is prepared.

How many pages are? How many items per page? There are also vector images like charts or EMF, WMF?

 

I tested for example 40 pages (200 records with one image and 30 text items per record) with booth FR Export and printing to "Microsoft print to PDF". The speed is about 3 seconds for both on a i7-8700K CPU. This is only Export because I do this at preview where the report is already prepared.

 

P.S. You are too scarce with details and want a suggestion.....

Edited by Cristian Peța
  • Like 1

Share this post


Link to post
14 hours ago, dkprojektai said:

There is picture (8 KB), but I think, it's not this who gives low speed for building PDF.

Just to be sure, have you tried without the picture? Is there 1 picture for the report, or 1 picture for each record?

Share this post


Link to post

What about the queries that provide the data to the report - are they fast if they are run stand alone?

Share this post


Link to post
11 hours ago, Lars Fosdal said:

What about the queries that provide the data to the report - are they fast if they are run stand alone?

/* Affected rows: 0  Found rows: 4 956  Warnings: 0  Duration for 1 query: 1,109 sec. (+ 0,032 sec. network) */

Share this post


Link to post

Have you tried with Microsoft driver?
 

frxReport9.PrintOptions.PrnOutFileName := 'name.pdf';
frxReport9.PrintOptions.Copies := 1;
frxReport9.PrintOptions.ShowDialog := False;
frxReport9.PrintOptions.Printer := 'Microsoft Print to PDF';
frxReport9.SelectPrinter;
frxReport9.Print;

 

Share this post


Link to post
8 minutes ago, Cristian Peța said:

Have you tried with Microsoft driver?
 


frxReport9.PrintOptions.PrnOutFileName := 'name.pdf';
frxReport9.PrintOptions.Copies := 1;
frxReport9.PrintOptions.ShowDialog := False;
frxReport9.PrintOptions.Printer := 'Microsoft Print to PDF';
frxReport9.SelectPrinter;
frxReport9.Print;

 

I can't use it, because all works on Unigui web server. 

Share this post


Link to post

This procedure takes 76% of time in my case
2694    procedure TfrxPDFExport.ExportViaVector(const Memo: TfrxCustomMemoView);

 

and was called because GapY was -1

  if (Memo.ReducedAngle <> 0) or (Min(Memo.GapX, Memo.GapY) < 0) then
    ExportViaVector(Memo)

With Gap=0 for some of memo components ExportViaVector() takes 44% of time and the report looks the same but the PDF is generated in 6 seconds vs. 13 seconds

 

Edit: Better take a profiler and don't lose the time guessing.

Edited by Cristian Peța
  • Like 2

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×