Java 类com.lowagie.text.pdf.PdfDate 实例源码

项目:itext2    文件:PdfCollectionField.java   
/**
 * Returns a PdfObject that can be used as the value of a Collection Item.
 * @param v value   the value that has to be changed into a PdfObject (PdfString, PdfDate or PdfNumber) 
 */
public PdfObject getValue(String v) {
    switch(fieldType) {
    case TEXT:
        return new PdfString(v, PdfObject.TEXT_UNICODE);
    case DATE:
        return new PdfDate(PdfDate.decode(v));
    case NUMBER:
        return new PdfNumber(v);
    }
    throw new IllegalArgumentException(v + " is not an acceptable value for the field " + get(PdfName.N).toString());
}
项目:jasperreports    文件:PdfXmpCreator.java   
byte[] createXmpMetadata()
{
    try
    {
        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);
    }
}
项目:DroidText    文件:PdfCollectionItem.java   
/**
 * Sets the value of the collection item.
 * @param d
 */
public void addItem(String key, PdfDate d) {
    PdfName fieldname = new PdfName(key);
    PdfCollectionField field = (PdfCollectionField)schema.get(fieldname);
    if (field.fieldType == PdfCollectionField.DATE) {
        put(fieldname, d);
    }
}
项目:itext2    文件:XmpWriter.java   
/**
 * @param os
 * @param info
 * @throws IOException
 */
public XmpWriter(OutputStream os, Map info) throws IOException {
    this(os);
    if (info != null) {
        DublinCoreSchema dc = new DublinCoreSchema();
        PdfSchema p = new PdfSchema();
        XmpBasicSchema basic = new XmpBasicSchema();
        String key;
        String value;
        for (Iterator it = info.entrySet().iterator(); it.hasNext();) {
            Map.Entry entry = (Map.Entry) it.next();
            key = (String) entry.getKey();
            value = (String) entry.getValue();
            if (value == null)
                continue;
            if ("Title".equals(key)) {
                dc.addTitle(value);
            }
            if ("Author".equals(key)) {
                dc.addAuthor(value);
            }
            if ("Subject".equals(key)) {
                dc.addSubject(value);
                dc.addDescription(value);
            }
            if ("Keywords".equals(key)) {
                p.addKeywords(value);
            }
            if ("Creator".equals(key)) {
                basic.addCreatorTool(value);
            }
            if ("Producer".equals(key)) {
                p.addProducer(value);
            }
            if ("CreationDate".equals(key)) {
                basic.addCreateDate(PdfDate.getW3CDate(value));
            }
            if ("ModDate".equals(key)) {
                basic.addModDate(PdfDate.getW3CDate(value));
            }
        }
        if (dc.size() > 0) addRdfDescription(dc);
        if (p.size() > 0) addRdfDescription(p);
        if (basic.size() > 0) addRdfDescription(basic);
    }
}
项目:itext2    文件:PdfCollectionItem.java   
/**
 * Sets the value of the collection item.
 * @param d
 */
public void addItem(String key, PdfDate d) {
    PdfName fieldname = new PdfName(key);
    PdfCollectionField field = (PdfCollectionField)schema.get(fieldname);
    if (field.fieldType == PdfCollectionField.DATE) {
        put(fieldname, d);
    }
}
项目:DroidText    文件:XmpWriter.java   
/**
 * @param os
 * @param info
 * @throws IOException
 */
public XmpWriter(OutputStream os, Map info) throws IOException {
    this(os);
    if (info != null) {
        DublinCoreSchema dc = new DublinCoreSchema();
        PdfSchema p = new PdfSchema();
        XmpBasicSchema basic = new XmpBasicSchema();
        String key;
        String value;
        for (Iterator it = info.entrySet().iterator(); it.hasNext();) {
            Map.Entry entry = (Map.Entry) it.next();
            key = (String) entry.getKey();
            value = (String) entry.getValue();
            if (value == null)
                continue;
            if ("Title".equals(key)) {
                dc.addTitle(value);
            }
            if ("Author".equals(key)) {
                dc.addAuthor(value);
            }
            if ("Subject".equals(key)) {
                dc.addSubject(value);
                dc.addDescription(value);
            }
            if ("Keywords".equals(key)) {
                p.addKeywords(value);
            }
            if ("Creator".equals(key)) {
                basic.addCreatorTool(value);
            }
            if ("Producer".equals(key)) {
                p.addProducer(value);
            }
            if ("CreationDate".equals(key)) {
                basic.addCreateDate(PdfDate.getW3CDate(value));
            }
            if ("ModDate".equals(key)) {
                basic.addModDate(PdfDate.getW3CDate(value));
            }
        }
        if (dc.size() > 0) addRdfDescription(dc);
        if (p.size() > 0) addRdfDescription(p);
        if (basic.size() > 0) addRdfDescription(basic);
    }
}
项目:DroidText    文件:PdfCollectionField.java   
/**
 * Returns a PdfObject that can be used as the value of a Collection Item.
 * @param v value   the value that has to be changed into a PdfObject (PdfString, PdfDate or PdfNumber) 
 */
public PdfObject getValue(String v) {
    switch(fieldType) {
    case TEXT:
        return new PdfString(v, PdfObject.TEXT_UNICODE);
    case DATE:
        return new PdfDate(PdfDate.decode(v));
    case NUMBER:
        return new PdfNumber(v);
    }
    throw new IllegalArgumentException(v + " is not an acceptable value for the field " + get(PdfName.N).toString());
}
项目:itext2    文件:PdfCollectionItem.java   
/**
 * Sets the value of the collection item.
 * @param c
 */
public void addItem(String key, Calendar c) {
    addItem(key, new PdfDate(c));
}
项目:DroidText    文件:PdfCollectionItem.java   
/**
 * Sets the value of the collection item.
 * @param c
 */
public void addItem(String key, Calendar c) {
    addItem(key, new PdfDate(c));
}