Example usage for com.lowagie.text.pdf PdfName AUTHOR

List of usage examples for com.lowagie.text.pdf PdfName AUTHOR

Introduction

In this page you can find the example usage for com.lowagie.text.pdf PdfName AUTHOR.

Prototype

PdfName AUTHOR

To view the source code for com.lowagie.text.pdf PdfName AUTHOR.

Click Source Link

Document

A name

Usage

From source file:net.mitnet.tools.pdf.book.pdf.itext.PdfReaderHelper.java

License:Open Source License

public String getDocumentAuthor(String defaultValue) {
    return getPdfStringValue(this.pdfInfo, PdfName.AUTHOR, defaultValue);
}

From source file:net.sf.jasperreports.engine.export.PdfXmpCreator.java

License:Open Source License

byte[] createXmpMetadata() {
    try {// w ww . j a  va 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.xhtmlrenderer.pdf.util.XHtmlMetaToPdfInfoAdapter.java

License:Open Source License

private void parseHtmlMetaTags(Document doc) {

    NodeList headNodeList = doc.getDocumentElement().getElementsByTagName(HTML_TAG_HEAD);
    XRLog.render(Level.FINEST, "headNodeList=" + headNodeList);
    Element rootHeadNodeElement = (Element) headNodeList.item(0);
    NodeList metaNodeList = rootHeadNodeElement.getElementsByTagName(HTML_TAG_META);
    XRLog.render(Level.FINEST, "metaNodeList=" + metaNodeList);

    for (int inode = 0; inode < metaNodeList.getLength(); ++inode) {
        XRLog.render(Level.FINEST, "node " + inode + " = " + metaNodeList.item(inode).getNodeName());
        Element thisNode = (Element) metaNodeList.item(inode);
        XRLog.render(Level.FINEST, "node " + thisNode);
        String metaName = thisNode.getAttribute(HTML_META_ATTR_NAME);
        String metaContent = thisNode.getAttribute(HTML_META_ATTR_CONTENT);
        XRLog.render(Level.FINEST, "metaName=" + metaName + ", metaContent=" + metaContent);
        if (metaName.length() != 0 && metaContent.length() != 0) {

            PdfName pdfName = null;//from  w  w w. j ava2s .  c  o  m
            PdfString pdfString = null;
            if (HTML_META_KEY_TITLE.equalsIgnoreCase(metaName)
                    || HTML_META_KEY_DC_TITLE.equalsIgnoreCase(metaName)) {
                pdfName = PdfName.TITLE;
                pdfString = new PdfString(metaContent, PdfObject.TEXT_UNICODE);
                this.pdfInfoValues.put(pdfName, pdfString);

            } else if (HTML_META_KEY_CREATOR.equalsIgnoreCase(metaName)
                    || HTML_META_KEY_DC_CREATOR.equalsIgnoreCase(metaName)) {
                pdfName = PdfName.AUTHOR;
                pdfString = new PdfString(metaContent, PdfObject.TEXT_UNICODE);
                this.pdfInfoValues.put(pdfName, pdfString);

            } else if (HTML_META_KEY_SUBJECT.equalsIgnoreCase(metaName)
                    || HTML_META_KEY_DC_SUBJECT.equalsIgnoreCase(metaName)) {
                pdfName = PdfName.SUBJECT;
                pdfString = new PdfString(metaContent, PdfObject.TEXT_UNICODE);
                this.pdfInfoValues.put(pdfName, pdfString);

            } else if (HTML_META_KEY_KEYWORDS.equalsIgnoreCase(metaName)) {
                pdfName = PdfName.KEYWORDS;
                pdfString = new PdfString(metaContent, PdfObject.TEXT_UNICODE);
                this.pdfInfoValues.put(pdfName, pdfString);
            }
        }
    }
}