private void prepareNonVisibleSignature(PDSignatureField signatureField) { // "Signature fields that are not intended to be visible shall // have an annotation rectangle that has zero height and width." // Set rectangle for non-visual signature to rectangle array [ 0 0 0 0 ] signatureField.getWidgets().get(0).setRectangle(new PDRectangle()); }
private void assignSignatureRectangle(PDSignatureField signatureField, COSDictionary annotDict) { // Read and set the rectangle for visual signature COSArray rectArray = (COSArray) annotDict.getDictionaryObject(COSName.RECT); PDRectangle rect = new PDRectangle(rectArray); PDRectangle existingRectangle = signatureField.getWidgets().get(0).getRectangle(); //in case of an existing field keep the original rect if (existingRectangle == null || existingRectangle.getCOSArray().size() != 4) { signatureField.getWidgets().get(0).setRectangle(rect); } }
private void assignAppearanceDictionary(PDSignatureField signatureField, COSDictionary apDict) { // read and set Appearance Dictionary PDAppearanceDictionary ap = new PDAppearanceDictionary(apDict); apDict.setDirect(true); signatureField.getWidgets().get(0).setAppearance(ap); }
/** * @see PDTerminalField#PDTerminalField(PDAcroForm) * * @param acroForm The acroForm for this field. */ public PDSignatureField(PDAcroForm acroForm) { super(acroForm); getCOSObject().setItem(COSName.FT, COSName.SIG); getWidgets().get(0).setLocked(true); getWidgets().get(0).setPrinted(true); setPartialName(generatePartialName()); }
@Override public void createWidgetDictionary(PDSignatureField signatureField, PDResources holderFormResources) throws IOException { COSDictionary widgetDict = signatureField.getWidgets().get(0).getCOSObject(); widgetDict.setNeedToBeUpdated(true); widgetDict.setItem(COSName.DR, holderFormResources.getCOSObject()); pdfStructure.setWidgetDictionary(widgetDict); LOG.info("WidgetDictionary has been created"); }
@Override public void createSignature(PDSignatureField pdSignatureField, PDPage page, String signerName) throws IOException { PDSignature pdSignature = new PDSignature(); PDAnnotationWidget widget = pdSignatureField.getWidgets().get(0); pdSignatureField.setValue(pdSignature); widget.setPage(page); page.getAnnotations().add(widget); if (!signerName.isEmpty()) { pdSignature.setName(signerName); } pdfStructure.setPdSignature(pdSignature); LOG.info("PDSignature has been created"); }
@Override void constructAppearances() throws IOException { PDAnnotationWidget widget = this.getWidgets().get(0); if (widget != null) { // check if the signature is visible if (widget.getRectangle() == null || Float.compare(widget.getRectangle().getHeight(), 0) == 0 && Float.compare(widget.getRectangle().getWidth(), 0) == 0 || widget.isNoView() || widget.isHidden()) { return; } // TODO: implement appearance generation for signatures LOG.warn("Appearance generation for signature fields not yet implemented - you need to generate/update that manually"); } } }
@Override public void createAppearanceDictionary(PDFormXObject holderForml, PDSignatureField signatureField) throws IOException { PDAppearanceDictionary appearance = new PDAppearanceDictionary(); appearance.getCOSObject().setDirect(true); PDAppearanceStream appearanceStream = new PDAppearanceStream(holderForml.getCOSObject()); appearance.setNormalAppearance(appearanceStream); signatureField.getWidgets().get(0).setAppearance(appearance); pdfStructure.setAppearanceDictionary(appearance); LOG.info("PDF appearance dictionary has been created"); }
@Override public void createSignatureRectangle(PDSignatureField signatureField, PDVisibleSignDesigner properties) throws IOException { PDRectangle rect = new PDRectangle(); rect.setUpperRightX(properties.getxAxis() + properties.getWidth()); rect.setUpperRightY(properties.getTemplateHeight() - properties.getyAxis()); rect.setLowerLeftY(properties.getTemplateHeight() - properties.getyAxis() - properties.getHeight()); rect.setLowerLeftX(properties.getxAxis()); signatureField.getWidgets().get(0).setRectangle(rect); pdfStructure.setSignatureRectangle(rect); LOG.info("Signature rectangle has been created"); }
PDAnnotationWidget widget = signatureField.getWidgets().get(0); PDRectangle rect = new PDRectangle(50, 650, 200, 50); widget.setRectangle(rect);
signatureField.getWidgets().get(0).setPage(page); signatureField.getWidgets().get(0).setPrinted(true); checkFields)) PDAnnotationWidget widget = signatureField.getWidgets().get(0);
private void prepareNonVisibleSignature(PDSignatureField signatureField) throws IOException { // "Signature fields that are not intended to be visible shall // have an annotation rectangle that has zero height and width." // Set rectangle for non-visual signature to rectangle array [ 0 0 0 0 ] signatureField.getWidgets().get(0).setRectangle(new PDRectangle()); }
private void assignSignatureRectangle(PDSignatureField signatureField, COSDictionary annotDict) { // Read and set the rectangle for visual signature COSArray rectArray = (COSArray) annotDict.getDictionaryObject(COSName.RECT); PDRectangle rect = new PDRectangle(rectArray); PDRectangle existingRectangle = signatureField.getWidgets().get(0).getRectangle(); //in case of an existing field keep the original rect if (existingRectangle == null || existingRectangle.getCOSArray().size() != 4) { signatureField.getWidgets().get(0).setRectangle(rect); } }
private void assignAppearanceDictionary(PDSignatureField signatureField, COSDictionary apDict) { // read and set Appearance Dictionary PDAppearanceDictionary ap = new PDAppearanceDictionary(apDict); apDict.setDirect(true); signatureField.getWidgets().get(0).setAppearance(ap); }
private void assignAppearanceDictionary(PDSignatureField signatureField, COSDictionary apDict) { // read and set Appearance Dictionary PDAppearanceDictionary ap = new PDAppearanceDictionary(apDict); apDict.setDirect(true); signatureField.getWidgets().get(0).setAppearance(ap); }
@Override public void createWidgetDictionary(PDSignatureField signatureField, PDResources holderFormResources) throws IOException { COSDictionary widgetDict = signatureField.getWidgets().get(0).getCOSObject(); widgetDict.setNeedToBeUpdated(true); widgetDict.setItem(COSName.DR, holderFormResources.getCOSObject()); pdfStructure.setWidgetDictionary(widgetDict); LOG.info("WidgetDictionary has been created"); }
@Override public void createWidgetDictionary(PDSignatureField signatureField, PDResources holderFormResources) throws IOException { COSDictionary widgetDict = signatureField.getWidgets().get(0).getCOSObject(); widgetDict.setNeedToBeUpdated(true); widgetDict.setItem(COSName.DR, holderFormResources.getCOSObject()); pdfStructure.setWidgetDictionary(widgetDict); LOG.info("WidgetDictionary has been created"); }
doc.getDocumentCatalog().setAcroForm(acroForm); PDSignatureField signatureField = new PDSignatureField(acroForm); PDAnnotationWidget widget = signatureField.getWidgets().get(0); List<PDField> acroFormFields = acroForm.getFields(); acroForm.setSignaturesExist(true);
@Override public void createAppearanceDictionary(PDFormXObject holderForml, PDSignatureField signatureField) throws IOException { PDAppearanceDictionary appearance = new PDAppearanceDictionary(); appearance.getCOSObject().setDirect(true); PDAppearanceStream appearanceStream = new PDAppearanceStream(holderForml.getCOSObject()); appearance.setNormalAppearance(appearanceStream); signatureField.getWidgets().get(0).setAppearance(appearance); pdfStructure.setAppearanceDictionary(appearance); LOG.info("PDF appearance dictionary has been created"); }
@Override public void createAppearanceDictionary(PDFormXObject holderForml, PDSignatureField signatureField) throws IOException { PDAppearanceDictionary appearance = new PDAppearanceDictionary(); appearance.getCOSObject().setDirect(true); PDAppearanceStream appearanceStream = new PDAppearanceStream(holderForml.getCOSObject()); appearance.setNormalAppearance(appearanceStream); signatureField.getWidgets().get(0).setAppearance(appearance); pdfStructure.setAppearanceDictionary(appearance); LOG.info("PDF appearance dictionary has been created"); }