Copying PDF File and Adding MetaData : PDF Metadata « PDF RTF « Java






Copying PDF File and Adding MetaData

import java.io.FileOutputStream;
import java.util.HashMap;

import com.lowagie.text.pdf.PdfReader;
import com.lowagie.text.pdf.PdfStamper;

public class CopyPDFFileAndAddMetaData {
  public static void main(String[] args) {
    try {
      PdfReader reader = new PdfReader("YourOwnPDF.pdf");

      PdfStamper stamp = new PdfStamper(reader,
          new FileOutputStream("NewPDFFileFromPdfStamper.pdf"));

      HashMap<String, String> moreInfo = new HashMap<String, String>();
      moreInfo.put("Author", "YourName");
      moreInfo.put("Title", "YourTitle");
      moreInfo.put("Subject", "YourSubject");
      stamp.setMoreInfo(moreInfo);
      stamp.close();

    } catch (Exception de) {
      de.printStackTrace();
    }
  }
}
           
       








itext.zip( 1,748 k)

Related examples in the same category

1.PDF Meta data: Subject, Keywords, Creator, Author, CreationDate, Producer
2.PDF Meta data: TitlePDF Meta data: Title