PDFDocument.Graphics.PreviousPage method? To number pages "page x of y"


I am familiarising myself with PDFDocument and so far have managed to create a decent looking mock exam paper based on random data pulled from an sqlitedatabase :slight_smile:

I use a pagecounter as integer to keep track of what page I’m on and increment it whenever I use the Graphics.NextPage method. At the bottom of each page I draw the page number “page x”.
Ideally, I would like it to say “page x of y”.

My initial thought was, after I’d finishing creating all pages, to then go back and number each page, now that I know the total. However, I was a bit surprised that there doesn’t seem to be a way to go back to a previous page. For my own education, why is that?

So to achieve what I want, would the best way be to calculate how many pages it will take to fit all the text at the start, before drawing anything? I know that will work, but it just seems a bit inelegant to loop through all the data twice, doing basically the same calculations and operations :stuck_out_tongue:

Any input would be appreciated.

What they want to do “simply”, understandably, there is currently no option in PDFDocument. But if you look at this feedback case <https://xojo.com/issue/65247>, which is marked as “Implemented”, you should get a feeling that the “soon” should be possible.

Aaah, thank you. I should have known that I would not be the first person to think of this!

The reason I requested it (besides needing it! ) is that in the Einhugur PDF plugin that I use, PDFpage is a class. There I just subclassed Einhugur’s PDFDocument class and overrided the AddPage Method to store the page reference in an array in it, so i could do things like that.

I was very surprised when Xojo initially released the PDF functionally that it was not more OOP and I could not do that!

I was originally thinking using Xojo PDF support when it came out, but the lack of that capability and some others missing features the Einhugur plugin has that I needed, along with some rough edges handling graphics, has made me take a wait and see attitude about switching over to using the Xojo PDF support.