List of usage examples for com.itextpdf.text.xml.xmp XmpWriter XmpWriter
public XmpWriter(OutputStream os) throws IOException
From source file:br.unifor.mia.xmpsemantico.xmp.MetadataXmp.java
License:GNU General Public License
/** * create PDF document//from www . ja v a2 s.c o m * @param filename of new archive PDF * @throws DocumentException * @throws IOException */ public void createPdf() throws IOException { Document document = new Document(); PdfWriter writer = null; try { writer = PdfWriter.getInstance(document, new FileOutputStream(pathPdf)); ByteArrayOutputStream os = new ByteArrayOutputStream(); XmpWriter xmp = new XmpWriter(os); MiaSchema miaSchema = new MiaSchema(); miaSchema.addDescription(this.descricao); miaSchema.setProperty(MiaSchema.DISCIPLINA, this.disciplina); miaSchema.setProperty(MiaSchema.PROFESSOR, this.professor); miaSchema.setProperty(MiaSchema.CARGA_HORARIA, this.cargaHoraria); miaSchema.setProperty(MiaSchema.CREDITOS, this.creditos); xmp.addRdfDescription(miaSchema); xmp.close(); writer.setXmpMetadata(os.toByteArray()); document.open(); document.addAuthor("docsemantico"); Paragraph paragraph = new Paragraph("Quick brown "); Anchor foxRefence = new Anchor("fox"); foxRefence.setReference("#fox"); paragraph.add(foxRefence); paragraph.add(" jumps over the lazy dog."); document.add(paragraph); document.newPage(); Anchor foxName = new Anchor("This is the FOX"); foxName.setName("fox"); document.add(foxName); document.add(new Paragraph(this.texto)); document.close(); } catch (DocumentException e) { e.printStackTrace(); } //teste commit }
From source file:org.crossref.pdfmark.MarkBuilder.java
License:Open Source License
@Override public void onComplete(String requestedDoi) { ByteArrayOutputStream bout = new ByteArrayOutputStream(); SchemaSet schemaSet = new SchemaSet(); try {// ww w. j a v a 2 s . co m Work work = null; switch (unixref.getType()) { case JOURNAL: work = unixref.getJournal(); break; case BOOK: work = unixref.getBook(); break; default: break; } if (work != null) { XmpWriter writer = new XmpWriter(bout); work.writeXmp(schemaSet); if (publisher != null) { if (generateCopyright) { String cp = getCopyright(work); Work.addToSchema(schemaSet.getDc(), DublinCoreSchema.RIGHTS, cp); Work.addToSchema(schemaSet.getPrism(), Prism21Schema.COPYRIGHT, cp); } Work.addToSchema(schemaSet.getDc(), DublinCoreSchema.PUBLISHER, publisher.getName()); } Work.addToSchema(schemaSet.getPrism(), Prism21Schema.RIGHTS_AGENT, rightsAgent); writer.addRdfDescription(schemaSet.getDc()); writer.addRdfDescription(schemaSet.getPrism()); writer.close(); } xmpData = bout.toByteArray(); } catch (IOException e) { onFailure(requestedDoi, MetadataGrabber.CLIENT_EXCEPTION_CODE, e.toString()); } catch (XPathExpressionException e) { onFailure(requestedDoi, MetadataGrabber.CLIENT_EXCEPTION_CODE, e.toString()); } }
From source file:org.crossref.pdfmark.XmpUtils.java
License:Open Source License
/** * Combines the RDF description blocks from left and right. Those from * right will overwrite those from left in the case that left and right * contain description blocks with the same namespace. *//*from w ww .j a v a 2s. c om*/ public static byte[] mergeXmp(byte[] left, byte[] right) throws XmpException { if (left == null || left.length == 0) { ByteArrayOutputStream bout = new ByteArrayOutputStream(); try { XmpWriter writer = new XmpWriter(bout); for (XmpSchema schema : parseSchemata(right)) { writer.addRdfDescription(schema); } writer.close(); } catch (IOException e) { throw new XmpException(e); } return bout.toByteArray(); } if (right == null || right.length == 0) { ByteArrayOutputStream bout = new ByteArrayOutputStream(); try { XmpWriter writer = new XmpWriter(bout); for (XmpSchema schema : parseSchemata(left)) { writer.addRdfDescription(schema); } writer.close(); } catch (IOException e) { throw new XmpException(e); } return bout.toByteArray(); } XmpSchema[] leftSchemata = parseSchemata(left); XmpSchema[] rightSchemata = parseSchemata(right); ByteArrayOutputStream bout = new ByteArrayOutputStream(); String[] noWriteList = new String[rightSchemata.length]; for (int i = 0; i < noWriteList.length; i++) { noWriteList[i] = rightSchemata[i].getXmlns(); } try { XmpWriter writer = new XmpWriter(bout); for (XmpSchema schema : leftSchemata) { boolean found = false; for (String checkAgainst : noWriteList) { if (schema.getXmlns().equals(checkAgainst)) { found = true; break; } } if (!found) { writer.addRdfDescription(schema); } } for (XmpSchema schema : rightSchemata) { writer.addRdfDescription(schema); } writer.close(); return bout.toByteArray(); } catch (IOException e) { throw new XmpException(e); } }