Tilman, I ran the code on the OPs behalf and can confirm that this issue still exists without PDFBOX. I changed the Font size to 144 and the numPages to 4.
These are my test results: - PASS: All pages - PASS: First page only (1-1) - PASS: First three pages (1-3) - *FAIL: Second page only (2-2)* Nothing printed - *FAIL: Last page only (4-4)* Nothing printed - *Fail: Last two pages (3-4)* Nothing printed - *FAIL: Last three pages (2-4)* This one's interesting because it DOES print but only pages 3-4. This smells like an off-by-one error. I opened a ticket with my company's OpenJDK support team. The assigned dev is on vacation so there's no upstream bug report to link yet. Thanks for the code snippet, I'll provide this with the private bug report as it'll greatly help narrow down the cause. On Wed, Aug 6, 2025 at 6:28 AM Tilman Hausherr <thaush...@t-online.de> wrote: > Did you run this code? Did it reproduce the problem? > > Tilman > > Am 31.07.2025 um 12:42 schrieb Seethalakshmi Sathya: > > Thank you! > > > > On Thu, Jul 31, 2025 at 12:20 PM Tilman Hausherr <thaush...@t-online.de> > > wrote: > > > >> Am 31.07.2025 um 06:22 schrieb Tilman Hausherr: > >>> I think the bug is in the jdk, and I'll write something small later to > >>> prove this. > >> And here it is, I asked ChatGPT ("Create a program in java that uses the > >> Pageable interface to print a 10 pages document with the numbers from 1 > >> to 10. The print option dialog should be used for additional manual > >> configuration.") and modified it slightly: > >> > >> > >> public class PageableTest extends Book > >> { > >> private final int numPages = 2; > >> > >> public static void main(String[] args) > >> { > >> PrinterJob job = PrinterJob.getPrinterJob(); > >> job.setPageable(new PageableTest()); > >> > >> // Show print dialog for manual configuration > >> if (job.printDialog()) > >> { > >> try > >> { > >> job.print(); > >> } > >> catch (PrinterException e) > >> { > >> e.printStackTrace(); > >> } > >> } > >> } > >> > >> // Return the number of pages > >> @Override > >> public int getNumberOfPages() > >> { > >> return numPages; > >> } > >> > >> // Not needed for this example > >> @Override > >> public PageFormat getPageFormat(int pageIndex) throws > >> IndexOutOfBoundsException > >> { > >> if (pageIndex >= numPages) > >> { > >> throw new IndexOutOfBoundsException("Invalid page index"); > >> } > >> return PrinterJob.getPrinterJob().defaultPage(); > >> } > >> > >> // Return the Printable that will render the content > >> @Override > >> public Printable getPrintable(int pageIndex) throws > >> IndexOutOfBoundsException > >> { > >> if (pageIndex >= numPages) > >> { > >> throw new IndexOutOfBoundsException("Invalid page index"); > >> } > >> > >> return new Printable() > >> { > >> @Override > >> public int print(Graphics g, PageFormat pf, int index) > >> throws PrinterException > >> { > >> Graphics2D g2d = (Graphics2D) g; > >> g2d.translate(pf.getImageableX(), pf.getImageableY()); > >> g2d.setFont(new Font("Serif", Font.BOLD, 72)); > >> g2d.drawString(String.valueOf(index + 1), 100, 100); > >> return Printable.PAGE_EXISTS; > >> } > >> }; > >> } > >> } > >> > >> > >> --------------------------------------------------------------------- > >> To unsubscribe, e-mail: users-unsubscr...@pdfbox.apache.org > >> For additional commands, e-mail: users-h...@pdfbox.apache.org > >> > >> > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@pdfbox.apache.org > For additional commands, e-mail: users-h...@pdfbox.apache.org > >