Examples of XMPSchemaDublinCore


Examples of org.apache.jempbox.xmp.XMPSchemaDublinCore

                document = PDDocument.load( args[0] );
                PDDocumentCatalog catalog = document.getDocumentCatalog();
                PDMetadata meta = catalog.getMetadata();
                XMPMetadata metadata = meta.exportXMPMetadata();

                XMPSchemaDublinCore dc = metadata.getDublinCoreSchema();
                if (dc != null)
                {
                    display("Title:", dc.getTitle());
                    display("Description:", dc.getDescription());
                    list("Creators: ", dc.getCreators());
                    list("Dates:", dc.getDates());
                }

                XMPSchemaPDF pdf = metadata.getPDFSchema();
                if (pdf != null)
                {
View Full Code Here

Examples of org.apache.jempbox.xmp.XMPSchemaDublinCore

        Reader decoded = new InputStreamReader(
                new ByteArrayInputStream(xmpraw.toByteArray()),
                DEFAULT_XMP_CHARSET);
        try {
            XMPMetadata xmp = XMPMetadata.load(new InputSource(decoded));
            XMPSchemaDublinCore dc = xmp.getDublinCoreSchema();
            if (dc != null) {
                if (dc.getTitle() != null) {
                    metadata.set(TikaCoreProperties.TITLE, dc.getTitle());
                }
                if (dc.getDescription() != null) {
                    metadata.set(TikaCoreProperties.DESCRIPTION, dc.getDescription());
                }
                if (dc.getCreators() != null && dc.getCreators().size() > 0) {
                    metadata.set(TikaCoreProperties.CREATOR, joinCreators(dc.getCreators()));
                }
                if (dc.getSubjects() != null && dc.getSubjects().size() > 0) {
                    for (String keyword : dc.getSubjects()) {
                        metadata.add(TikaCoreProperties.KEYWORDS, keyword);
                    }
                    // TODO should we set KEYWORDS too?
                    // All tested photo managers set the same in Iptc.Application2.Keywords and Xmp.dc.subject
                }
View Full Code Here

Examples of org.apache.jempbox.xmp.XMPSchemaDublinCore

    private void extractMetadata(PDDocument document, Metadata metadata)
            throws TikaException {

        org.apache.jempbox.xmp.XMPMetadata xmp = null;
        XMPSchemaDublinCore dcSchema = null;
        try{
            if (document.getDocumentCatalog().getMetadata() != null) {
                xmp = document.getDocumentCatalog().getMetadata().exportXMPMetadata();
            }
            if (xmp != null) {
View Full Code Here

Examples of org.apache.jempbox.xmp.XMPSchemaDublinCore

                  PDMetadata meta = catalog.getMetadata();
                  if (meta != null)
                  {
                     XMPMetadata metadata = meta.exportXMPMetadata();

                     XMPSchemaDublinCore dc = metadata.getDublinCoreSchema();
                     if (dc != null)
                     {
                        try
                        {
                           if (dc.getTitle() != null)
                              props.put(DCMetaData.TITLE, fixEncoding(dc.getTitle()));
                        }
                        catch (Exception e)
                        {
                           LOG.warn("getTitle failed: " + e.getMessage());
                        }
                        try
                        {
                           if (dc.getDescription() != null)
                              props.put(DCMetaData.DESCRIPTION, fixEncoding(dc.getDescription()));
                        }
                        catch (Exception e)
                        {
                           LOG.warn("getSubject failed: " + e.getMessage());
                        }

                        try
                        {
                           if (dc.getCreators() != null)
                           {
                              for (String creator : dc.getCreators())
                              {
                                 props.put(DCMetaData.CREATOR, fixEncoding(creator));
                              }
                           }
                        }
                        catch (Exception e)
                        {
                           LOG.warn("getCreator failed: " + e.getMessage());
                        }

                        try
                        {
                           if (dc.getDates() != null)
                           {
                              for (Calendar date : dc.getDates())
                              {
                                 props.put(DCMetaData.DATE, date);
                              }
                           }
                        }
View Full Code Here

Examples of org.jempbox.xmp.XMPSchemaDublinCore

        assertEquals(1, schemas.size());

        schemas = meta
            .getSchemasByNamespaceURI(XMPSchemaDublinCore.NAMESPACE);
        assertEquals(1, schemas.size());
        XMPSchemaDublinCore dc = (XMPSchemaDublinCore) schemas.get(0);
        assertEquals("application/pdf", dc.getFormat());

        schemas = meta
            .getSchemasByNamespaceURI(XMPSchemaBasic.NAMESPACE);
        assertEquals(1, schemas.size());
        XMPSchemaBasic bs = (XMPSchemaBasic) schemas.get(0);
        assertEquals("Acrobat PDFMaker 7.0.7", bs.getCreatorTool());

        Calendar c = Calendar.getInstance();
        c.clear();
        c.set(Calendar.YEAR, 2006);
        c.set(Calendar.MONTH, Calendar.AUGUST);
        c.set(Calendar.DATE, 7);
        c.set(Calendar.HOUR, 14);
        c.set(Calendar.MINUTE, 44);
        c.set(Calendar.SECOND, 24);
        c.setTimeZone(TimeZone.getTimeZone("GMT+2"));

        Calendar other = bs.getCreateDate();

        assertEquals(c.get(Calendar.YEAR), other.get(Calendar.YEAR));
        assertEquals(c.get(Calendar.MONTH), other.get(Calendar.MONTH));
        assertEquals(c.get(Calendar.DATE), other.get(Calendar.DATE));
        assertEquals(c.get(Calendar.HOUR), other.get(Calendar.HOUR));
        assertEquals(c.get(Calendar.MINUTE), other.get(Calendar.MINUTE));
        assertEquals(c.get(Calendar.SECOND), other.get(Calendar.SECOND));
        assertTrue(c.getTimeZone().hasSameRules(other.getTimeZone()));

        schemas = meta
            .getSchemasByNamespaceURI(XMPSchemaMediaManagement.NAMESPACE);
        assertEquals(1, schemas.size());
        XMPSchemaMediaManagement mm = (XMPSchemaMediaManagement) schemas
            .get(0);
        assertEquals("17", mm.getSequenceList("xapMM:VersionID").get(0));

      } finally {
        if (document != null) {
          document.close();
        }
      }
    }

    { // Now alter the Bibtex entry, write it and do all the checks again
      BibtexEntry toSet = t1BibtexEntry();
      toSet.setField("author", "Pokemon!");

      XMPUtil.writeXMP(pdfFile, toSet, null);

      List l = XMPUtil.readXMP(pdfFile.getAbsoluteFile());
      assertEquals(1, l.size());
      BibtexEntry e = (BibtexEntry) l.get(0);

      assertEquals(toSet, e);

      // This is what we really want to test: Is the rest of the
      // descriptions still there?

      PDDocument document = null;
      try {
        document = PDDocument.load(pdfFile.getAbsoluteFile());
        if (document.isEncrypted()) {
          throw new IOException(
              "Error: Cannot read metadata from encrypted document.");
        }
        PDDocumentCatalog catalog = document.getDocumentCatalog();
        PDMetadata metaRaw = catalog.getMetadata();

        XMPMetadata meta;
        if (metaRaw != null) {
          meta = new XMPMetadata(XMLUtil.parse(metaRaw
              .createInputStream()));
        } else {
          meta = new XMPMetadata();
        }
        meta.addXMLNSMapping(XMPSchemaBibtex.NAMESPACE,
            XMPSchemaBibtex.class);

        List schemas = meta.getSchemas();

        assertEquals(4, schemas.size());

        schemas = meta
            .getSchemasByNamespaceURI(XMPSchemaBibtex.NAMESPACE);
        assertEquals(1, schemas.size());

        schemas = meta
            .getSchemasByNamespaceURI(XMPSchemaDublinCore.NAMESPACE);
        assertEquals(1, schemas.size());
        XMPSchemaDublinCore dc = (XMPSchemaDublinCore) schemas.get(0);
        assertEquals("application/pdf", dc.getFormat());

        schemas = meta
            .getSchemasByNamespaceURI(XMPSchemaBasic.NAMESPACE);
        assertEquals(1, schemas.size());
        XMPSchemaBasic bs = (XMPSchemaBasic) schemas.get(0);
View Full Code Here

Examples of org.jempbox.xmp.XMPSchemaDublinCore

      // Check Dublin Core
      List<XMPSchema> schemas = meta
          .getSchemasByNamespaceURI("http://purl.org/dc/elements/1.1/");
      assertEquals(1, schemas.size());

      XMPSchemaDublinCore dcSchema = (XMPSchemaDublinCore) schemas
          .iterator().next();
      assertNotNull(dcSchema);

      assertEquals("Hypersonic ultra-sound", dcSchema.getTitle());
      assertEquals("1982-07", dcSchema.getSequenceList("dc:date").get(0));
      assertEquals("Kelly Clarkson", dcSchema.getCreators().get(0));
      assertEquals("Ozzy Osbourne", dcSchema.getCreators().get(1));
      assertEquals("Huey Duck", dcSchema.getContributors().get(0));
      assertEquals("Dewey Duck", dcSchema.getContributors().get(1));
      assertEquals("Louie Duck", dcSchema.getContributors().get(2));
      assertEquals("Inproceedings", dcSchema.getTypes().get(0));
      assertEquals("bibtex/bibtexkey/Clarkson06", dcSchema
          .getRelationships().get(0));
      assertEquals("peanut", dcSchema.getSubjects().get(0));
      assertEquals("butter", dcSchema.getSubjects().get(1));
      assertEquals("jelly", dcSchema.getSubjects().get(2));

      /**
       * Bibtexkey, Journal, pdf, booktitle
       */
      assertEquals(4, dcSchema.getRelationships().size());

      assertEquals(t3BibtexEntry(), XMPUtil
          .getBibtexEntryFromDublinCore(dcSchema));

    } finally {
View Full Code Here

Examples of org.jempbox.xmp.XMPSchemaDublinCore

      List<XMPSchema> schemas = meta
          .getSchemasByNamespaceURI("http://purl.org/dc/elements/1.1/");

      assertEquals(1, schemas.size());

      XMPSchemaDublinCore dcSchema = (XMPSchemaDublinCore) schemas
          .iterator().next();
      assertNotNull(dcSchema);

      assertEquals("Hypersonic ultra-sound", dcSchema.getTitle());
      assertEquals("1982-07", dcSchema.getSequenceList("dc:date").get(0));
      assertEquals("Kelly Clarkson", dcSchema.getCreators().get(0));
      assertEquals("Ozzy Osbourne", dcSchema.getCreators().get(1));
      assertEquals("Huey Duck", dcSchema.getContributors().get(0));
      assertEquals("Dewey Duck", dcSchema.getContributors().get(1));
      assertEquals("Louie Duck", dcSchema.getContributors().get(2));
      assertEquals("Inproceedings", dcSchema.getTypes().get(0));
      assertEquals("bibtex/bibtexkey/Clarkson06", dcSchema
          .getRelationships().get(0));
      assertEquals("peanut", dcSchema.getSubjects().get(0));
      assertEquals("butter", dcSchema.getSubjects().get(1));
      assertEquals("jelly", dcSchema.getSubjects().get(2));

      /**
       * Bibtexkey, Journal, pdf, booktitle
       */
      assertEquals(4, dcSchema.getRelationships().size());

      assertEquals(t3BibtexEntry(), XMPUtil
          .getBibtexEntryFromDublinCore(dcSchema));

    } finally {
View Full Code Here

Examples of org.jempbox.xmp.XMPSchemaDublinCore

        List<XMPSchema> schemas = meta
            .getSchemasByNamespaceURI("http://purl.org/dc/elements/1.1/");

        assertEquals(1, schemas.size());

        XMPSchemaDublinCore dcSchema = (XMPSchemaDublinCore) schemas
            .iterator().next();
        assertNotNull(dcSchema);

        assertEquals("David Patterson", dcSchema.getCreators().get(0));
        assertEquals("Arvind", dcSchema.getCreators().get(1));
        assertEquals("Krste Asanov\\'\\i{}c", dcSchema.getCreators()
            .get(2));

        b = XMPUtil.getBibtexEntryFromDublinCore(dcSchema);
        assertEquals(originalAuthors, AuthorList.getAuthorList(b
            .getField("author").toString()));
View Full Code Here

Examples of org.jempbox.xmp.XMPSchemaDublinCore

              if (result.size() == 0) {
                schemas = meta
                    .getSchemasByNamespaceURI(XMPSchemaDublinCore.NAMESPACE);
                it = schemas.iterator();
                while (it.hasNext()) {
                  XMPSchemaDublinCore dc = (XMPSchemaDublinCore) it.next();
       
                  BibtexEntry entry = getBibtexEntryFromDublinCore(dc);
       
                  if (entry != null)
                    result.add(entry);
View Full Code Here

Examples of org.jempbox.xmp.XMPSchemaDublinCore

      XMPSchema bib = (XMPSchema) it.next();
      bib.getElement().getParentNode().removeChild(bib.getElement());
    }

    for (BibtexEntry entry : entries) {
      XMPSchemaDublinCore dcSchema = new XMPSchemaDublinCore(meta);
      writeToDCSchema(dcSchema, entry, null);
      meta.addSchema(dcSchema);
    }

    // Save to stream and then input that stream to the PDF
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.