Search in sources :

Example 6 with XMPMetadata

use of org.apache.jempbox.xmp.XMPMetadata in project jabref by JabRef.

the class XMPSchemaBibtexTest method testGetSetPersonList.

@Test
public void testGetSetPersonList() throws IOException {
    XMPMetadata xmp = new XMPMetadata();
    XMPSchemaBibtex bibtex = new XMPSchemaBibtex(xmp);
    bibtex.setPersonList("author", "Tom DeMarco and Kent Beck");
    Element e = bibtex.getElement();
    NodeList l1 = e.getElementsByTagName("bibtex:author");
    Assert.assertEquals(1, l1.getLength());
    NodeList l = e.getElementsByTagName("rdf:li");
    Assert.assertEquals(2, l.getLength());
    Assert.assertEquals("Tom DeMarco", XMLUtil.getStringValue((Element) l.item(0)));
    Assert.assertEquals("Kent Beck", XMLUtil.getStringValue((Element) l.item(1)));
    List<String> authors = bibtex.getPersonList("author");
    Assert.assertEquals(2, authors.size());
    Assert.assertEquals("Tom DeMarco", authors.get(0));
    Assert.assertEquals("Kent Beck", authors.get(1));
}
Also used : XMPMetadata(org.apache.jempbox.xmp.XMPMetadata) Element(org.w3c.dom.Element) NodeList(org.w3c.dom.NodeList) Test(org.junit.Test)

Example 7 with XMPMetadata

use of org.apache.jempbox.xmp.XMPMetadata in project jabref by JabRef.

the class XMPSchemaBibtexTest method testXMPSchemaBibtexXMPMetadata.

@Test
public void testXMPSchemaBibtexXMPMetadata() throws IOException {
    XMPMetadata xmp = new XMPMetadata();
    XMPSchemaBibtex bibtex = new XMPSchemaBibtex(xmp);
    Assert.assertNotNull(bibtex.getElement());
    Assert.assertEquals("rdf:Description", bibtex.getElement().getTagName());
}
Also used : XMPMetadata(org.apache.jempbox.xmp.XMPMetadata) Test(org.junit.Test)

Example 8 with XMPMetadata

use of org.apache.jempbox.xmp.XMPMetadata in project jabref by JabRef.

the class XMPSchemaBibtexTest method testGetSequenceListString.

@Test
public void testGetSequenceListString() throws IOException {
    XMPMetadata xmp = new XMPMetadata();
    XMPSchemaBibtex bibtex = new XMPSchemaBibtex(xmp);
    bibtex.addSequenceValue("author", "Tom DeMarco");
    bibtex.addSequenceValue("author", "Kent Beck");
    {
        List<String> l = bibtex.getSequenceList("author");
        Assert.assertEquals(2, l.size());
        Assert.assertEquals("Tom DeMarco", l.get(0));
        Assert.assertEquals("Kent Beck", l.get(1));
    }
    {
        bibtex.removeSequenceValue("author", "Tom DeMarco");
        List<String> l = bibtex.getSequenceList("author");
        Assert.assertEquals(1, l.size());
        Assert.assertTrue(l.get(0).equals("Kent Beck"));
    }
    {
        // Already removed
        bibtex.removeSequenceValue("author", "Tom DeMarco");
        List<String> l = bibtex.getSequenceList("author");
        Assert.assertEquals(1, l.size());
        Assert.assertTrue(l.get(0).equals("Kent Beck"));
    }
    {
        // Duplicates allowed!
        bibtex.addSequenceValue("author", "Kent Beck");
        List<String> l = bibtex.getSequenceList("author");
        Assert.assertEquals(2, l.size());
        Assert.assertTrue(l.get(0).equals("Kent Beck"));
        Assert.assertTrue(l.get(1).equals("Kent Beck"));
    }
    // Remvoes all
    bibtex.removeSequenceValue("author", "Kent Beck");
    List<String> l = bibtex.getSequenceList("author");
    Assert.assertEquals(0, l.size());
}
Also used : XMPMetadata(org.apache.jempbox.xmp.XMPMetadata) NodeList(org.w3c.dom.NodeList) List(java.util.List) Test(org.junit.Test)

Example 9 with XMPMetadata

use of org.apache.jempbox.xmp.XMPMetadata in project com.revolsys.open by revolsys.

the class SaveAsPdf method save.

public static void save() {
    final Project project = Project.get();
    final String directory = "/Users/paustin/Downloads/";
    final File file = new File(directory, project.getName() + ".pdf");
    try {
        final PDDocument document = new PDDocument();
        final Viewport2D viewport = project.getViewport();
        BoundingBox boundingBox = viewport.getBoundingBox();
        final int width = viewport.getViewWidthPixels();
        final int height = viewport.getViewHeightPixels();
        final int srid = boundingBox.getCoordinateSystemId();
        if (srid == 3857) {
            boundingBox = boundingBox.convert(boundingBox.getGeometryFactory().getGeographicGeometryFactory());
        }
        final PDRectangle pageSize = new PDRectangle(width, height);
        final PDPage page = new PDPage(pageSize);
        try (PdfViewport pdfViewport = new PdfViewport(document, page, project, width, height, boundingBox)) {
            final LayerRenderer<? extends Layer> renderer = project.getRenderer();
            renderer.render(pdfViewport);
        }
        document.addPage(page);
        final PDDocumentCatalog catalog = document.getDocumentCatalog();
        final PDMetadata metadata = new PDMetadata(document);
        catalog.setMetadata(metadata);
        // jempbox version
        final XMPMetadata xmp = new XMPMetadata();
        final XMPSchemaDublinCore xmpSchema = new XMPSchemaDublinCore(xmp);
        xmp.addSchema(xmpSchema);
        xmpSchema.setAbout("");
        metadata.importXMPMetadata(xmp);
        document.save(file);
    } catch (final Throwable e) {
        Logs.error(SaveAsPdf.class, "Unable to create PDF " + file, e);
    }
}
Also used : XMPSchemaDublinCore(org.apache.jempbox.xmp.XMPSchemaDublinCore) PDPage(org.apache.pdfbox.pdmodel.PDPage) PDMetadata(org.apache.pdfbox.pdmodel.common.PDMetadata) PDDocumentCatalog(org.apache.pdfbox.pdmodel.PDDocumentCatalog) Project(com.revolsys.swing.map.layer.Project) Viewport2D(com.revolsys.swing.map.Viewport2D) XMPMetadata(org.apache.jempbox.xmp.XMPMetadata) PDDocument(org.apache.pdfbox.pdmodel.PDDocument) BoundingBox(com.revolsys.geometry.model.BoundingBox) PDRectangle(org.apache.pdfbox.pdmodel.common.PDRectangle) File(java.io.File)

Example 10 with XMPMetadata

use of org.apache.jempbox.xmp.XMPMetadata in project openolat by klemens.

the class PdfDocument method addMetadata.

public void addMetadata(String title, String subject, String author) throws IOException, TransformerException {
    PDDocumentCatalog catalog = document.getDocumentCatalog();
    PDDocumentInformation info = document.getDocumentInformation();
    Calendar date = Calendar.getInstance();
    info.setAuthor(author);
    info.setCreator(author);
    info.setCreationDate(date);
    info.setModificationDate(date);
    info.setTitle(title);
    info.setSubject(subject);
    XMPMetadata metadata = new XMPMetadata();
    XMPSchemaPDF pdfSchema = metadata.addPDFSchema();
    pdfSchema.setProducer("OpenOLAT");
    XMPSchemaBasic basicSchema = metadata.addBasicSchema();
    basicSchema.setModifyDate(date);
    basicSchema.setCreateDate(date);
    basicSchema.setCreatorTool("OpenOLAT");
    basicSchema.setMetadataDate(date);
    XMPSchemaDublinCore dcSchema = metadata.addDublinCoreSchema();
    dcSchema.setTitle(title);
    dcSchema.addCreator(author);
    dcSchema.setDescription(subject);
    PDMetadata metadataStream = new PDMetadata(document);
    metadataStream.importXMPMetadata(metadata);
    catalog.setMetadata(metadataStream);
}
Also used : XMPSchemaDublinCore(org.apache.jempbox.xmp.XMPSchemaDublinCore) XMPMetadata(org.apache.jempbox.xmp.XMPMetadata) XMPSchemaBasic(org.apache.jempbox.xmp.XMPSchemaBasic) Calendar(java.util.Calendar) XMPSchemaPDF(org.apache.jempbox.xmp.XMPSchemaPDF) PDMetadata(org.apache.pdfbox.pdmodel.common.PDMetadata) PDDocumentInformation(org.apache.pdfbox.pdmodel.PDDocumentInformation) PDDocumentCatalog(org.apache.pdfbox.pdmodel.PDDocumentCatalog)

Aggregations

XMPMetadata (org.apache.jempbox.xmp.XMPMetadata)24 Test (org.junit.Test)12 BibEntry (org.jabref.model.entry.BibEntry)11 XMPSchemaDublinCore (org.apache.jempbox.xmp.XMPSchemaDublinCore)10 PDDocumentCatalog (org.apache.pdfbox.pdmodel.PDDocumentCatalog)10 PDMetadata (org.apache.pdfbox.pdmodel.common.PDMetadata)10 PDDocument (org.apache.pdfbox.pdmodel.PDDocument)9 XMPSchema (org.apache.jempbox.xmp.XMPSchema)8 ByteArrayInputStream (java.io.ByteArrayInputStream)5 IOException (java.io.IOException)4 Calendar (java.util.Calendar)4 LinkedList (java.util.LinkedList)4 PDDocumentInformation (org.apache.pdfbox.pdmodel.PDDocumentInformation)4 TypedBibEntry (org.jabref.logic.TypedBibEntry)4 Document (org.w3c.dom.Document)4 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 InputStream (java.io.InputStream)3 List (java.util.List)3 XMPSchemaBasic (org.apache.jempbox.xmp.XMPSchemaBasic)3 ParserResult (org.jabref.logic.importer.ParserResult)3