Accurate sizing with @top-xxx
I am supposed to produce pages on 8 1/2 by 11 paper that fit entirely inside a 7 3/8 by 9 1/8 inch centered rectangle, so that all printed material, including page headers, fits inside a 6 by 8 inch rectangle. I use @top-xxx to make the headers.
According to
https://www.princexml.com/doc/paged/, margin denotes the "page area". But how do I control the heights of the @top-xxx?
By default, margin boxes fill the entire space between the page margin and the edge of the page. If you need that not to be the case, you can stick a margin on the margin box itself to create space between the margin box and the edge of the page.
For example, if what you want is a 1" gap at the top of the page, followed by a 1" top margin box, you'd give the page a top margin of 2", then give the top margin boxes themselves a top margin of 1".
Besides what David suggested, I'm having good results using bleed. I set my page size to the finished size (your 7 3/8 by 9 1/8, if I'm reading correctly), bleed gets set to make up the difference of the 8 1/2 by 11 page, and the margins work downward. (NOTE, I haven't tried this with a background color or picture in the margins, but just putting text in the margin boxes leaves them properly placed)
So, you would do @page { size: 7.375in 9.125in; bleed: 0.9375in 0.5625in;} and then whatever you need your margins to be to get to that 6x8 actual content area.
Thanks, that's pretty much what I ended up doing. Start with @page size. I used -prince-trim instead of bleed because I wanted to use crop marks. NB. I switched to pt because otherwise the numbers got ugly. The moment of truth is to get back to letter size with pdfinfo. (Remember the crop marks take up 6pt on each side.)
Next, I sized the content area of the page, not counting the running head, with @page { margin: ... } The top-left, top-center, top-right regions, which I use for the running head, show above the top margin.
To have a gap between the top of the printable area and the running head, I added @page { @top-left { margin-top: ... } } and the same for @top-center @top-right.
And to have a gap between the running head and the page content, body { padding-top: ...}
None of this is rocket science, but it took me a fair amount of fussing to get it just so. It's easier if you don't care about crop marks.
Sounds like you've got a solid plan. Just a heads up, something you might want to check into.
A lot (most if not all) home and office printers - it's not a problem on the big digital press machines - introduce a little bit of offset when duplex (double sided) printing. This results in the text on the front of a page being a little lower or higher than the text on the back of a page. Under normal circumstances it's not really noticeable (and few people care if it is). Unfortunately, when you use trim marks, it will be noticable, because the marks at either the top or the bottom will be visible on one side after you've trimmed it down.
If you want to test the printer you will be using, create a simple document - letter size paper, 1 inch margins all around, enough paragraphs of text to fill at least 2 pages, add some page numbers in one of the margin boxes. It's easiest to evaluate what is going on if the text is justified and if you want to get fancy, generate the file using the snap to baseline function (just to be absolutely sure the pdf as the text all lined up to start with). Then, print the resulting PDF in duplex mode and hold the paper up to the light so you can see through it. If the top line of text perfectly lines up, all is well, and your trim lines will probably be completely trimmed away. If the text doesn't quite line up, you may wish to explore other options for marking out how to trim the pages once printed (or, manually duplex, or play around with the rotate/center/scale/etc settings in the print dialog for whatever pdf reader you will be printing from, there are other strategies for dealing with this too). Just a trick I learned from the people that print and bind books (this is an issue that happens regardless of the method you use to get a pdf, it's a printer feed problem, not a software problem, usually)