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

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

Introduction

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

Prototype

public PDDocumentInformation() 

Source Link

Document

Default Constructor.

Usage

From source file:pdfbox.PDFA3File.java

License:Apache License

/**
 * Makes A PDF/A3a-compliant document from a PDF-A1 compliant document (on the
 * metadata level, this will not e.g. convert graphics to JPG-2000)
 *//*from  w w  w . ja  v a2 s  . co m*/
private PDDocumentCatalog makeA3compliant(PDDocument doc) throws IOException, TransformerException {
    PDDocumentCatalog cat = doc.getDocumentCatalog();
    PDMetadata metadata = new PDMetadata(doc);
    cat.setMetadata(metadata);
    // jempbox version
    XMPMetadata xmp = new XMPMetadata();
    XMPSchemaPDFAId pdfaid = new XMPSchemaPDFAId(xmp);
    xmp.addSchema(pdfaid);

    XMPSchemaDublinCore dc = xmp.addDublinCoreSchema();
    String creator = System.getProperty("user.name");
    String producer = "PDFBOX";
    dc.addCreator(creator);
    dc.setAbout("");

    XMPSchemaBasic xsb = xmp.addBasicSchema();
    xsb.setAbout("");

    xsb.setCreatorTool(creator);
    xsb.setCreateDate(GregorianCalendar.getInstance());
    // PDDocumentInformation pdi=doc.getDocumentInformation();
    PDDocumentInformation pdi = new PDDocumentInformation();
    pdi.setProducer(producer);
    pdi.setAuthor(creator);
    doc.setDocumentInformation(pdi);

    XMPSchemaPDF pdf = xmp.addPDFSchema();
    pdf.setProducer(producer);
    pdf.setAbout("");

    // Mandatory: PDF-A3 is tagged PDF which has to be expressed using a
    // MarkInfo dictionary (PDF A/3 Standard sec. 6.7.2.2)
    PDMarkInfo markinfo = new PDMarkInfo();
    markinfo.setMarked(true);
    doc.getDocumentCatalog().setMarkInfo(markinfo);

    pdfaid.setPart(3);
    pdfaid.setConformance("A");/*
                                * All files are PDF/A-3, setConformance refers
                                * to the level conformance, e.g. PDF/A-3-B where
                                * B means only visually preservable, U means
                                * visually and unicode preservable and A -like
                                * in this case- means full compliance, i.e.
                                * visually, unicode and structurally preservable
                                */
    pdfaid.setAbout("");
    metadata.importXMPMetadata(xmp);
    return cat;
}

From source file:us.kagome.pdfbox.PDFMergerExample.java

License:Apache License

private PDDocumentInformation createPDFDocumentInfo(String title, String creator, String subject) {
    LOG.info("Setting document info (title, author, subject) for merged PDF");
    PDDocumentInformation documentInformation = new PDDocumentInformation();
    documentInformation.setTitle(title);
    documentInformation.setCreator(creator);
    documentInformation.setSubject(subject);
    return documentInformation;
}