0
A
回答
1
这个问题似乎与iText的5.5.11来解决。我发布这个例子来展示它是如何完成的。
package sandbox.barcodes;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import com.itextpdf.text.Document;
import com.itextpdf.text.DocumentException;
import com.itextpdf.text.Image;
import com.itextpdf.text.pdf.Barcode128;
import com.itextpdf.text.pdf.PdfContentByte;
import com.itextpdf.text.pdf.PdfPCell;
import com.itextpdf.text.pdf.PdfPTable;
import com.itextpdf.text.pdf.PdfWriter;
public class BarcodeInTable {
public static final String DEST = "/tmp/barcode_in_table.pdf";
public static void main(String[] args) throws IOException, DocumentException {
File file = new File(DEST);
file.getParentFile().mkdirs();
new BarcodeInTable().createPdf(DEST);
}
public void createPdf(String dest) throws IOException, DocumentException {
Document document = new Document();
PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(dest));
document.open();
String withFNC1 = "021930063300597615160221105052013760";
String withoutFNC1 = "02193006330059761516022110505201Ê3760";
PdfContentByte cb = writer.getDirectContent();
PdfPTable table = new PdfPTable(2);
table.addCell("Without FNC1");
Barcode128 code128 = new Barcode128();
code128.setCode(withFNC1);
code128.setCodeType(Barcode128.CODE128);
Image code128Image = code128.createImageWithBarcode(cb, null, null);
PdfPCell cell = new PdfPCell(code128Image);
table.addCell(cell);
table.addCell("With FNC1");
code128 = new Barcode128();
code128.setCode(withoutFNC1);
code128.setCodeType(Barcode128.CODE128);
code128Image = code128.createImageWithBarcode(cb, null, null);
cell = new PdfPCell(code128Image);
table.addCell(cell);
document.add(table);
document.close();
}
}
相关问题
- 1. 使用未声明的标识符'a'
- 2. 号码作为标识符
- 3. 如何使用C#中的美元符号引用标识符?
- 4. 标识符“A”是C++
- 5. 特殊字符“A”之前版权符号插入
- 6. 插入符号
- 7. pydtmx或libdtmx如何返回FNC1字符
- 8. 插入blob时标识符太长
- 9. SET带引号的标识符应该插入一条记录
- 10. 用PHP插入注册商标符号/版权符号到MySQL
- 11. 无效标识符时插入全部
- 12. Scala中的符号标识符
- 13. iText Java:不添加音标符号
- 14. VIM符号^ A
- 15. mongodb插入意外标识符
- 16. 以......开头的标识符太长。最大长度为128
- 17. 越来越近光标插入符号
- 18. 如何使用UItableViewCell重用标识符
- 19. MySQL:插入符号,如½或°
- 20. 用VBA插入符号
- 21. 如何使用sed来标识括号中的字符串?
- 22. 语法错误:插入“枚举标识符”,插入“EnumBody”小图“}”
- 23. 如何使用javascript在输入文本中插入符号
- 24. 如何使用javascript在插入符处插入字符?
- 25. PHP和MySQL - 使用标识符在表中插入值
- 26. 在Word中使用C插入符号
- 27. 在SparkR中使用插入符号?
- 28. 使用带插入符号的PCRE_MULTILINE
- 29. 使用插入符号(^)在PowerShell中
- 30. 使用php在mysql中插入符号
iText的5.5.11今天将被释放,其中包含条形码128A一个修正:https://github.com/itext/itextpdf/commit/e20dc76e8862422ff366f83f5486ce795a05c8be –
@AmedeeVanGasse谢谢你的 – PbxMan