Inject Page n of z at the bottom of every page.

  • Using WPDF 2.x, WPTools 5.x, and Delphi 6.x

    We are using the WPDFPrinter to print multiple reports into a single PDF utilizing the BeginDoc / EndDoc.

    Every page is initiated with StartPage and ends with EndPage.

    What I want to do is create a two pass system where I can determine how many pages this document will be so I can inject a Page n of z at the bottom right of every page.

    What I would like to figure out is what math would I use and code to make it always print at the same position on all pages regardless of orientation. So essentially the text always starts at .35 inches above the bottom of the page and the right aligned text is always .35 inches to the left of the right side of the page...

    So I know I am using the Canvas.TextOut, but I am not sure of what to use to always put the text in the same area. I am guessing I would use the page width and page height values and subtracting some number to get the position to start the text.

    I am also not sure what to pass to make it right aligned (This isn't critical, but figured right aligning would be helpful). Most important issue is what math to get the same starting position.

    • Offizieller Beitrag

    Hi,

    There is the event
    OnBeforePrintPage: TWPPDFPrintPageEvent

    That could be used to print anything before any other wptools output. Unfortunately this event is yet not been called for tghe other output. That would be possible to do though. I think about that.

    T print righjt alignt I usually measure the width of the string and subtract that value from the desired end position for text out.

    Julian

  • Zitat von wpsupport

    Hi,

    There is the event
    OnBeforePrintPage: TWPPDFPrintPageEvent

    That could be used to print anything before any other wptools output. Unfortunately this event is yet not been called for tghe other output. That would be possible to do though. I think about that.

    T print righjt alignt I usually measure the width of the string and subtract that value from the desired end position for text out.

    Julian

    I guess I don't fully understand the WPDF product, but it appears I can do the Canvas.TextOut(?,?,?) and I see it show up on the PDF. My only issue is determining what calculations to use to make sure I have it in the same spot every time.

    It seems that I should be able to use the width and height of the page and then subtract the proper numbers to position it at the same spot every time. But what I don't know is what calculation to use to properly position it every time. Do I take screen resolution or pixelsperinch into consideration?

    What I tried to do was this:

    So it seems like I could do the above, but maybe I need a better calculation for the (BOLD) areas.

    Maybe I am going about this wrong, but it just seems like this would be the way to do it.

    And to be honest my test does pretty good, but for the print routine that works with Ace Reports positions it higher so I am thinking I am not using the best calculation or not taking something into consideration.