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. 插入符號
- 4. 插入blob時標識符太長
- 5. SET帶引號的標識符應該插入一條記錄
- 6. 用PHP插入註冊商標符號/版權符號到MySQL
- 7. pydtmx或libdtmx如何返回FNC1字符
- 8. 無效標識符時插入全部
- 9. VIM符號^ A
- 10. 越來越近光標插入符號
- 11. 如何使用UItableViewCell重用標識符
- 12. MySQL:插入符號,如½或°
- 13. 語法錯誤:插入「枚舉標識符」,插入「EnumBody」小圖「}」
- 14. 如何使用javascript在插入符處插入字符?
- 15. PHP和MySQL - 使用標識符在表中插入值
- 16. 使用插入符號(^)在PowerShell中
- 17. 在Word中使用C插入符號
- 18. 在SparkR中使用插入符號?
- 19. 使用php在mysql中插入符號
- 20. 在Ruby中使用插入符號(^)
- 21. iText:無法打印÷符號
- 22. 目標C中的插入符號C
- 23. 如何解決孤兒標點符號iText的
- 24. 如何讓插入順序的唯一標識符
- 25. 使用@符號的文件名和標識符
- 26. 我如何定製插入符號?
- 27. Filter_var()被添加了 「A」 符號 「©」 符號
- 28. 如何比較符號a和字符a?
- 29. &(&符號)字符未插入數據庫
- 30. 插入貨幣符號,itextSharp
iText的5.5.11今天將被釋放,其中包含條形碼128A一個修正:https://github.com/itext/itextpdf/commit/e20dc76e8862422ff366f83f5486ce795a05c8be –
@AmedeeVanGasse謝謝你的 – PbxMan