We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Priting a document use large amount of memory and take a very long time in java

I print a PDF file using PdfViewer.
I need to print a 5MB file (not so large) 14 pages.
Because of an open issue the printing quality is very poor.
I changed the resolution using viewer.setResolution(600);
In order to execute such operation it takes 4GB of memory and goes into a huge garbage collection.
The printig operation take more than 3 minutes before the printer is activated.
Could You provide a solution ?
Any suggestion ?
Tks
Tullio

public void print(byte[] xpDocument, String xpPrinterName, int xpCopies) throws IOException {
	LOGGER.info("Print step 1");
	Document doc = new Document(new ByteArrayInputStream(xpDocument));
	LOGGER.info("Print step 2");
	PdfViewer viewer = new PdfViewer();
	LOGGER.info("Print step 3");
	viewer.setResolution(600);
	viewer.bindPdf(doc);
	viewer.setPrintPageDialog(false);
	if(xpPrinterName == null) {
		viewer.printDocument();
	} else {
		LOGGER.info("Print step 4");
		PdfPrinterSettings settings = viewer.getDefaultPrinterSettings();
		LOGGER.info("Print step 5");
		settings.setCopies((short)xpCopies);
		settings.setPrinterName(xpPrinterName);
		viewer.printDocumentWithSettings(settings);
		LOGGER.info("Print step 6");
	}
}

@AxiomaBo

I have been able to reproduce the issue on our end. A ticket with ID PDFJAVA-40608 has been created in our issue tracking system to further investigate the issue on our end. This thread has been linked with the issue so that you may be notified once the issue will be fixed.