Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Printing Postscript to PDF

807603Oct 21 2005 — edited Nov 29 2007
Hello there!
I don't know if this is the most appropriate Sun forum to ask this kind of question, but as I didn't find a better one, I'm gonna post it here, so please, don't blame me :)

I need to convert some Postscripts files to PDF. The solution I came up with was to print these files to "Adobe Acrobat Distiller printer", as it follows:

...
PrintService[] printers = PrintServiceLookup.lookupPrintServices(null, null);
PrintService printer = //some logic iterating through "printers" to find the "Distiller" printer

//Creates the output file attribute
URI uri = new URI("file:/" + dest);
Destination destFile = new Destination(uri);
PrintRequestAttributeSet attributes = new HashPrintRequestAttributeSet();
attributes.add(destFile);

//Creates the input Postscript doc
InputStream ps = new FileInputStream(path);
Doc printerDoc = new SimpleDoc(ps, INPUT_STREAM.POSTSCRIPT, null);

//Finally prints the doc :)
DocPrintJob printerJob = printer.createPrintJob();
printerJob.print(printerDoc, attributes);

The problem is that the output file is ALSO a Postscript, and not a PDF (which is the Distiller output format).
It's tricky because if you print any document to Distiller (for example, a Word document inside Word program), the output is a PDF file.
Does anybody know why this is happening? Am I missing any configuration in the Java API?
Please, let me know if you have any issue concerning this problem.

Best wishes,

Fernando
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 27 2007
Added on Oct 21 2005
3 comments
343 views