Slow PrintPreview

General TRichView support forum. Please post your questions here
Post Reply
HighTower
Posts: 11
Joined: Wed Oct 12, 2005 8:46 am
Location: Putins-Burg

Slow PrintPreview

Post by HighTower »

Is it normal, that print previre renerates too slow?

Code: Select all

       if ( !RVPrint->Ready )
         RVPrint->FormatPages(TRVDisplayOptions());

       PrintPreview->UpdateView();

       PrintPreview->SetFocus();
and RVPrint->FormatPages takes a lot of time, ~5 sec for 3 pages with text and tables (without pictures)!!! on P4 1.6, 512Mb

is it normal?
Sergey Tkachenko
Site Admin
Posts: 17522
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

The first call may be slower than others (a printing system is initialized)
HighTower
Posts: 11
Joined: Wed Oct 12, 2005 8:46 am
Location: Putins-Burg

Post by HighTower »

is it possible to preinitialize printing system [in background]?
Sergey Tkachenko
Site Admin
Posts: 17522
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

So do you confirm - it's the first call of FormatPages() which may take a lot of time, and subsequent calls are not slower than reformatting on the screen?

TRichView does nothing special but reads printer properties from the system and creates device context compatible to the printer. The initialization is performed by Windows.

Well, I do not know, you can try to create a hidden preview of empty document when the application is idle...
HighTower
Posts: 11
Joined: Wed Oct 12, 2005 8:46 am
Location: Putins-Burg

Post by HighTower »

I've found the source of problem - tables drawing!!!
If document doesnt containt tables - previewing of 15 pages takes less than 1 second, but if it does - a lot of time!!!
Sergey Tkachenko
Site Admin
Posts: 17522
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Please send me RVF document for testing
HighTower
Posts: 11
Joined: Wed Oct 12, 2005 8:46 am
Location: Putins-Burg

Post by HighTower »

here they are:
Создана ссылка на файл!
webfile.ru/578079
Имя файла - test_rvf.rar , размер 15 Кбайт. Файлу присвоен номер 578079, он будет доступен до 24.10.2005 16:46.
2 files in rar archive:

fast_13pages_text.rvf - 13 pages text with formatting only
slow_3pages_tables.rvf - 3 pages with tables
Sergey Tkachenko
Site Admin
Posts: 17522
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Downloaded. Will be tested tomorrow.
HighTower
Posts: 11
Joined: Wed Oct 12, 2005 8:46 am
Location: Putins-Burg

Post by HighTower »

and what about results and comments?
Sergey Tkachenko
Site Admin
Posts: 17522
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

It's no surprise that the second document's preview redrawing is slower. It has a complex layout with a lot of tables and small text.

There is a way to speed up the preview: set RVPrintPreview.CachePageImage to True (but do it only when running on WinXP, problems were reported on some Win9x computers).
In this mode, the page image is rendered in a metafile, and this metafile is shown in preview.
HighTower
Posts: 11
Joined: Wed Oct 12, 2005 8:46 am
Location: Putins-Burg

Post by HighTower »

set RVPrintPreview.CachePageImage to True
If the difference also is, it imperceptible (for me) undex WinXP

As I understood, the preview is generated for all pages. Mey be it'ld be better to generate preview for each page separately when it is neded?
Benoit B.

Post by Benoit B. »

HighTower wrote:I've found the source of problem - tables drawing!!!
If document doesnt containt tables - previewing of 15 pages takes less than 1 second, but if it does - a lot of time!!!
I use RichView for tables me too, and it's very slow :

for a file with 500 pages of tables, it works 5 minutes.
Sergey Tkachenko
Site Admin
Posts: 17522
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

To HighTower:
If RVPrintPreview.CachePageImage=False, no caching is used, and a trichview page-painting procedure is called on each repainting of the preview.
If RVPrintPreview.CachePageImage=True, the current page is rendered into a metafile, and then this metafile is drawn, so the trichview page-painting procedure is called only one time per page, when this page is shown for the first time. Only one page is cached. When you switch the preview to another page, a metafile is recreated. This metafile is also recreated after changing zooming percent.
So the initial displaying of each page in the caching mode may be even slower (time for creating metafile + time for drawing metafile), but scrolling will be faster.

To Benoit B.:
Try to optimize your document. For example, instead of using one huge table, try to use several smaller tables.
HighTower
Posts: 11
Joined: Wed Oct 12, 2005 8:46 am
Location: Putins-Burg

Post by HighTower »

so, as I understud - slow print [preview] of documents with tables - is a feature (or bug) of TRichView.
I've downloaded demos of WPTools http://www.wpcubed.com/ftp/wp5demo.zip
and DevExpress PrintingSystem http://www.devexpress.com/downloads/VCL ... S3Demo.zip
and they makes preview very, very fast!!!
and their speed doesn't depend on pages count and content...
Sergey Tkachenko
Site Admin
Posts: 17522
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

It's possible to make a very fast preview by drawing a page image in bitmap, and then showing this bitmap.
You can do it yourself, using RVPrint.MakeScaledPreview method.
Post Reply