You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-dev@xmlgraphics.apache.org by Jeremias Maerki <de...@greenmail.ch> on 2005/08/26 15:57:53 UTC

FOP extension to output custom PostScript instructions

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


Re: FOP extension to output custom PostScript instructions

Posted by Jeremias Maerki <de...@greenmail.ch>.
You got me thinking about extensions, Finn. I've written down my
thoughts in the Wiki [1]. I don't have time to implement the full extent
of my ideas right now, but I think I'll try to implement the PS
extensions in the way I outlined them on that page. If anyone wants more
information I can add some more detailed information on how I imagine to
implement this stuff. Additional thoughts welcome.

[1] http://wiki.apache.org/xmlgraphics-fop/ExtensionPoints

On 31.08.2005 00:32:17 Finn Bock wrote:
> >>[Jeremias on <fox:ps-> extensions]
> >>
> >>
> >>>Anybody opposed to my adding this? ...
> >>
> >>Not at all, but I assume that you ask because it can't be added as an 
> >>extension that is completely seperated from FOP. That you have to make 
> >>changes to FOP sources in order to add it.
> > 
> > Yes, that's true.
> > 
> >>And that is IMO a bit of a failure of FOP and the renderer design.
> 
> [Jeremias]
> 
> > Why do you think this is a design failure?
> 
> I would like if anybody, not just FOP comitters, could add such usefull 
> features to FOP. And it is mostly the renderers that can't be extended 
> by dynamicly loaded extensions.
> 
> regards,
> finn



Jeremias Maerki


Re: FOP extension to output custom PostScript instructions

Posted by Jeremias Maerki <de...@greenmail.ch>.
Well, in a certain aspect that is already the case today. I've recently
added to possibility to dynamically add renderer-specific XML handlers.
I need this for the Barcode4J extension for example (directly prividing
EPS and PDF versions of the barcode to the renderer). Furthermore, you
can always subclass and replace a default renderer. I intend to add
dynamic lookup support for that, too. As for other extensions I think it
would be very difficult to guess what people need. Those extension
mechanisms always have their limitations. I expect people to speak up if
they have particular requirements that should be but cannot be fulfilled
using a dynamic plugin. We can then do something about it. So I don't
really understand what you're after. Do you have a concrete conception
how such a thing would look like?

As a related issue: Can we add extension attributes to existing FO
elements? I don't think so. Imagine the possibility to specify on an
external-graphic that the image is to be only referenced in a PostScript
file instead of embedded. Or to specify an SVG to be rendered to a
bitmap instead of the native format because the native format may not
yet be as feature-complete as the bitmap output from Batik. Useful for
very few people but useful nonetheless but this information would
currently also have to be hard-coded into our sources. So if there are
requirements let's specify them and check how we can integrate them into
a good design. I'm very much interested to do that.

On 31.08.2005 00:32:17 Finn Bock wrote:
> >>[Jeremias on <fox:ps-> extensions]
> >>
> >>
> >>>Anybody opposed to my adding this? ...
> >>
> >>Not at all, but I assume that you ask because it can't be added as an 
> >>extension that is completely seperated from FOP. That you have to make 
> >>changes to FOP sources in order to add it.
> > 
> > Yes, that's true.
> > 
> >>And that is IMO a bit of a failure of FOP and the renderer design.
> 
> [Jeremias]
> 
> > Why do you think this is a design failure?
> 
> I would like if anybody, not just FOP comitters, could add such usefull 
> features to FOP. And it is mostly the renderers that can't be extended 
> by dynamicly loaded extensions.
> 
> regards,
> finn



Jeremias Maerki


Re: FOP extension to output custom PostScript instructions

Posted by Finn Bock <bc...@worldonline.dk>.
>>[Jeremias on <fox:ps-> extensions]
>>
>>
>>>Anybody opposed to my adding this? ...
>>
>>Not at all, but I assume that you ask because it can't be added as an 
>>extension that is completely seperated from FOP. That you have to make 
>>changes to FOP sources in order to add it.
> 
> Yes, that's true.
> 
>>And that is IMO a bit of a failure of FOP and the renderer design.

[Jeremias]

> Why do you think this is a design failure?

I would like if anybody, not just FOP comitters, could add such usefull 
features to FOP. And it is mostly the renderers that can't be extended 
by dynamicly loaded extensions.

regards,
finn

Re: FOP extension to output custom PostScript instructions

Posted by Jeremias Maerki <de...@greenmail.ch>.
On 30.08.2005 16:06:08 Finn Bock wrote:
> [Jeremias on <fox:ps-> extensions]
> 
> > Anybody opposed to my adding this? ...
> 
> Not at all, but I assume that you ask because it can't be added as an 
> extension that is completely seperated from FOP. That you have to make 
> changes to FOP sources in order to add it.

Yes, that's true.

> And that is IMO a bit of a failure of FOP and the renderer design.

Why do you think this is a design failure? The problem is that XSL-FO
doesn't (directly) provide for certain needs. For example, it doesn't
provide any means to add device control information (like paper type and
other print job information). In the past I've had to post-process PDF
to add device control code. The difficult thing was to know which page
was created by which simple-page-master so the right paper can be
selected. Some FOP users simply need such a mechanism however it looks
like. My proposal is one that doesn't try to provide a concrete means to
specify paper types but simply provides a means for people to add the
control code themselves. XEP and other commercial vendors did similar
things, although some have chosen XML processing instructions for that.
I prefer a special namespace.

An alternative could probably be JDF to handle these specific features
but this beast is much too complex and there are only a few expensive
systems that support it. Most of us doing mass-printing simply need to
inject a few PostScript commands into the PostScript stream. This should
all not be very invasive.

JDF: http://en.wikipedia.org/wiki/Job_Definition_Format

Step 2 after this extension might be a PPD parser so the PS Renderer
could create the right control code based on logical information. But
that is a lot of work. I'd like to keep it simple to start with.

Jeremias Maerki


Re: FOP extension to output custom PostScript instructions

Posted by Finn Bock <bc...@worldonline.dk>.
[Jeremias on <fox:ps-> extensions]

> Anybody opposed to my adding this? ...

Not at all, but I assume that you ask because it can't be added as an 
extension that is completely seperated from FOP. That you have to make 
changes to FOP sources in order to add it.

And that is IMO a bit of a failure of FOP and the renderer design.

regards,
finn