itext生成pdf用AcroFields.setField替换文本域中的内容,请问怎么设置文本域内容的行间距???
展开全部
用columnText吧,展示效果差别不大,设置文本的各种属性也方便
BaseFont baseFont1 = BaseFont.createFont("C:/WINDOWS/Fonts/SIMYOU.TTF",BaseFont.IDENTITY_H,BaseFont.NOT_EMBEDDED);
Font font1 = new Font(baseFont1,9,Font.NORMAL);
int pageNo = form.getFieldPositions("~DICO-FUNC").get(0).page;
Rectangle signRect = form.getFieldPositions("~DICO-FUNC").get(0).position;
PdfContentByte ctOver = stamper.getOverContent(pageNo);
//测试columnText
ColumnText ct = new ColumnText(ctOver);
//行间距
ct.setLeading(0,1);
ct.setAlignment(Element.ALIGN_LEFT);
ct.setText(new Paragraph(" 测试输出",font1));
ct.setSimpleColumn(signRect);
ct.go();
BaseFont baseFont1 = BaseFont.createFont("C:/WINDOWS/Fonts/SIMYOU.TTF",BaseFont.IDENTITY_H,BaseFont.NOT_EMBEDDED);
Font font1 = new Font(baseFont1,9,Font.NORMAL);
int pageNo = form.getFieldPositions("~DICO-FUNC").get(0).page;
Rectangle signRect = form.getFieldPositions("~DICO-FUNC").get(0).position;
PdfContentByte ctOver = stamper.getOverContent(pageNo);
//测试columnText
ColumnText ct = new ColumnText(ctOver);
//行间距
ct.setLeading(0,1);
ct.setAlignment(Element.ALIGN_LEFT);
ct.setText(new Paragraph(" 测试输出",font1));
ct.setSimpleColumn(signRect);
ct.go();
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询