• Post Reply Bookmark Topic Watch Topic
  • New Topic

Printing Postscript to PDF

 
Fernando Matias Valadao
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!