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));
}
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());
}
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());
}
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);
}
}
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);
}
Aggregations