Example usage for com.itextpdf.text.pdf PdfFileSpecification fileEmbedded

List of usage examples for com.itextpdf.text.pdf PdfFileSpecification fileEmbedded

Introduction

In this page you can find the example usage for com.itextpdf.text.pdf PdfFileSpecification fileEmbedded.

Prototype

public static PdfFileSpecification fileEmbedded(PdfWriter writer, String filePath, String fileDisplay,
        byte fileStore[], String mimeType, PdfDictionary fileParameter, int compressionLevel)
        throws IOException 

Source Link

Document

Creates a file specification with the file embedded.

Usage

From source file:io.konik.carriage.itext.ITextInvoiceAppender.java

License:Open Source License

private static void attachFile(byte[] attachmentFile, PdfAStamper stamper) throws IOException {
    PdfDictionary embeddedFileParams = new PdfDictionary();
    embeddedFileParams.put(PARAMS, new PdfName(ZF_FILE_NAME));
    embeddedFileParams.put(MODDATE, new PdfDate());

    PdfFileSpecification fs = PdfFileSpecification.fileEmbedded(stamper.getWriter(), null, ZF_FILE_NAME,
            attachmentFile, MIME_TYPE, embeddedFileParams, 0);
    fs.put(AFRELATIONSHIP, Alternative);
    stamper.addFileAttachment(ZF_FILE_NAME, fs);

    PdfArray array = new PdfArray();
    array.add(fs.getReference());/*from   w  w w.  j a va2 s  .c  o  m*/
    stamper.getWriter().getExtraCatalog().put(new PdfName("AF"), array);
}