Reputation: 111
How do I print a PDF file from a Java application?
Upvotes: 6
Views: 18047
Reputation: 28069
Try PDF Renderer. It's open source and there are a couple of examples on the site on how to render to a printer device.
Upvotes: 5
Reputation: 12858
I've used PDFBox before for a similar task like yours. It's an excellent library from the Apache Software Foundation. The class you are probably going to use is called: PDFTextStripper . The javadoc for the class can be found here.
Upvotes: 4
Reputation: 12433
Here some source code that will allow you print any text file:
public void print() {
//The desktop api can help calling other applications in our machine
//and also many other features...
Desktop desktop = Desktop.getDesktop();
try {
//desktop.print(new File("DocXfile.docx"));
desktop.print(new File("Docfile.pdf"));
} catch (IOException e) {
e.printStackTrace();
}
}
Maybe it suit your needs since you did not give more details.
Upvotes: 8