Hi, i use following code to open a aspose words document and print it.
the original document has 2 pages ,is printed on a existing printer, the first page has to be printed on tray-2 and all following pages on tray-3.
When printing with Microsoft Word, the document tray settings are respected and printing works.
But with AsposeWordsPrintDocument, the tray-settings are lost.
import java.awt.print.PrinterJob;
import java.io.File;
import java.io.FileInputStream;
import javax.print.PrintService;
import javax.print.attribute.HashPrintRequestAttributeSet;
import javax.print.attribute.PrintRequestAttributeSet;
import com.aspose.words.AsposeWordsPrintDocument;
import com.aspose.words.Document;
import com.aspose.words.License;
public class TestAsposePrint {
/**
- @param args
-
@throws Exception
*/
public static void main(String[] args) throws Exception {
Document doc = new Document(“C:\test.doc”);
String printerName = “\server\printer_1”;
PrinterJob pj = PrinterJob.getPrinterJob();
PrintService[] service = PrinterJob.lookupPrintServices();
for (PrintService printService : service) {
if(printService.getName().contains(printerName)){
pj.setPrintService(printService);
break;
}
}
// 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();
}
}
i do not want to use the printDialog, the documents are printed in batch.
Could you please look into this, do i need to map the trays from the document to printattributes or should this code work ?
thanks in advance.
With kind regards,
Paul Kwakman