/** * start building of visible signature * * @throws IOException if the output could not be written */ public void buildSignature() throws IOException { PDFTemplateBuilder builder = new PDVisibleSigBuilder(); PDFTemplateCreator creator = new PDFTemplateCreator(builder); setVisibleSignature(creator.buildPDF(getPdVisibleSignature())); }
/** * Constructor. * * @param document Already created PDDocument of your PDF document. * @param image * @param page The 1-based page number for which the page size should be calculated. */ public PDVisibleSignDesigner(PDDocument document, BufferedImage image, int page) { setImage(image); calculatePageSize(document, page); }
/** * Set visible signature designer for a new signature field. * * @param filename * @param x position of the signature field * @param y position of the signature field * @param zoomPercent increase (positive value) or decrease (negative value) image with x percent. * @param imageStream input stream of an image. * @param page the signature should be placed on * @throws IOException */ public void setVisibleSignDesigner(String filename, int x, int y, int zoomPercent, InputStream imageStream, int page) throws IOException { visibleSignDesigner = new PDVisibleSignDesigner(filename, imageStream, page); visibleSignDesigner.xAxis(x).yAxis(y).zoom(zoomPercent).adjustForRotation(); }
/** * Set visible signature properties for new signature fields. * * @param name * @param location * @param reason * @param preferredSize * @param page * @param visualSignEnabled */ public void setVisibleSignatureProperties(String name, String location, String reason, int preferredSize, int page, boolean visualSignEnabled) { visibleSignatureProperties.signerName(name).signerLocation(location).signatureReason(reason). preferredSize(preferredSize).page(page).visualSignEnabled(visualSignEnabled). setPdVisibleSignature(visibleSignDesigner); }
/** * Set visible signature properties for existing signature fields. * * @param name * @param location * @param reason * @param visualSignEnabled */ public void setVisibleSignatureProperties(String name, String location, String reason, boolean visualSignEnabled) { visibleSignatureProperties.signerName(name).signerLocation(location).signatureReason(reason). visualSignEnabled(visualSignEnabled).setPdVisibleSignature(visibleSignDesigner); }
/** * Constructor. * * @param document Already created PDDocument of your PDF document. * @param imageStream Image as a stream. * @param page The 1-based page number for which the page size should be calculated. * @throws IOException If we can't read, flush, or can't close stream. */ public PDVisibleSignDesigner(PDDocument document, InputStream imageStream, int page) throws IOException { readImageStream(imageStream); calculatePageSize(document, page); }
/** * Constructor. * * @param filename Path of the PDF file * @param imageStream image as a stream * @param page The 1-based page number for which the page size should be calculated. * @throws IOException */ public PDVisibleSignDesigner(String filename, InputStream imageStream, int page) throws IOException { // set visible signature image Input stream readImageStream(imageStream); // calculate height and width of document page calculatePageSizeFromFile(filename, page); }
/** * Constructor. * * @param documentStream Original PDF document as stream * @param imageStream Image as a stream * @param page The 1-based page number for which the page size should be calculated. * @throws IOException */ public PDVisibleSignDesigner(InputStream documentStream, InputStream imageStream, int page) throws IOException { // set visible signature image Input stream readImageStream(imageStream); // calculate height and width of document page calculatePageSizeFromStream(documentStream, page); }
/** * Constructor. * * @param documentStream Original PDF document as stream * @param image * @param page The 1-based page number for which the page size should be calculated. * @throws IOException */ public PDVisibleSignDesigner(InputStream documentStream, BufferedImage image, int page) throws IOException { // set visible signature image setImage(image); // calculate height and width of document page calculatePageSizeFromStream(documentStream, page); }
/** * Constructor. * * @param filename Path of the PDF file * @param image * @param page The 1-based page number for which the page size should be calculated. * @throws IOException */ public PDVisibleSignDesigner(String filename, BufferedImage image, int page) throws IOException { // set visible signature image setImage(image); // calculate height and width of document page calculatePageSizeFromFile(filename, page); }
/** * Reads the visual signature from the given visual signature properties * * @param visSignatureProperties the <code>PDVisibleSigProperties</code> object containing the * visual signature * * @throws IOException when something went wrong during parsing */ public void setVisualSignature(PDVisibleSigProperties visSignatureProperties) throws IOException { setVisualSignature(visSignatureProperties.getVisibleSignature()); }
/** * Constructor usable for signing existing signature fields. * * @param imageStream image as a stream * @throws IOException */ public PDVisibleSignDesigner(InputStream imageStream) throws IOException { // set visible signature image Input stream readImageStream(imageStream); }
/** * * @return template height */ protected float getTemplateHeight() { return getPageHeight(); }
/** * Returns the PDFTemplateStructure object. * */ public PDFTemplateStructure getPdfStructure() { return pdfBuilder.getStructure(); }
/** * Set visible signature designer for an existing signature field. * * @param zoomPercent increase (positive value) or decrease (negative value) image with x percent. * @param imageStream input stream of an image. * @throws IOException */ public void setVisibleSignDesigner(int zoomPercent, InputStream imageStream) throws IOException { visibleSignDesigner = new PDVisibleSignDesigner(imageStream); visibleSignDesigner.zoom(zoomPercent); }
@Override public void createAffineTransform(AffineTransform affineTransform) { pdfStructure.setAffineTransform(affineTransform); LOG.info("Matrix has been added"); }
private void calculatePageSizeFromStream(InputStream documentStream, int page) throws IOException { try (PDDocument document = PDDocument.load(documentStream)) { // calculate height and width of document page calculatePageSize(document, page); } }
/** * Read the image stream of the signature and set height and width. * * @param stream stream of your visible signature image * @throws IOException If we can't read, flush, or close stream of image */ private void readImageStream(InputStream stream) throws IOException { ImageIO.setUseCache(false); setImage(ImageIO.read(stream)); }
@Override public void closeTemplate(PDDocument template) throws IOException { template.close(); pdfStructure.getTemplate().close(); } }