My app creates a pdf page from app data, using Quartz and UIGraphics.
Basically I define a CGRect docRect
to fit on that page, then increment an NSInteger yOffset
each time I draw something.
If yOffset
gets larger than docRect.size.height
I do a UIGraphicsBeginPDFPage()
.
This works fine, BUT:
I would like to draw a page count at the bottom, like "Page X of Y".
X is obviously easy to tell, but at the moment when I create a new page, I don't know how large Y might be.
I see 2 possible solutions for this:
After drawing all pages, reiterate through all pages and add the counter. Problem: As far as I can tell, after calling
UIGraphicsBeginPDFPage()
there is no way to return back to previous pages. Is anyone able to disconfirm that?Calculate all
yOffset
increments in advance to get the total page count. Possible, but IMHO not really an elegant solution.
Has anyone advice on this problem?
Thanks in advance, m