Example usage for com.itextpdf.text.pdf PdfCopy addDocument

List of usage examples for com.itextpdf.text.pdf PdfCopy addDocument

Introduction

In this page you can find the example usage for com.itextpdf.text.pdf PdfCopy addDocument.

Prototype

public void addDocument(PdfReader reader) throws DocumentException, IOException 

Source Link

Usage

From source file:Logic.AddCover1.java

/**
 * Manipulates a PDF file src with the file dest as result
 * @param src the original PDF/*  w w  w.  j  a v  a 2 s  .c  o  m*/
 * @param dest the resulting PDF
 * @throws IOException
 * @throws DocumentException
 */
public void manipulatePdf(String src, String dest, String cov) throws IOException, DocumentException {
    PdfReader cover = new PdfReader(cov);
    PdfReader reader = new PdfReader(src);
    Document document = new Document();
    PdfCopy copy = new PdfCopy(document, new FileOutputStream(dest));
    document.open();
    copy.addDocument(cover);
    copy.addDocument(reader);

    document.close();
    cover.close();
    reader.close();
}