openpdf模板
AdobeAcrobatpro生成PDF模版java生成PDF辣白菜怎么做
孔子见南子//PdfTemplate类里面定义了所有表单域的名称这里只举例子了两个表单域//上面提到了表单域的名称
publicstaticvoidfillTemplate(PdfTemplatepdfTemplate)throwsBusinessException{
//模板路径
StringtemplatePath="/pdf/xxxx.pdf";
//填充模版文件后生成的待签署的合同路径
//TODO地址
//文件名BORROWPROTOCOL+协议编号
StringnewPDFPath=TEMP_PDF_Contract_no()+EXPANDEDNAME;
出纳交接表模板
PdfReaderreader;
FileOutputStreamout;
ByteArrayOutputStreambos;
PdfStamperstamper;
try{
out=newFileOutputStream(newPDFPath);
//读取pdf模板芙蓉洞
王羲之书法reader=newPdfReader(templatePath);
bos=newByteArrayOutputStream();
stamper=newPdfStamper(reader,bos);
AcroFields();
//往pdf合同模版里面设置值//mock
//合同编号
form.tField("contract_no",Contract_no());
//甲方
人人有份
form.tField("first_ur_name",First_ur_name());
//...需要填充的其他表单域
//如果为fal那么生成的PDF文件还能编辑,一定要设为true
stamper.tFormFlattening(true);
stamper.clo();
Documentdoc=newDocument();
PdfCopycopy=newPdfCopy(doc,out);
缘相随
doc.open();
//pdf模版的页数
赞颂老师的成语NumberOfPages();
for(inti=1;i<pagecount+1;i++){
ImportedPage(ByteArray()),i);
copy.addPage(importPage);
}
doc.clo();
}catch(IOExceptione){
thrownewBusinessException("生成合同模版失败,合同编号:"+Contract_no());
}catch(DocumentExceptione){
thrownewBusinessException("生成合同模版失败,合同编号:"+Contract_no());