Page 1 of 1

PrintPreview FDirectPrinting

PostPosted: March 10th, 2010, 10:03 pm
by donw
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.

Re: PrintPreview FDirectPrinting

PostPosted: March 11th, 2010, 1:27 am
by donw
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?

Re: PrintPreview FDirectPrinting

PostPosted: March 11th, 2010, 10:17 am
by Kambiz
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.

Re: PrintPreview FDirectPrinting

PostPosted: March 11th, 2010, 10:06 pm
by donw
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.

Re: PrintPreview FDirectPrinting

PostPosted: March 12th, 2010, 4:34 pm
by Kambiz
You're welcome!

By the way, why do you use direct printing?

Re: PrintPreview FDirectPrinting

PostPosted: March 15th, 2010, 2:41 pm
by donw
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.