useful materials
http://svn.assembla.com/svn/jarbilling/billing/trunk/billing/vendor/pdfmanipulator/Fdf.java
http://svn.assembla.com/svn/jarbilling/billing/trunk/billing/vendor/pdfmanipulator/test/BatchFormFill.java
http://www.coderanch.com/t/63861/open-source/iText-Silent-Print
http://threebit.net/mail-archive/itext-questions/msg02068.html
part4.chapter13.PrintPreferencesExample:
http://itextpdf.com/examples/iia.php?id=230
http://comments.gmane.org/gmane.comp.java.lib.itext.general/28053
import java.io.ByteArrayOutputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.util.Map.Entry;
import java.util.Set;
import com.itextpdf.text.Document;
import com.itextpdf.text.FontFactory;
import com.itextpdf.text.PageSize;
import com.itextpdf.text.pdf.AcroFields;
import com.itextpdf.text.pdf.AcroFields.Item;
import com.itextpdf.text.pdf.BaseFont;
import com.itextpdf.text.pdf.PdfReader;
import com.itextpdf.text.pdf.PdfStamper;
public class PdfTest2 {
public static void main(String[] args) throws Exception {
// Create output PDF
Document document = new Document(PageSize.A4);
document.open();
// Load existing PDF
PdfReader reader = new PdfReader(new FileInputStream(
"Sample application form_ENG edit.pdf"));
// PdfImportedPage page = writer.getImportedPage(reader, 1);
// we'll create the file in memory
ByteArrayOutputStream baos = new ByteArrayOutputStream();
// Now we create the PDF
PdfStamper stamper = new PdfStamper(reader, baos);
// We alter the fields of the existing PDF
AcroFields fields = stamper.getAcroFields();
BaseFont baseFont = FontFactory.getFont(FontFactory.TIMES_ITALIC,BaseFont.IDENTITY_H, new Float(12)).getBaseFont();
Set<Entry<String, Item>> entrySet = fields.getFields().entrySet();
for (Entry<String, Item> entry : entrySet) {
String key = entry.getKey();
System.out.println(key);
fields.setField(key, key);
// if (fields.getFieldType(key) == AcroFields.FIELD_TYPE_TEXT) {
fields.setFieldProperty(key, "textfont", baseFont, null);
fields.setFieldProperty(key, "textsize", new Float(16), null);
// }
}
fields.setField("tradeID", "007");
// close the stamper
fields.setField("acNo", "9527");
stamper.close();
document.close();
// let's write the file in memory to a file anyway
FileOutputStream fos = new FileOutputStream("HelloWorld-Gavin.pdf");
fos.write(baos.toByteArray());
fos.close();
}
}
分享到:
相关推荐
使用itextpdf5做合同模板,工程中有itextpdf5的使用教程,基本能实现再实际应用中的需求
# 本项目主要介绍 1. itextpdf(CreatePdf) ...对于不会HTML的制作,熟悉**itextpdf**的,完全可以使用PdfTemplate,该方法其实就是将itextpdf中PDF的元素逆解析 5. xdocreport 复杂word动态生成上功能很强大
该项目实现了使用IText将html文件转为pdf文件功能。 步骤: (1):将字体文件按代码中写的路径放到磁盘对应位置。 (2):将template.html文件按代码中路径放到磁盘对应位置。 (3):直接运行HtmlToPdfUtilForCss...
实现 在生成的PDF封面显示总页数, 在每页显示页眉、页脚, 在页脚显示 第几页/共几页 实现 在生成的PDF封面显示总页数, 在每页显示页眉、页脚, 在页脚显示 第几页/共几页
项目需引用itextpdf-5.5.5.jar处理pdf 套打方法类中加载此pdf模板文件: URL templateFile = this.getClass().getResource(/pdftemplate/xxx.pdf); 根据具体业务获取套打的数据,并写入对应的Map中,Map的key即为...
是附加组件。 此附加组件使您可以轻松地将HTML转换为PDF或iText对象。 pdfHtml社区源代码托管在,... 这些活动包括: 以ASP的形式向客户提供付费服务在云端或网络应用程序中即时提供PDF 使用封闭源产品运送iText 与人员
itext-html-css-pdf-jsf-template JSF模板项目,使用CSS从HTML创建PDF
是附加组件。 此附加组件使您可以轻松地将HTML转换为PDF或iText对象。 pdfHtml社区源代码托管在,您还... 这些活动包括: 以ASP的形式向客户提供付费服务在云端或网络应用程序中即时提供PDF 使用封闭源产品运送iText
PDF应用程序中的Resume是基于Lowagie iText库的Java模板应用程序。 恢复 你可以看 如何使用 要求 假定使用Java和Gradle发行版。 对于Gradle,强烈建议使用以下安装程序之一: (BREW的gradle安装) 万不得已,如果...
poi word转pdf
百度云盘分享 简介 笔者当初为了学习JAVA,收集了很多经典源码,源码难易程度分为初级、中级、高级等,详情看源码列表,需要的可以直接下载! 这些源码反映了那时那景笔者对未来的盲目,对代码的热情、执着,对...
Java 源码包 Applet钢琴模拟程序java源码 2个目标文件,提供基本的音乐编辑功能。编辑音乐软件的朋友,这款实例会对你有所帮助。 Calendar万年历 1个目标文件 EJB 模拟银行ATM流程及操作源代码 ...