/** * Use this method to add a file attachment at the document level. * @param fs the file specification * @throws IOException if the file attachment could not be added to the document */ public void addFileAttachment(final PdfFileSpecification fs) throws IOException { addFileAttachment(null, fs); }
/** * Use this method to add a file attachment at the document level. * @param fs the file specification * @throws IOException if the file attachment could not be added to the document */ public void addFileAttachment(final PdfFileSpecification fs) throws IOException { addFileAttachment(null, fs); }
/** * Use this method to add a file attachment at the document level. * @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, file, fileDisplay, fileStore)); }
/** * Use this method to add a file attachment at the document level. * @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, file, fileDisplay, fileStore)); }
public void addAttachments( String src, String dest, String[] attachments) throws IOException, DocumentException { PdfReader reader = new PdfReader(src); PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(dest)); for (int i = 0; i < attachments.length; i++) { addAttachment(stamper.getWriter(), new File(attachments[i])); } stamper.close(); } protected void addAttachment(PdfWriter writer, File src) throws IOException { PdfFileSpecification fs = PdfFileSpecification.fileEmbedded(writer, src.getAbsolutePath(), src.getName(), null); writer.addFileAttachment(src.getName().substring(0, src.getName().indexOf('.')), fs); }