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

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

Introduction

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

Prototype

public void setCreator(String creator) 

Source Link

Document

This will set the creator of the document.

Usage

From source file:au.org.alfred.icu.pdf.services.factories.ICUDischargeSummaryFactory.java

public static void addDocumentInformation(PDDocument pdf, String title, String subject, String keywords,
        String creator, String author) {

    PDDocumentInformation info = new PDDocumentInformation();

    info.setAuthor(author);// ww  w .  j av a 2  s.  c  om
    info.setCreationDate(Calendar.getInstance());
    info.setCreator(creator);
    info.setKeywords(keywords);
    info.setSubject(subject);
    info.setTitle("ICU Discharge Summary");

    pdf.setDocumentInformation(info);

}

From source file:com.helger.pdflayout.PageLayoutPDF.java

License:Apache License

/**
 * Render this layout to an OutputStream.
 *
 * @param aCustomizer/*from  w  w  w. j a v  a  2 s  . com*/
 *        The customizer to be invoked before the document is written to the
 *        stream. May be <code>null</code>.
 * @param aOS
 *        The output stream to write to. May not be <code>null</code>. Is
 *        closed automatically.
 * @throws PDFCreationException
 *         In case of an error
 */
public void renderTo(@Nullable final IPDDocumentCustomizer aCustomizer,
        @Nonnull @WillClose final OutputStream aOS) throws PDFCreationException {
    // create a new document
    PDDocument aDoc = null;

    try {
        aDoc = new PDDocument();

        // Set document properties
        {
            final PDDocumentInformation aProperties = new PDDocumentInformation();
            if (StringHelper.hasText(m_sDocumentAuthor))
                aProperties.setAuthor(m_sDocumentAuthor);
            if (m_aDocumentCreationDate != null)
                aProperties.setCreationDate(m_aDocumentCreationDate);
            if (StringHelper.hasText(m_sDocumentCreator))
                aProperties.setCreator(m_sDocumentCreator);
            if (StringHelper.hasText(m_sDocumentTitle))
                aProperties.setTitle(m_sDocumentTitle);
            if (StringHelper.hasText(m_sDocumentKeywords))
                aProperties.setKeywords(m_sDocumentKeywords);
            if (StringHelper.hasText(m_sDocumentSubject))
                aProperties.setSubject(m_sDocumentSubject);
            aProperties.setProducer("ph-pdf-layout - https://github.com/phax/ph-pdf-layout");
            // add the created properties
            aDoc.setDocumentInformation(aProperties);
        }

        // Prepare all page sets
        final PageSetPrepareResult[] aPRs = new PageSetPrepareResult[m_aPageSets.size()];
        int nPageSetIndex = 0;
        int nTotalPageCount = 0;
        for (final PLPageSet aPageSet : m_aPageSets) {
            final PageSetPrepareResult aPR = aPageSet.prepareAllPages();
            aPRs[nPageSetIndex] = aPR;
            nTotalPageCount += aPR.getPageCount();
            nPageSetIndex++;
        }

        // Start applying all page sets
        nPageSetIndex = 0;
        int nTotalPageIndex = 0;
        for (final PLPageSet aPageSet : m_aPageSets) {
            final PageSetPrepareResult aPR = aPRs[nPageSetIndex];
            aPageSet.renderAllPages(aPR, aDoc, m_bDebug, nPageSetIndex, nTotalPageIndex, nTotalPageCount);
            // Inc afterwards
            nTotalPageIndex += aPR.getPageCount();
            nPageSetIndex++;
        }

        // Customize the whole document (optional)
        if (aCustomizer != null)
            aCustomizer.customizeDocument(aDoc);

        // save document to output stream
        aDoc.save(aOS);

        if (s_aLogger.isDebugEnabled())
            s_aLogger.debug("PDF successfully created");
    } catch (final IOException ex) {
        throw new PDFCreationException("IO Error", ex);
    } catch (final Throwable t) {
        throw new PDFCreationException("Internal error", t);
    } finally {
        // close document
        if (aDoc != null) {
            try {
                aDoc.close();
            } catch (final IOException ex) {
                s_aLogger.error("Failed to close PDF document " + aDoc, ex);
            }
        }

        // Necessary in case of an exception
        StreamUtils.close(aOS);
    }
}

From source file:io.github.qwefgh90.akka.pdf.PDFUtilWrapper.java

License:Apache License

private static 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;
}

From source file:org.gfbio.idmg.util.PDFUtil.java

private void setDocumentInformation() {

    // Creating the PDDocumentInformation object
    PDDocumentInformation pdd = document.getDocumentInformation();
    // Setting the author of the document
    pdd.setAuthor("GFBio");
    // Setting the title of the document
    pdd.setTitle("DMP for" + userInput.getProjectName());
    // Setting the creator of the document
    pdd.setCreator("GFBio DMP-Tool");
    // Setting the subject of the document
    pdd.setSubject("GFBio Data Management Plan");
}

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 w ww .  j a va  2 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);
}

From source file:org.primaresearch.pdf.PageToPdfConverterUsingPdfBox.java

License:Apache License

private void addMetadata(PDDocument doc, Page page) {
    MetaData pageMetadata = page.getMetaData();

    PDDocumentInformation info = new PDDocumentInformation();

    //Creator/*from   w  w  w  . jav  a 2 s  . co  m*/
    if (pageMetadata.getCreator() != null && !pageMetadata.getCreator().isEmpty())
        info.setCreator(pageMetadata.getCreator());

    //Comments
    if (pageMetadata.getComments() != null && !pageMetadata.getComments().isEmpty())
        info.setCustomMetadataValue("Comments", pageMetadata.getComments());

    //TODO

    doc.setDocumentInformation(info);
}

From source file:org.zaproxy.zap.extension.alertReport.AlertReportExportPDF.java

License:Apache License

/**
 * adds PDF metadata to the PDF document
 *
 * @param extensionExport/*from   w w  w.  jav  a  2  s .co  m*/
 */
private void addMetaData(ExtensionAlertReportExport extensionExport) {
    PDDocumentInformation docInfo = document.getDocumentInformation();
    docInfo.setTitle(extensionExport.getParams().getTitleReport());
    docInfo.setSubject(extensionExport.getParams().getCustomerName());
    docInfo.setKeywords(extensionExport.getParams().getPdfKeywords());
    docInfo.setAuthor(extensionExport.getParams().getAuthorName());
    docInfo.setCreator(extensionExport.getParams().getAuthorName());
    docInfo.setProducer("OWASP ZAP. Extension authors: Leandro Ferrari, Colm O'Flaherty");
}

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;
}