but the view
always prints at 100% and thus scaling does not print correctly
Yeah, you're dividing by the scaling factor, thus negating the
user wants to print at 0.75, you divide by 0.75 thus scaling your
area *up*, then the printing system multiplies by 0.75, and there
it: drawing at 1.0.
But, I got that from sample code in the "Printing" topic of the
Apple's cocoa documentation?
Nevertheless, I tried not dividing by the scaling and it still draws
at 100%. Furthermore it calculated the number of pages incorrectly.
For example, I had one printing that spanned 2 pages in horizontal
direction and 2 pages in vertical direction. Printing at 50% should
fit it all on to one page. If I remove the divide by scaling, the
knowsPageRange method always returns 4 pages and does not change when
the scaling changes?
So I tried a different approach and have it solved (an unsatisfying
solution, however, in that I still don't know why the other way failed).
Instead of overriding knowsPageRange and rectForPage, I overrode
and similarly for width. This uses the initial proposed setting, which
came from my margin settings, while the default method would check all
subviews and usually move the page break. I wanted to fill the paper
even if it meant going through subviews and this change solved that
problem. This way scales correctly as well.