/** Adds a file attachment at the document level. Existing attachments will be kept. * @param description the file description * @param fileStore an array with the file. If it's <CODE>null</CODE> * the file will be read from the disk * @param file the path to the file. It will only be used if * <CODE>fileStore</CODE> is not <CODE>null</CODE> * @param fileDisplay the actual file name stored in the pdf * @throws IOException on error */ public void addFileAttachment(String description, byte fileStore[], String file, String fileDisplay) throws IOException { addFileAttachment(description, PdfFileSpecification.fileEmbedded(stamper, file, fileDisplay, fileStore)); }
/** Adds a file attachment at the document level. Existing attachments will be kept. * @param description the file description * @param fileStore an array with the file. If it's <CODE>null</CODE> * the file will be read from the disk * @param file the path to the file. It will only be used if * <CODE>fileStore</CODE> is not <CODE>null</CODE> * @param fileDisplay the actual file name stored in the pdf * @throws IOException on error */ public void addFileAttachment(String description, byte[] fileStore, String file, String fileDisplay) throws IOException { addFileAttachment(description, PdfFileSpecification.fileEmbedded(stamper, file, fileDisplay, fileStore)); }
/** Adds a file attachment at the document level. Existing attachments will be kept. * @param description the file description * @param fileStore an array with the file. If it's <CODE>null</CODE> * the file will be read from the disk * @param file the path to the file. It will only be used if * <CODE>fileStore</CODE> is not <CODE>null</CODE> * @param fileDisplay the actual file name stored in the pdf * @throws IOException on error */ public void addFileAttachment(final String description, final byte fileStore[], final String file, final String fileDisplay) throws IOException { addFileAttachment(description, PdfFileSpecification.fileEmbedded(this.stamper, file, fileDisplay, fileStore)); }
public static final String[] ATTACHMENTS = { "hello", "world", "what", "is", "up" }; public void manipulatePdf(String src, String dest) throws IOException, DocumentException { PdfReader reader = new PdfReader(src); PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(dest)); for (String s : ATTACHMENTS) { PdfFileSpecification fs = PdfFileSpecification.fileEmbedded( stamper.getWriter(), null, String.format("%s.txt", s), String.format("Some test: %s", s).getBytes()); stamper.addFileAttachment(String.format("Content: %s", s), fs); } stamper.close(); }
public void manipulatePdf(String src, String dest) throws IOException, DocumentException { PdfReader reader = new PdfReader(src); PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(dest)); PdfFileSpecification fs = PdfFileSpecification.fileEmbedded( stamper.getWriter(), null, "test.txt", "Some test".getBytes()); stamper.addFileAttachment("some test file", fs); stamper.close(); }
public void manipulatePdf(String src, String dest) throws IOException, DocumentException { PdfReader reader = new PdfReader(src); PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(dest)); PdfFileSpecification fs = PdfFileSpecification.fileEmbedded( stamper.getWriter(), null, "test.txt", "Some test".getBytes()); stamper.addFileAttachment("some test file", fs); stamper.close(); }