如何在Java应用程序中打印PDF文件?

如何在Java应用程序中打印PDF文件?

问题描述:

如何从Java应用程序打印PDF文件?

How do I print a PDF file from a Java application?

这里有一些源代码可以让你打印任何文本文件:

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.