Package org.apache.xmlgraphics.xmp

Examples of org.apache.xmlgraphics.xmp.Metadata


* Test case for PDF/A metadata handling.
*/
public class PDFAMetadataTestCase extends TestCase {

    public void testInfoUpdate() throws Exception {
        Metadata meta = new Metadata();
        DublinCoreAdapter dc = DublinCoreSchema.getAdapter(meta);
        dc.setTitle("MyTitle");
        dc.setDescription(null, "MySubject");
        dc.addCreator("That's me");
       
View Full Code Here


        Calendar cal2 = Calendar.getInstance(TimeZone.getTimeZone("Europe/Zurich"));
        cal2.set(2007, Calendar.JUNE, 6, 8, 15, 59);
        cal2.set(Calendar.MILLISECOND, 0);
        info.setModDate(cal2.getTime());
       
        Metadata meta = PDFMetadata.createXMPFromPDFDocument(doc);
       
        DublinCoreAdapter dc = DublinCoreSchema.getAdapter(meta);
        assertEquals("MyTitle", dc.getTitle());
        assertEquals("MySubject", dc.getDescription());
        assertEquals(1, dc.getCreators().length);
View Full Code Here

            renderBookmarkItem(bookmarkItem.getSubData(i), pdfOutline);
        }
    }

    private void renderXMPMetadata(XMPMetadata metadata) {
        Metadata docXMP = metadata.getMetadata();
        Metadata fopXMP = PDFMetadata.createXMPFromPDFDocument(pdfDoc);
        //Merge FOP's own metadata into the one from the XSL-FO document
        fopXMP.mergeInto(docXMP);
        XMPBasicAdapter xmpBasic = XMPBasicSchema.getAdapter(docXMP);
        //Metadata was changed so update metadata date
        xmpBasic.setMetadataDate(new java.util.Date());
        PDFMetadata.updateInfoFromMetadata(docXMP, pdfDoc.getInfo());
View Full Code Here

            }
        }
        if (pdfDoc.getRoot().getMetadata() == null) {
            //If at this time no XMP metadata for the overall document has been set, create it
            //from the PDFInfo object.
            Metadata xmp = PDFMetadata.createXMPFromPDFDocument(pdfDoc);
            PDFMetadata pdfMetadata = pdfDoc.getFactory().makeMetadata(
                    xmp, true);
            pdfDoc.getRoot().setMetadata(pdfMetadata);
        }
    }
View Full Code Here

*/
public class ParseMetadata {

    private static void parseMetadata() throws TransformerException, SAXException {
        URL url = ParseMetadata.class.getResource("pdf-example.xmp");
        Metadata meta = XMPParser.parseXMP(url);
        XMPProperty prop;
        prop = meta.getProperty(XMPConstants.DUBLIN_CORE_NAMESPACE, "creator");
        XMPArray array;
        array = prop.getArrayValue();
        for (int i = 0, c = array.getSize(); i < c; i++) {
            System.out.println("Creator: " + array.getValue(i));
        }
        prop = meta.getProperty(XMPConstants.DUBLIN_CORE_NAMESPACE, "title");
        array = prop.getArrayValue();
        System.out.println("Default Title: " + array.getSimpleValue());
        System.out.println("German Title: " + array.getLangValue("de"));
        prop = meta.getProperty(XMPConstants.XMP_BASIC_NAMESPACE, "CreateDate");
        System.out.println("Creation Date: " + prop.getValue());
        prop = meta.getProperty(XMPConstants.XMP_BASIC_NAMESPACE, "CreatorTool");
        System.out.println("Creator Tool: " + prop.getValue());
        prop = meta.getProperty(XMPConstants.ADOBE_PDF_NAMESPACE, "Producer");
        System.out.println("Producer: " + prop.getValue());
        prop = meta.getProperty(XMPConstants.ADOBE_PDF_NAMESPACE, "PDFVersion");
        System.out.println("PDF version: " + prop.getValue());

        DublinCoreAdapter dc = DublinCoreSchema.getAdapter(meta);
        System.out.println("Default title: " + dc.getTitle());
        System.out.println("German title: " + dc.getTitle("de"));
View Full Code Here

*/
public class MetadataFromScratch {

    private static void buildAndPrintMetadata()
                throws TransformerConfigurationException, SAXException {
        Metadata meta = new Metadata();
        DublinCoreAdapter dc = new DublinCoreAdapter(meta);
        dc.setTitle("de", "Der Herr der Ringe");
        dc.setTitle("en", "Lord of the Rings");
        dc.addDate(new Date());
        dc.setFormat("application/pdf");
View Full Code Here

*/
public class MergeMetadata {

    private static void mergeMetadata() throws TransformerException, SAXException {
        URL url = MergeMetadata.class.getResource("pdf-example.xmp");
        Metadata meta1 = XMPParser.parseXMP(url);

        Metadata meta2 = new Metadata();
        DublinCoreAdapter dc = new DublinCoreAdapter(meta2);
        dc.setTitle("de", "Der Herr der Ringe");
        dc.setTitle("en", "Lord of the Rings");
        dc.addCreator("J.R.R. Tolkien"); //Will replace creator from pdf-example.xmp
        dc.addDate(new Date());

        meta2.mergeInto(meta1);

        Metadata meta = meta1;
        XMPProperty prop;
        dc = new DublinCoreAdapter(meta);
        String[] creators = dc.getCreators();
        for (int i = 0, c = creators.length; i < c; i++) {
            System.out.println("Creator: " + creators[i]);
        }
        System.out.println("Title: " + dc.getTitle());
        System.out.println("Title de: " + dc.getTitle("de"));
        System.out.println("Title en: " + dc.getTitle("en"));
        prop = meta.getProperty(XMPConstants.XMP_BASIC_NAMESPACE, "CreateDate");
        System.out.println("Creation Date: " + prop.getValue());
        prop = meta.getProperty(XMPConstants.XMP_BASIC_NAMESPACE, "CreatorTool");
        System.out.println("Creator Tool: " + prop.getValue());
        prop = meta.getProperty(XMPConstants.ADOBE_PDF_NAMESPACE, "Producer");
        System.out.println("Producer: " + prop.getValue());
        prop = meta.getProperty(XMPConstants.ADOBE_PDF_NAMESPACE, "PDFVersion");
        System.out.println("PDF version: " + prop.getValue());

        XMPSerializer.writeXMPPacket(meta, System.out, false);
    }
View Full Code Here

    private static void parseMetadata() throws IOException, TransformerException {
        URL url = ExtractMetadataPacket.class.getResource("xmp-sandbox.fop.trunk.pdf");
        InputStream in = url.openStream();
        try {
            Metadata meta = XMPPacketParser.parse(in);
            if (meta == null) {
                System.err.println("No XMP packet found!");
            } else {
                dumpSomeMetadata(meta);
            }
View Full Code Here

        outputIntent.setInfo(outputIntent.getOutputConditionIdentifier());
        pdfDoc.getRoot().addOutputIntent(outputIntent);
    }

    public void renderXMPMetadata(XMPMetadata metadata) {
        Metadata docXMP = metadata.getMetadata();
        Metadata fopXMP = PDFMetadata.createXMPFromPDFDocument(pdfDoc);
        //Merge FOP's own metadata into the one from the XSL-FO document
        fopXMP.mergeInto(docXMP);
        XMPBasicAdapter xmpBasic = XMPBasicSchema.getAdapter(docXMP);
        //Metadata was changed so update metadata date
        xmpBasic.setMetadataDate(new java.util.Date());
        PDFMetadata.updateInfoFromMetadata(docXMP, pdfDoc.getInfo());
View Full Code Here

    public void generateDefaultXMPMetadata() {
        if (pdfDoc.getRoot().getMetadata() == null) {
            //If at this time no XMP metadata for the overall document has been set, create it
            //from the PDFInfo object.
            Metadata xmp = PDFMetadata.createXMPFromPDFDocument(pdfDoc);
            PDFMetadata pdfMetadata = pdfDoc.getFactory().makeMetadata(
                    xmp, true);
            pdfDoc.getRoot().setMetadata(pdfMetadata);
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.xmlgraphics.xmp.Metadata

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.