Examples of XMPMetadata


Examples of org.jempbox.xmp.XMPMetadata

      entries = database.resolveForStrings(entries, false);

    PDDocumentCatalog catalog = document.getDocumentCatalog();
    PDMetadata metaRaw = catalog.getMetadata();

    XMPMetadata meta;
    if (metaRaw != null) {
      meta = new XMPMetadata(XMLUtil.parse(metaRaw.createInputStream()));
    } else {
      meta = new XMPMetadata();
    }

    // Remove all current Dublin-Core schemas
    List schemas = meta
        .getSchemasByNamespaceURI(XMPSchemaDublinCore.NAMESPACE);
    Iterator it = schemas.iterator();
    while (it.hasNext()) {
      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
    ByteArrayOutputStream os = new ByteArrayOutputStream();
    meta.save(os);
    ByteArrayInputStream is = new ByteArrayInputStream(os.toByteArray());
    PDMetadata metadataStream = new PDMetadata(document, is, false);
    catalog.setMetadata(metadataStream);
  }
View Full Code Here

Examples of org.jempbox.xmp.XMPMetadata

      }

      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);

      // Remove all current Bibtex-schemas
      List schemas = meta
          .getSchemasByNamespaceURI(XMPSchemaBibtex.NAMESPACE);
      Iterator it = schemas.iterator();
      while (it.hasNext()) {
        XMPSchemaBibtex bib = (XMPSchemaBibtex) it.next();
        bib.getElement().getParentNode().removeChild(bib.getElement());
      }

      it = bibtexEntries.iterator();
      while (it.hasNext()) {
        BibtexEntry e = (BibtexEntry) it.next();
        XMPSchemaBibtex bibtex = new XMPSchemaBibtex(meta);
        meta.addSchema(bibtex);
        bibtex.setBibtexEntry(e, null);
      }

      // Save to stream and then input that stream to the PDF
      ByteArrayOutputStream os = new ByteArrayOutputStream();
      meta.save(os);
      ByteArrayInputStream is = new ByteArrayInputStream(os.toByteArray());
      PDMetadata metadataStream = new PDMetadata(document, is, false);
      catalog.setMetadata(metadataStream);

      // Save
View Full Code Here

Examples of org.jempbox.xmp.XMPMetadata

      break;
    }
    case 2: {
      if (args[0].equals("-x") && args[1].endsWith(".pdf")) {
        // Read from pdf and write as BibTex
        XMPMetadata meta = XMPUtil.readRawXMP(new File(args[1]));

        if (meta == null) {
          System.err
              .println("The given pdf does not contain any XMP-metadata.");
        } else {
          XMLUtil.save(meta.getXMPDocument(), System.out, "UTF-8");
        }
        break;
      }

      if (args[0].endsWith(".bib") && args[1].endsWith(".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.