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

Free Support Forum - aspose.com


I cant figure out how this should work.
if i want to print page 3.5. and 7 how do i do?
Or is it not possible, your java doc is a little bit unclear on this point.
How can i set the page numbers when the input value is int?


public void setPrintRange(int value)
Sets the page numbers that the user has specified to be printed.
value - PdfPrintRange element
See Also:

Hi Mattias,

Thanks for contacting support.

In order to accomplish this requirement, please try using following code snippet.


// Create PdfViewer object<o:p></o:p>

com.aspose.pdf.facades.PdfViewer viewer = new com.aspose.pdf.facades.PdfViewer();

// Open input PDF file

viewer.bindPdf(path + "4pages.pdf");

viewer.setAutoResize(true); // Print the file with adjusted size

viewer.setAutoRotate(true); // Print the file with adjusted rotation

com.aspose.pdf.printing.PdfPrinterSettings printerSettings = new com.aspose.pdf.printing.PdfPrinterSettings();



printerSettings.setPrintRange(com.aspose.pdf.printing.PdfPrintRange.Selection);//or PdfPrintRange.SomePages

com.aspose.pdf.printing.PrintPageSettings pageSettings = new com.aspose.pdf.printing.PrintPageSettings();

// print PDF document

viewer.printDocumentWithSettings(pageSettings, printerSettings);

// close the Pdf file.


Thanks for a fast and good answer,
Ok that explains setPrintRange function.
I belive PdfPrintRange.AllPages is default.

The setFromPage and setToPage is clear. So if i want to print pages between 1-3 or 2-4 i use PdfPrintRange.Some Pages

But if i want to print pages 1, 3, 5 i should use PdfPrintRange.Selection
According to your doc it should be possible to select pages

The selected pages are printed.
How can i set selected pages programatically, my printing service is running without GUI


Thanks for sharing the details.

Currently Aspose.Pdf for Java offers the feature to specify the range of pages which you need to print but I am afraid currently Aspose.Pdf for Java do not offer the feature to set page number information for selected pages to be printed. However for the sake of correction, I have logged an investigation ticket as PDFJAVA-36224 in our issue tracking system. We will further look into the details of this problem and will keep you updated on the status of correction. Please be patient and spare us little time. We are sorry for this inconvenience.

The issues you have found earlier (filed as PDFJAVA-36224) have been fixed in Aspose.Pdf for Java 16.11.0.

This message was posted using Notification2Forum from Downloads module by Aspose Notifier.

The issues you have found earlier (filed as ) have been fixed in this update. This message was posted using BugNotificationTool from Downloads module by MuzammilKhan