Bug 47093 - [PATCH] A PrintRenderer using Java Print Service API
Summary: [PATCH] A PrintRenderer using Java Print Service API
Status: NEW
Alias: None
Product: Fop - Now in Jira
Classification: Unclassified
Component: general (show other bugs)
Version: all
Hardware: All All
: P2 enhancement
Target Milestone: ---
Assignee: fop-dev
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-04-24 08:01 UTC by Martin Voelkle
Modified: 2012-05-23 08:27 UTC (History)
0 users



Attachments
the PrintRenderer (2.54 KB, application/octet-stream)
2009-04-24 08:01 UTC, Martin Voelkle
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Voelkle 2009-04-24 08:01:05 UTC
Created attachment 23537 [details]
the PrintRenderer

The attached PrintRenderer uses the Java Print Service API, introduced in Java 1.4.
It allows to programmatically set print options, like the destination printer and media tray. I use it like this:

// Construct a FopFactory
FopFactory fopFactory = FopFactory.newInstance();
FOUserAgent userAgent = fopFactory.newFOUserAgent();

// Setup FOP print renderer
PrintRenderer renderer = new PrintRenderer();
renderer.setUserAgent(userAgent);
userAgent.setRendererOverride(renderer);

// Construct fop with desired output format
Fop fop = fopFactory.newFop(MimeConstants.MIME_FOP_PRINT, userAgent);
ContentHandler handler = fop.getDefaultHandler();

// lookup a printer
PrintService service = PrintServiceLookup.lookupDefaultPrintService();
DocPrintJob job = service.createPrintJob();
PrintRequestAttributeSet attributes = new HashPrintRequestAttributeSet();
// set print request attributes here, like the media tray

// print
job.print(renderer, attributes);

If this PrintRenderer replaced the current one (hint, hint), I could skip the "Setup FOP print renderer" section.
Comment 1 Glenn Adams 2012-04-07 01:44:01 UTC
resetting P2 open bugs to P3 pending further review
Comment 2 Glenn Adams 2012-04-11 03:21:39 UTC
increase priority for bugs with a patch