当前位置: 首页>>代码示例>>Java>>正文


Java PdfDate类代码示例

本文整理汇总了Java中com.lowagie.text.pdf.PdfDate的典型用法代码示例。如果您正苦于以下问题:Java PdfDate类的具体用法?Java PdfDate怎么用?Java PdfDate使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


PdfDate类属于com.lowagie.text.pdf包,在下文中一共展示了PdfDate类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getValue

import com.lowagie.text.pdf.PdfDate; //导入依赖的package包/类
/**
 * 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());
}
 
开发者ID:albfernandez,项目名称:itext2,代码行数:16,代码来源:PdfCollectionField.java

示例2: createXmpMetadata

import com.lowagie.text.pdf.PdfDate; //导入依赖的package包/类
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);
	}
}
 
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:74,代码来源:PdfXmpCreator.java

示例3: addItem

import com.lowagie.text.pdf.PdfDate; //导入依赖的package包/类
/**
 * 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);
	}
}
 
开发者ID:bullda,项目名称:DroidText,代码行数:12,代码来源:PdfCollectionItem.java

示例4: XmpWriter

import com.lowagie.text.pdf.PdfDate; //导入依赖的package包/类
/**
 * @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);
    }
}
 
开发者ID:albfernandez,项目名称:itext2,代码行数:51,代码来源:XmpWriter.java


注:本文中的com.lowagie.text.pdf.PdfDate类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。