On 21-Sep-2014 10:52:38 Deri James wrote: > On Sun 21 Sep 2014 06:38:42 Werner LEMBERG wrote: >> >> A good starting point may be to implement a C/C++ library function, >> >> to extract the MediaBox properties; that would open the gate to a >> >> possible pdfbb request, which gtroff.exe could process internally. >> > >> > >> > Alternatively, we could modify the existing implementation of .psbb, >> > such that it will discriminate on `%!PS-Adobe-´ or `%PDF-´ as >> > initial file content, then DTRT wrt parsing a `%%BoundingBox:´ or >> > `/MediaBox´ record accordingly. >> >> >> Good idea! >> >> >> Werner > > Yes, it is. Someone on the list has contacted me, with a view to writing > the code, and I have provided the perl version. > > It is a bit more complex than psbb, which is essentially a grep for > %BoundingBox in the first part of the postscript file. This is because > MediaBox can appear in multiple object types in a hierarchical fashion. > Unlike postscript, each page in a pdf document can be a different size. > So to be sure of the correct MediaBox to use it is necessary to parse > the complete document, find the page you are interested in (page 1 in > the case of PDFPIC) and then search for the MediaBox in the page object > or any of its ancestors. > > Cheers > Deri
Just to clarify: Strictly speaking, in PostScript also each page can be a different size (though there is nothing built-in to groff to arrange this). First of all, the coordinates fo placing a mark can be arbitrary. Next, what will appear when the document is rendered will depend on the PostScript interpreter. The "%%BoundingBox" that Deri refers to grepping for is in fact not part of the PostScript commands which determine what will be placed on the page, and where; it is in fact a Comment which the PostScript interpreter may or may not ignore. The "%%" ensure that it is ignored when the printing instructions are carried out. There is, for instance, a "%%PageBoundingBox:" comment defined in the PostScript Language Specification. Quote: "This comment specifies the bounding box that includes all the martks painted on a particular page (this is not the bounding box of the whole document -- see the %%BoundingBox: comment)." So there is a lot of flexibility of this kind in PostScript; but by default this is not exploited by groff (which, by default, does not even insert a %%BoundingBox: comment, though one can easily do this by putting appropriate commands in the start-up script one uses). Best wishes to all, Ted. ------------------------------------------------- E-Mail: (Ted Harding) <ted.hard...@wlandres.net> Date: 21-Sep-2014 Time: 12:45:35 This message was sent by XFMail -------------------------------------------------