我正在使用 iText 动态生成 PDF 文档。现在我正在尝试在此 PDF 中动态创建条形码。Adobe Live Cycle 内置了条码功能。您只需拖动页面上的条形码文本框即可创建。
问题:
我在 PDF 中放置了条形码字段。然后从 JSP 页面向条形码字段传递一个数字。但只有数字出现。条码线从不显示
数字 20099002 在 PDF 文档中可见,但条码线未显示。我在 LiveCycle 中尝试了其他几个条形码选项,但都给出了相同的结果。
OurJavaPage.java
public class ExampleForm extends BaseOutput {
private static final Log LOG = LogFactory.getLog(ExampleForm.class);
public OutputStream generate() throws IOException, DocumentException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PdfReader reader;
reader = new PdfReader(BASEDIR + "MailingExample.pdf");
PdfStamper stamper = new PdfStamper(reader, baos);
Participant participantHome = home.getParticipant();
Set<Location> homeLocs = participantHome.getLocations();
final AcroFields form = stamper.getAcroFields();
setFormField(form, "addrNumber[0]", addrMaster.getStreetNum());
setFormField(form, "dateMiddle[0]", formatDate("MM-dd-yyyy", new Date()));
// *********** Here's the problem *****************************
setFormField(form, "Code128ABarcode1[0]", "20099002");
// ************************************************************
debugAcrobatForm("ExampleForm", form);
stamper.setFormFlattening(true);
stamper.close();
return baos;
}
}
操作系统: Linux
编程: Java、.jsp、iText
软件: Adobe Live Cycle Designer ES 8.1