As you know I'm currently updating the PostScript renderer. I'd like to
create a few FOP extensions for outputting custom PostScript code at key
places so people doing mass-printing can insert media selection code and
stuff like that into the PostScript stream.

fo:declaration is to be extended to:

((color-profile)+, (fox:ps-setup-code)*)

---

fox:ps-setup-code:

Content:
(#PCDATA)

Properties:
 * name (optional)

The content of a ps-setup-code element is inserted into the PostScript
stream right after the %%BeginSetup DSC comment and will itself be
surrounded by two comments: %FOPBeginSetupCode (with the name as
argument to the comment) and %FOPEndSetupCode.

Use case: The user can add special setup code, for example, initializing
the InputAttributes dictionary used for media selection.

---

fo:simple-page-master is to be extended to:

(region-body,region-before?,region-after?,region-start?,region-end?,
(fox:ps-page-setup-code)*)

---

fox:ps-page-setup-code:

Content:
(#PCDATA)

Properties:
 * name (optional)

The content of a ps-setup-code element is inserted into the PostScript
stream right after the %%BeginPageSetup DSC comment and will itself be
surrounded by two comments: %FOPBeginPageSetupCode (with the name as
argument to the comment) and %FOPEndPageSetupCode.

Use case: The user can add media selection setup code.

---

Example:

<fo:simple-page-master master-name="letterhead" page-height="29.7cm" 
page-width="21cm" margin="2cm">
  <fo:region-body/>
  <fox:ps-page-setup-code name="media-selection">
    &lt;&lt; /MediaType (letterhead) &gt;&gt; setpagedevice
  </fox:ps-page-setup-code>
</fo:simple-page-master>

will result in PostScript to:

[...]
%%Page: 1 1
%%PageBoundingBox: 0 0 595 842
%%PageHiResBoundingBox: 0 0 595 842
%%PageResources: (atend)
%%BeginPageSetup
%FOPBeginPageSetupCode: media-selection
<< /MediaType (letterhead) >> setpagedevice
%FOPEndPageSetupCode
<<
/PageSize [595 842]
/ImagingBBox null
>> setpagedevice
[1 0 0 -1 0 360] concat
%%EndPageSetup
%FOPBeginRegionViewport: xsl-region-body
[...]

---

That should cover most of the common requirements in this area. If
anyone needs custom code in the Trailer or PageTrailer this is easily
added later.

The most important thing here is probably that the generated PostScript
code is generally well-delimited with DSC comments and FOP-specific
comments so it is easy for people post-processing PostScript files to
modify them easily. Some people will only add a DSC comment into the
PostScript file instead of the actual media selection code. This comment
will then be expanded later.

Anybody opposed to my adding this? Anything missing?

Jeremias Maerki

Reply via email to