Example usage for com.lowagie.text.xml.xmp XmpSchema setProperty

List of usage examples for com.lowagie.text.xml.xmp XmpSchema setProperty

Introduction

In this page you can find the example usage for com.lowagie.text.xml.xmp XmpSchema setProperty.

Prototype

public Object setProperty(String key, LangAlt value) 

Source Link

Usage

From source file:de.unigoettingen.sub.commons.contentlib.pdflib.PDFManager.java

License:Apache License

/**
 * Write xmp metadata.//from  w  ww  . j ava  2 s  .  com
 * 
 * @param inWriter the in writer
 */
private void writeXMPMetadata(PdfWriter inWriter) {
    ByteArrayOutputStream os = new ByteArrayOutputStream();

    try {
        XmpWriter xmp = new XmpWriter(os);
        XmpSchema dc = new DublinCoreSchema();

        // set DublinCore metadata
        if (this.subject != null) {
            dc.setProperty(DublinCoreSchema.SUBJECT, this.subject);
        }
        if (this.title != null) {
            dc.setProperty(DublinCoreSchema.TITLE, this.title);
        }
        if (this.author != null) {
            dc.setProperty(DublinCoreSchema.CREATOR, this.author);
        }

        // add the DublinCore Simple Metadata to the RDF container

        xmp.addRdfDescription(dc);

        PdfSchema pdf = new PdfSchema();
        // set keywords
        pdf.setProperty(PdfSchema.KEYWORDS, "Hello World, XMP, Metadata");

        // set the version; must be 1.4 for PDF/A
        pdf.setProperty(PdfSchema.VERSION, "1.4");
        xmp.addRdfDescription(pdf);

        xmp.close();
    } catch (IOException e) {
        LOGGER.error("error occured while writing xmp metadata", e);
    }
    inWriter.setXmpMetadata(os.toByteArray());
}