JDK-8364428 : [macOS] Printing a PDF by entering a page range of 2 to 2 fails—no output is produced
  • Type: Bug
  • Component: client-libs
  • Sub-Component: 2d
  • Affected Version: 8,11,17,24
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: os_x
  • CPU: x86_64
  • Submitted: 2025-07-30
  • Updated: 2025-08-08
  • Resolved: 2025-08-08
Related Reports
Duplicate :  
Description
ADDITIONAL SYSTEM INFORMATION :
OS X - sequoia - 15.5
Apache PDF BOX - 3.0.5

A DESCRIPTION OF THE PROBLEM :
Printing a pdf file with a specific page using the print dialog fails. Print is not done.

REGRESSION : Last worked in version 24.0.2

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Run the example code mentioned in this mail, after setting the "file" to a valid PDF file.
2. Select "Range from" option on the displayed print settings dialog.
3. Type "2" in both the "from" and "to" text boxes.
4. Click Print.
5. Notice that the application just quits. 

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Print the document on the printer.
ACTUAL -
App quits (somtimes crashes) with doing nothing.

---------- BEGIN SOURCE ----------
import java.awt.print.PrinterJob;

import java.io.File;



import org.apache.pdfbox.Loader;

import org.apache.pdfbox.io.RandomAccessReadBufferedFile;

import org.apache.pdfbox.pdmodel.PDDocument;

import org.apache.pdfbox.printing.PDFPageable;

 

public class ApachePdfPrintTest {  

	

  private static final File file = new File("PATH_TO_PDF_FILE");

  

  public static void main(String[] args) {



	  try {



		  final PrinterJob pJob = PrinterJob.getPrinterJob();



		  //final PDDocument doc = PDDocument.load(file);

		  final PDDocument doc = Loader.loadPDF(new RandomAccessReadBufferedFile(file));

		  

		  pJob.setPageable(new PDFPageable(doc));

		  

		  if (pJob.printDialog()) {

			  pJob.print();

		  }



	  } catch (final Exception e) {

		  e.printStackTrace();

	  }

  } 

  

} 
---------- END SOURCE ----------


Comments
Additional Information from submitter: =============================== I have attached a screen recording of the crash. You can also reproduce this by downloading the Cook'n app for Mac from <LINK> 1. The printer target does not matter. 2. The application is using Open JDK 17.0.2. However the source code was developed with Java 17. 3. The snippet I provided was tested with both Java 17 and 24.0.2. Attached the crash report
08-08-2025

Mail to submitter: ================ Regarding the bug you reported “Printing a PDF with page range fails on Mac OSX” As described, after selecting a specific page range (e.g., setting both "From" and "To" to "2" in the print dialog) and clicking "Print", the application simply quits silently—it does not proceed with printing, nor does it present any crash/exception indication. We do not observe any obvious signs of crashing , but the process exits abruptly after attempting to print a specific page range. This behavior appears consistent with the issue described in JDK-8297191. But We want to understand “Sometimes crashes” as you mentioned “App quits (sometimes crashes) with doing nothing”. Please can you share screen clipping, any crash log or errors. Also, Could you please confirm if this functionality was working correctly in earlier JDK versions? If so, could you specify which JDK version(s) it worked with?
04-08-2025

Duplicate of https://bugs.openjdk.org/browse/JDK-8297191
31-07-2025