Custom Metadata entry

Tags: metadatainfo dictionarycustom propertyiText 5
Files: 
/**
 * This example is written by Bruno Lowagie in answer to the following question:
 * http://stackoverflow.com/questions/26726485/itext-add-delete-retrieve-information-in-custom-property
 */
package sandbox.objects;
 
import com.itextpdf.text.Document;
import com.itextpdf.text.DocumentException;
import com.itextpdf.text.Header;
import com.itextpdf.text.Paragraph;
import com.itextpdf.text.pdf.PdfWriter;
 
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import sandbox.WrapToTest;
 
@WrapToTest
public class CustomMetaEntry {
 
    public static final String DEST = "results/objects/custom_meta.pdf";
 
    public static void main(String[] args) throws IOException,
            DocumentException {
        File file = new File(DEST);
        file.getParentFile().mkdirs();
        new CustomMetaEntry().createPdf(DEST);
    }
 
    public void createPdf(String dest) throws IOException, DocumentException {
        Document document = new Document();
        PdfWriter.getInstance(document, new FileOutputStream(dest));
        document.addTitle("Some example");
        document.add(new Header("Test", "test"));
        document.open();
        Paragraph p = new Paragraph("Hello World");
        document.add(p);
        document.close();
    }
 
}
File nameRaw URLUpdated
CustomMetaEntry.javaCustomMetaEntry.java2015-10-25 1:23 am
Results: 
File nameRaw URLUpdated
cmp_custom_meta.pdfcmp_custom_meta.pdf2015-10-25 1:24 am