@Test @LogMessages(messages = { @LogMessage(messageTemplate = LogMessageConstant.REMOVING_PAGE_HAS_ALREADY_BEEN_FLUSHED, count = 2) }) public void removeFlushedPage() throws IOException { String filename = "removeFlushedPage.pdf"; int pageCount = 10; PdfDocument pdfDoc = new PdfDocument(new PdfWriter(destinationFolder + filename)); PdfPage removedPage = pdfDoc.addNewPage(); int removedPageObjectNumber = removedPage.getPdfObject().getIndirectReference().getObjNumber(); removedPage.flush(); pdfDoc.removePage(removedPage); for (int i = 0; i < pageCount; i++) { PdfPage page = pdfDoc.addNewPage(); page.getPdfObject().put(PageNum, new PdfNumber(i + 1)); page.flush(); } Assert.assertTrue("Remove last page", pdfDoc.removePage(pdfDoc.getPage(pageCount))); Assert.assertFalse("Free reference", pdfDoc.getXref().get(removedPageObjectNumber).checkState(PdfObject.FREE)); pdfDoc.close(); verifyPagesOrder(destinationFolder + filename, pageCount - 1); }
public boolean removePage(int pageNum) { if (pageNum < from || pageNum >= from + getCount()) return false; decrementCount(); kids.remove(pageNum - from); return true; }
PdfPages extends PdfObjectWrapper<PdfDictionary> { public boolean removePage(int pageNum) { if (pageNum < from || pageNum >= from + getCount()) return false; decrementCount(); kids.remove(pageNum - from); return true; } }
PdfPages extends PdfObjectWrapper<PdfDictionary> { public boolean removePage(int pageNum) { if (pageNum < from || pageNum >= from + getCount()) return false; decrementCount(); kids.remove(pageNum - from); return true; } PdfPages(int from, PdfDocument pdfDocument, PdfPages parent);  PdfPages(int from, PdfDocument pdfDocument);  PdfPages(int from, int maxCount, PdfDictionary pdfObject, PdfPages parent); }
PdfPages extends PdfObjectWrapper<PdfDictionary> { public boolean removePage(int pageNum) { if (pageNum < from || pageNum >= from + getCount()) return false; decrementCount(); kids.remove(pageNum - from); return true; } PdfPages(int from, PdfDocument pdfDocument, PdfPages parent);  PdfPages(int from, PdfDocument pdfDocument);  PdfPages(int from, int maxCount, PdfDictionary pdfObject, PdfPages parent); void addPage(PdfDictionary page); boolean addPage(int index, PdfPage pdfPage); boolean removePage(int pageNum); void addPages(PdfPages pdfPages); void removeFromParent(); int getFrom(); int getCount(); void correctFrom(int correction); PdfArray getKids(); PdfPages getParent(); void incrementCount(); void decrementCount(); int compareTo(int index); }
PdfPages extends PdfObjectWrapper<PdfDictionary> { public boolean removePage(int pageNum) { if (pageNum < from || pageNum >= from + getCount()) return false; decrementCount(); kids.remove(pageNum - from); return true; } PdfPages(int from, PdfDocument pdfDocument, PdfPages parent);  PdfPages(int from, PdfDocument pdfDocument);  PdfPages(int from, int maxCount, PdfDictionary pdfObject, PdfPages parent); void addPage(PdfDictionary page); boolean addPage(int index, PdfPage pdfPage); boolean removePage(int pageNum); void addPages(PdfPages pdfPages); void removeFromParent(); int getFrom(); int getCount(); void correctFrom(int correction); PdfArray getKids(); PdfPages getParent(); void incrementCount(); void decrementCount(); int compareTo(int index);  }