/** * Adds specified annotation to the end of annotations array and tagged it. * May be used in chain. * * @param annotation the {@link PdfAnnotation} to add. * @return this {@link PdfPage} instance. */ public PdfPage addAnnotation(PdfAnnotation annotation) { return addAnnotation(-1, annotation, true); }
newAnnot.setAction(copiedAction); entry.getKey().addAnnotation(-1, newAnnot, false);
protected void applyLinkAnnotation(PdfDocument document) { PdfLinkAnnotation linkAnnotation = this.<PdfLinkAnnotation>getProperty(Property.LINK_ANNOTATION); if (linkAnnotation != null) { int pageNumber = occupiedArea.getPageNumber(); if (pageNumber < 1 || pageNumber > document.getNumberOfPages()) { Logger logger = LoggerFactory.getLogger(AbstractRenderer.class); String logMessageArg = "Property.LINK_ANNOTATION, which specifies a link associated with this element content area, see com.itextpdf.layout.element.Link."; logger.warn(MessageFormatUtil.format(LogMessageConstant.UNABLE_TO_APPLY_PAGE_DEPENDENT_PROP_UNKNOWN_PAGE_ON_WHICH_ELEMENT_IS_DRAWN, logMessageArg)); return; } Rectangle pdfBBox = calculateAbsolutePdfBBox(); if (linkAnnotation.getPage() != null) { PdfDictionary oldAnnotation = (PdfDictionary) linkAnnotation.getPdfObject().clone(); linkAnnotation = (PdfLinkAnnotation) PdfAnnotation.makeAnnotation(oldAnnotation); } linkAnnotation.setRectangle(new PdfArray(pdfBBox)); PdfPage page = document.getPage(pageNumber); page.addAnnotation(linkAnnotation); } }
protected void applyLinkAnnotation(PdfDocument document) { PdfLinkAnnotation linkAnnotation = this.<PdfLinkAnnotation>getProperty(Property.LINK_ANNOTATION); if (linkAnnotation != null) { int pageNumber = occupiedArea.getPageNumber(); if (pageNumber < 1 || pageNumber > document.getNumberOfPages()) { Logger logger = LoggerFactory.getLogger(AbstractRenderer.class); String logMessageArg = "Property.LINK_ANNOTATION, which specifies a link associated with this element content area, see com.itextpdf.layout.element.Link."; logger.warn(MessageFormatUtil.format(LogMessageConstant.UNABLE_TO_APPLY_PAGE_DEPENDENT_PROP_UNKNOWN_PAGE_ON_WHICH_ELEMENT_IS_DRAWN, logMessageArg)); return; } Rectangle pdfBBox = calculateAbsolutePdfBBox(); if (linkAnnotation.getPage() != null) { PdfDictionary oldAnnotation = (PdfDictionary) linkAnnotation.getPdfObject().clone(); linkAnnotation = (PdfLinkAnnotation) PdfAnnotation.makeAnnotation(oldAnnotation); } linkAnnotation.setRectangle(new PdfArray(pdfBBox)); PdfPage page = document.getPage(pageNumber); page.addAnnotation(linkAnnotation); } }
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(); } }
page.addAnnotation(-1, newAnnot, false);