List of usage examples for com.lowagie.text.pdf PdfName CREATOR
PdfName CREATOR
To view the source code for com.lowagie.text.pdf PdfName CREATOR.
Click Source Link
From source file:net.sf.jasperreports.engine.export.PdfXmpCreator.java
License:Open Source License
byte[] createXmpMetadata() { try {/*from w ww . ja v a 2 s . c o m*/ XMPMeta xmp = XMPMetaFactory.create(); xmp.setObjectName(""); xmp.setProperty(XMPConst.NS_DC, DublinCoreSchema.FORMAT, FORMAT_PDF); xmp.setProperty(XMPConst.NS_PDF, PDF_PRODUCER, Document.getVersion()); if (pdfWriter.getPDFXConformance() == PdfWriter.PDFA1A) { xmp.setProperty(XMPConst.NS_PDFA_ID, PDFA_PART, PDFA_PART_1); xmp.setProperty(XMPConst.NS_PDFA_ID, PDFA_CONFORMANCE, PDFA_CONFORMANCE_A); } else if (pdfWriter.getPDFXConformance() == PdfWriter.PDFA1B) { xmp.setProperty(XMPConst.NS_PDFA_ID, PDFA_PART, PDFA_PART_1); xmp.setProperty(XMPConst.NS_PDFA_ID, PDFA_CONFORMANCE, PDFA_CONFORMANCE_B); } xmp.setProperty(XMPConst.NS_XMP, XMP_CREATE_DATE, ((PdfDate) info.get(PdfName.CREATIONDATE)).getW3CDate()); xmp.setProperty(XMPConst.NS_XMP, XMP_MODIFY_DATE, ((PdfDate) info.get(PdfName.MODDATE)).getW3CDate()); String title = extractInfo(PdfName.TITLE); if (title != null) { xmp.setLocalizedText(XMPConst.NS_DC, DublinCoreSchema.TITLE, //FIXME use the tag language? XMPConst.X_DEFAULT, XMPConst.X_DEFAULT, title); } String author = extractInfo(PdfName.AUTHOR); if (author != null) { //FIXME cache the options? PropertyOptions arrayOrdered = new PropertyOptions().setArrayOrdered(true); xmp.appendArrayItem(XMPConst.NS_DC, DublinCoreSchema.CREATOR, arrayOrdered, author, null); } String subject = extractInfo(PdfName.SUBJECT); if (subject != null) { PropertyOptions array = new PropertyOptions().setArray(true); xmp.appendArrayItem(XMPConst.NS_DC, DublinCoreSchema.SUBJECT, array, subject, null); xmp.setLocalizedText(XMPConst.NS_DC, DublinCoreSchema.DESCRIPTION, XMPConst.X_DEFAULT, XMPConst.X_DEFAULT, subject); } String keywords = extractInfo(PdfName.KEYWORDS); if (keywords != null) { xmp.setProperty(XMPConst.NS_PDF, PDF_KEYWORDS, keywords); } String creator = extractInfo(PdfName.CREATOR); if (creator != null) { xmp.setProperty(XMPConst.NS_XMP, XMP_CREATOR_TOOL, creator); } SerializeOptions options = new SerializeOptions(); options.setUseCanonicalFormat(true); ByteArrayOutputStream out = new ByteArrayOutputStream(4096); XMPMetaFactory.serialize(xmp, out, options); return out.toByteArray(); } catch (XMPException e) { throw new JRRuntimeException(e); } }
From source file:org.sejda.impl.itext.component.FormFieldsAwarePdfCopier.java
License:Apache License
public FormFieldsAwarePdfCopier(File outputFile, PdfVersion version) throws TaskException { try {/*from w ww . j ava 2 s.c om*/ outputStream = new FileOutputStream(outputFile); if (version == null) { pdfCopy = new PdfCopyFields(outputStream); } else { pdfCopy = new PdfCopyFields(outputStream, version.getVersionAsCharacter()); } pdfCopy.getWriter().getInfo().put(PdfName.CREATOR, new PdfString(Sejda.CREATOR, PdfObject.TEXT_UNICODE)); } catch (FileNotFoundException e) { throw new TaskException(String.format("Unable to find the output file %s", outputFile.getPath()), e); } catch (DocumentException e) { throw new TaskException("An error occurred opening the PdfCopyFields.", e); } }