In a sense, I'm asking how psnup
works.
Say I have an existing document that follows the document structuring conventions. I can scan it, pull out the prolog, trailer, and individual pages. I want to then embed selected pages into the output of another document, subject to scaling and translation. I've tried following the conventions for encapsulated post script, but those conventions assume the source material follows the right rules.
I've tried doing this:
Define these in the prolog:
/BeginEPSF {
/b4_inc_state save def % save state for cleanup
/dict_count countdictstack def % count objects on dict stack
/op_count count 1 sub def % count objects on operand stack
userdict begin % push userdict on dict stack
/showpage { } def % redefined showpage
0 setgray 0 setlinecap
1 setlinewidth 0 setlinejoin
10 setmiterlimit [] 0 setdash newpath
/languagelevel where
{pop languagelevel
1 ne
{false setstrokeadjust false setoverprint
} if
} if
} bind def
/EndEPSF {
count op_count sub {pop} repeat % clean up stacks
countdictstack dict_count sub {end} repeat
b4_inc_state restore
} bind def
Then in one of my output pages I do something like this:
%%Page: "1" 1
BeginEPSF
gsave
0.00000 49.76471 translate
0.64706 0.64706 scale
(copy one page from source document, discarding its leading %%Page)
grestore
EndEPSF
showpage
and yet the embedded page renders unchanged in the output document. Something in the embedded page overrides my BeginEPSF
function.
I've compared and confirmed that both my code and psnup copy the page contents unchanged (except for removing the %%Page comment), so it's something in the wrapping code.
Rather than spending several days trying to understand the psnup code, I was wondering if there was a document, similar to the EPS specification, that says how this should be done.