问题
i have a printer attached to CUPS, it supports duplex printing, how can i set it to print simplex or duplex through my java routine?
i have attempted using itext libraries using the ASET add and the addViewerPreference without any luck.
can anyone offer some suggestions?
回答1:
I've created a small ChangeViewerPreference code sample that adds a viewer preference to an existing PDF:
PdfReader reader = new PdfReader(src);
PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(dest));
stamper.addViewerPreference(PdfName.DUPLEX, PdfName.DUPLEXFLIPLONGEDGE);
stamper.close();
reader.close();
Possible values for this viewer preference are PdfName.SIMPLEX
, PdfName.DUPLEXFLIPSHORTEDGE
and PdfName.DUPLEXFLIPLONGEDGE
. This code implements ISO-32000-1 and works with all viewers that have implemented the viewer preferences as defined in ISO-32000-1. This isn't the case for all viewers you'll find on the market. Maybe that's why you don't have any luck.
Which tool are you using to render the PDF? (Note that I have no idea what "ASET add" means, so you may want to clarify.)
回答2:
When using IPP you should set the job-attribute
sides = two-sided-long-edge
https://docs.oracle.com/javase/7/docs/api/javax/print/attribute/standard/Sides.html
来源:https://stackoverflow.com/questions/21827760/printing-a-pdf-duplex-using-java