private PdfPage getFieldPage(PdfDictionary annotDic) { PdfDictionary pageDic = annotDic.getAsDictionary(PdfName.P); if (pageDic != null) { return document.getPage(pageDic); } for (int i = 1; i <= document.getNumberOfPages(); i++) { PdfPage page = document.getPage(i); if (!page.isFlushed()) { PdfAnnotation annotation = PdfAnnotation.makeAnnotation(annotDic); if (annotation != null && page.containsAnnotation(annotation)) { return page; } } } return null; }
private PdfPage getFieldPage(PdfDictionary annotDic) { PdfDictionary pageDic = annotDic.getAsDictionary(PdfName.P); if (pageDic != null) { return document.getPage(pageDic); } for (int i = 1; i <= document.getNumberOfPages(); i++) { PdfPage page = document.getPage(i); if (!page.isFlushed()) { PdfAnnotation annotation = PdfAnnotation.makeAnnotation(annotDic); if (annotation != null && page.containsAnnotation(annotation)) { return page; } } } return null; }
/** * Get the page number associated to the provided widget. * * @param widget PdfWidgetAnnotation from which to extract the page number * @return page number */ protected int getWidgetPageNumber(PdfWidgetAnnotation widget) { int pageNumber = 0; PdfDictionary pageDict = widget.getPdfObject().getAsDictionary(PdfName.P); if (pageDict != null) { pageNumber = document.getPageNumber(pageDict); } else { for (int i = 1; i <= document.getNumberOfPages(); i++) { PdfPage page = document.getPage(i); if (!page.isFlushed()) { if (page.containsAnnotation(widget)) { pageNumber = i; break; } } } } return pageNumber; }
/** * Get the page number associated to the provided widget. * * @param widget PdfWidgetAnnotation from which to extract the page number * @return page number */ protected int getWidgetPageNumber(PdfWidgetAnnotation widget) { int pageNumber = 0; PdfDictionary pageDict = widget.getPdfObject().getAsDictionary(PdfName.P); if (pageDict != null) { pageNumber = document.getPageNumber(pageDict); } else { for (int i = 1; i <= document.getNumberOfPages(); i++) { PdfPage page = document.getPage(i); if (!page.isFlushed()) { if (page.containsAnnotation(widget)) { pageNumber = i; break; } } } } return pageNumber; }
private void addWidgetAnnotationToPage(PdfPage page, PdfAnnotation annot) { if (page.containsAnnotation(annot)) { return; } TagTreePointer tagPointer = null; boolean tagged = page.getDocument().isTagged(); if (tagged) { tagPointer = page.getDocument().getTagStructureContext().getAutoTaggingPointer(); //TODO attributes? tagPointer.addTag(StandardRoles.FORM); } page.addAnnotation(annot); if (tagged) { tagPointer.moveToParent(); } }
private void addWidgetAnnotationToPage(PdfPage page, PdfAnnotation annot) { if (page.containsAnnotation(annot)) { return; } TagTreePointer tagPointer = null; boolean tagged = page.getDocument().isTagged(); if (tagged) { tagPointer = page.getDocument().getTagStructureContext().getAutoTaggingPointer(); //TODO attributes? tagPointer.addTag(StandardRoles.FORM); } page.addAnnotation(annot); if (tagged) { tagPointer.moveToParent(); } }