我有一个rtf文件,我想使用系统的本地打印机进行打印?
我已经尝试过使用打印机作业,但是我不知道如何使用它,因此我在下面尝试了此代码,但是似乎不起作用。
文件夹=新文件(“ D:\ projects \ emrs3 \ PMS \ Claim \ PaperRTF”);
File [] listOfFiles = folder.listFiles();
int j = 3;
为(int i = 0; i
如果(listOfFiles [i] .isFile()){
//System.out.println("File " + listOfFiles[i].getName());
Document doc = new Document(listOfFiles[i].getAbsolutePath());
PrinterJob pj = PrinterJob.getPrinterJob();
// Initialize the Print Dialog with the number of pages in the document.
PrintRequestAttributeSet attributes = new HashPrintRequestAttributeSet();
attributes.add(new PageRanges(1, doc.getPageCount()));
// Create the Aspose.Words' implementation of the Java Pageable interface.
AsposeWordsPrintDocument awPrintDoc = new AsposeWordsPrintDocument(doc);
// Pass the document to the printer.
pj.setPageable(awPrintDoc);
// Print the document with the user specified print settings.
pj.print(attributes);
我希望打印出PDF文件