Free Support Forum -

Silent print in Words

Is it posible to print silent with Apsose for Words Java. Without a print screen. We want to create and render and mailmerge word documents, and automaticly print these document, without preview screen.
Hi Ernst,

Thanks for your inquiry.

Yes, it is possible for Aspose.Words.Java to print silently using your default printer. Following code for your reference should be helpful in this case:

// Open Document and Create PrinterJob instance initially associated with default printer.

Document doc = new Document(inputFilePathStr);
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);

You can also have a quick look here to have a better understanding of printing using Aspose.Words.Java. Hope this helps. Please let us know if you need any further assistance.