Example usage for org.apache.pdfbox.pdmodel PDDocumentInformation setModificationDate

List of usage examples for org.apache.pdfbox.pdmodel PDDocumentInformation setModificationDate

Introduction

In this page you can find the example usage for org.apache.pdfbox.pdmodel PDDocumentInformation setModificationDate.

Prototype

public void setModificationDate(Calendar date) 

Source Link

Document

This will set the modification date of the document.

Usage

From source file:io.konik.carriage.pdfbox.PDFBoxInvoiceAppender.java

License:Open Source License

private void setMetadata(PDDocument doc, AppendParameter appendParameter)
        throws IOException, TransformerException, BadFieldValueException, XmpSerializationException {
    Calendar now = Calendar.getInstance();
    PDDocumentCatalog catalog = doc.getDocumentCatalog();

    PDMetadata metadata = new PDMetadata(doc);
    catalog.setMetadata(metadata);//from www  . j a  v a 2s  .c  om

    XMPMetadata xmp = XMPMetadata.createXMPMetadata();
    PDFAIdentificationSchema pdfaid = new PDFAIdentificationSchema(xmp);
    pdfaid.setPart(Integer.valueOf(3));
    pdfaid.setConformance("B");
    xmp.addSchema(pdfaid);

    DublinCoreSchema dublicCore = new DublinCoreSchema(xmp);
    xmp.addSchema(dublicCore);

    XMPBasicSchema basicSchema = new XMPBasicSchema(xmp);
    basicSchema.setCreatorTool(PRODUCER);
    basicSchema.setCreateDate(now);
    xmp.addSchema(basicSchema);

    PDDocumentInformation pdi = doc.getDocumentInformation();
    pdi.setModificationDate(now);
    pdi.setProducer(PRODUCER);
    pdi.setAuthor(getAuthor());
    doc.setDocumentInformation(pdi);

    AdobePDFSchema pdf = new AdobePDFSchema(xmp);
    pdf.setProducer(PRODUCER);
    xmp.addSchema(pdf);

    PDMarkInfo markinfo = new PDMarkInfo();
    markinfo.setMarked(true);
    doc.getDocumentCatalog().setMarkInfo(markinfo);

    xmp.addSchema(zfDefaultXmp.getPDFExtensionSchema());
    XMPSchemaZugferd1p0 zf = new XMPSchemaZugferd1p0(xmp);
    zf.setConformanceLevel(appendParameter.zugferdConformanceLevel());
    zf.setVersion(appendParameter.zugferdVersion());
    xmp.addSchema(zf);

    new XmpSerializer().serialize(xmp, metadata.createOutputStream(), true);
}

From source file:org.olat.core.util.pdf.PdfDocument.java

License:Apache License

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);//from   ww w .ja v  a2 s. c  o  m
    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);
}