Package org.apache.xmpbox

Examples of org.apache.xmpbox.XMPMetadata


    {
        InputStream is = this.getClass().getResourceAsStream("/validxmp/exif.xmp");

        DomXmpParser builder = new DomXmpParser();
        builder.setStrictParsing(false);
        XMPMetadata rxmp = builder.parse(is);
        ExifSchema schema = (ExifSchema)rxmp.getSchema(ExifSchema.class);
        TextType ss = (TextType)schema.getProperty(ExifSchema.SPECTRAL_SENSITIVITY);
        Assert.assertNotNull(ss);
        Assert.assertEquals("spectral sens value",ss.getValue());
    }
View Full Code Here


    }

    @Test
    public void testGenerate () throws Exception
    {
        XMPMetadata metadata = XMPMetadata.createXMPMetadata();
        TypeMapping tmapping = metadata.getTypeMapping();
        ExifSchema exif = new ExifSchema(metadata);
        metadata.addSchema(exif);
        OECFType oecf = new OECFType(metadata);
        oecf.addProperty(tmapping.createInteger(oecf.getNamespace(), oecf.getPrefix(), OECFType.COLUMNS, 14));
        oecf.setPropertyName(ExifSchema.OECF);
        exif.addProperty(oecf);
View Full Code Here

        catch (IOException e)
        {
            throw new XmpParsingException(ErrorType.Undefined, "Failed to parse", e);
        }
        // document.normalizeDocument();
        XMPMetadata xmp = null;

        // Start reading
        removeComments(document);
        Node node = document.getFirstChild();
View Full Code Here

    public static final String MY_PREFIX = "test";

    @Before
    public void before() throws Exception
    {
        XMPMetadata xmp = XMPMetadata.createXMPMetadata();
        st = new MyStructuredType(xmp, MY_NS, MY_PREFIX);
    }
View Full Code Here

                if (meta != null)
                {
                    DomXmpParser xmpParser = new DomXmpParser();
                    try
                    {
                        XMPMetadata metadata = xmpParser.parse(meta.createInputStream());

                        DublinCoreSchema dc = metadata.getDublinCoreSchema();
                        if (dc != null)
                        {
                            display("Title:", dc.getTitle());
                            display("Description:", dc.getDescription());
                            listString("Creators: ", dc.getCreators());
                            listCalendar("Dates:", dc.getDates());
                            listString("Subjects:", dc.getSubjects());
                        }

                        AdobePDFSchema pdf = metadata.getAdobePDFSchema();
                        if (pdf != null)
                        {
                            display("Keywords:", pdf.getKeywords());
                            display("PDF Version:", pdf.getPDFVersion());
                            display("PDF Producer:", pdf.getProducer());
                        }

                        XMPBasicSchema basic = metadata.getXMPBasicSchema();
                        if (basic != null)
                        {
                            display("Create Date:", basic.getCreateDate());
                            display("Modify Date:", basic.getModifyDate());
                            display("Creator Tool:", basic.getCreatorTool());
View Full Code Here

    }

    @Test
    public void testArrayList() throws Exception
    {
        XMPMetadata meta = XMPMetadata.createXMPMetadata();
        ArrayProperty newSeq = meta.getTypeMapping().createArrayProperty(null, "nsSchem", "seqType", Cardinality.Seq);
        TypeMapping tm = meta.getTypeMapping();
        TextType li1 = tm.createText(null, "rdf", "li", "valeur1");
        TextType li2 = tm.createText(null, "rdf", "li", "valeur2");
        newSeq.getContainer().addProperty(li1);
        newSeq.getContainer().addProperty(li2);
        schem.addProperty(newSeq);
View Full Code Here

    @Test
    public void testRdfAboutFound() throws Exception
    {
        InputStream fis = DomXmpParser.class.getResourceAsStream("/validxmp/emptyli.xml");
        DomXmpParser xdb = new DomXmpParser();
        XMPMetadata meta = xdb.parse(fis);
        List<XMPSchema> schemas = meta.getAllSchemas();
        for (XMPSchema xmpSchema : schemas)
        {
            Assert.assertNotNull(xmpSchema.getAboutAttribute());
        }
    }
View Full Code Here

    @Test
    public void testWihtAttributesAsProperties() throws Exception
    {
        InputStream fis = DomXmpParser.class.getResourceAsStream("/validxmp/attr_as_props.xml");
        DomXmpParser xdb = new DomXmpParser();
        XMPMetadata meta = xdb.parse(fis);

        AdobePDFSchema pdf = meta.getAdobePDFSchema();
        Assert.assertEquals("GPL Ghostscript 8.64", pdf.getProducer());

        DublinCoreSchema dc = meta.getDublinCoreSchema();
        Assert.assertEquals("application/pdf", dc.getFormat());

        XMPBasicSchema basic = meta.getXMPBasicSchema();
        Assert.assertNotNull(basic.getCreateDate());

    }
View Full Code Here

    public void testSpaceTextValues () throws Exception {
        // check values with spaces at start or end
        // in this case, the value should not be trimmed
        InputStream is = DomXmpParser.class.getResourceAsStream("/validxmp/only_space_fields.xmp");
        DomXmpParser xdb = new DomXmpParser();
        XMPMetadata meta = xdb.parse(is);
        // check producer
        Assert.assertEquals(" ", meta.getAdobePDFSchema().getProducer());
        // check creator tool
        Assert.assertEquals("Canon ",meta.getXMPBasicSchema().getCreatorTool());

    }
View Full Code Here

            PDDocument document = ctx.getDocument();

            byte[] tmp = getXpacket(document.getDocument());
            DomXmpParser builder;
            builder = new DomXmpParser();
            XMPMetadata metadata;
            metadata = builder.parse(tmp);
            ctx.setMetadata(metadata);

            // 6.7.5 no deprecated attribute in xpacket processing instruction
            if (metadata.getXpacketBytes() != null)
            {
                addValidationError(ctx, new ValidationError(PreflightConstants.ERROR_METADATA_XPACKET_DEPRECATED,
                        "bytes attribute is forbidden"));
            }
            if (metadata.getXpacketEncoding() != null)
            {
                addValidationError(ctx, new ValidationError(PreflightConstants.ERROR_METADATA_XPACKET_DEPRECATED,
                        "encoding attribute is forbidden"));
            }
View Full Code Here

TOP

Related Classes of org.apache.xmpbox.XMPMetadata

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.