PrintPreview FDirectPrinting

Please post bug reports, feature requests, or any question regarding the DELPHI AREA projects here.

PrintPreview FDirectPrinting

Postby donw » March 10th, 2010, 10:03 pm

First off, I really appreciate your component.
I have been working with it for several months, and everything is working great except for one item. After displaying my pages, I go back and write in the page numbers and total pages at the bottom of each page. This works well when I use the preview form, but when I try to direct print, I get a 0 count of pages.

I do set direct printing properly, and FDirectPrinting is True when I first start the document. However, stepping through the code I found that somewhere in the code of Preview it gets turned back to False before I call for the total pages and so total pages reads the wrong variable. Any help would be appreciated.
donw
Member
Member
 
Posts: 4
Joined: March 10th, 2010, 9:52 pm

Re: PrintPreview FDirectPrinting

Postby donw » March 11th, 2010, 1:27 am

I think I finally realized why I could not get a good count on direct printing.

When previewing, I printed to the preview, ended the document, and then could get the page count by calling GetTotalPages, and then edited each page to print out the page number and total pages.

With Direct printing, the call to End Document clears the FDirectPrinting variable, and I guess, since the pages are bring sent directly to the printer, there are no pages to count after the End Document. So that was why I was getting 0.

Before starting to use the component I would build a context in memory, print to that, count the pages, and then send to the printer. I hope there is a better way with the component.

Can you suggest another way to get the count of total pages when using direct printing before they are sent to the printer?
donw
Member
Member
 
Posts: 4
Joined: March 10th, 2010, 9:52 pm

Re: PrintPreview FDirectPrinting

Postby Kambiz » March 11th, 2010, 10:17 am

Good that you have figured it out by yourself.

When you use direct printing, you should pre-calculate the total number of pages before print. There's no other way.
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2429
Joined: March 7th, 2003, 7:10 pm

Re: PrintPreview FDirectPrinting

Postby donw » March 11th, 2010, 10:06 pm

Thank you.

Ended up just using the component. Created a hidden one, printed to it to get my page counts, cleared it, and then printed again using direct print. Since I now had my page count it was easy to write in the page number and total pages as each page was printed directly.

Again, a great print preview component.
donw
Member
Member
 
Posts: 4
Joined: March 10th, 2010, 9:52 pm

Re: PrintPreview FDirectPrinting

Postby Kambiz » March 12th, 2010, 4:34 pm

You're welcome!

By the way, why do you use direct printing?
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2429
Joined: March 7th, 2003, 7:10 pm

Re: PrintPreview FDirectPrinting

Postby donw » March 15th, 2010, 2:41 pm

Just to give the customer a choice. The direct printing seems to give a slightly sharper printed report on a laser printer.
Also, just to let you know, playing your page metafiles into the Gnostice eDocEngine produces a very nice PDF also.
donw
Member
Member
 
Posts: 4
Joined: March 10th, 2010, 9:52 pm


Return to DELPHI AREA Projects

Who is online

Users browsing this forum: No registered users and 1 guest

cron