放置在小型頁面文字和圖像,我需要做一個PDF頁面看起來是這樣的:如何利用iText
我有問題,做出適合在兩列小頁面。
這是我的代碼:爲您解決問題,是創建與AcroForm領域模板PDF
public void createSizedPdf(String dest) throws IOException, DocumentException {
Document document = new Document();
PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(dest));
document.setMargins(5,5,5,5);
Rectangle one = new Rectangle(290,100);
one.setBackgroundColor(Color.YELLOW);
document.setPageSize(one);
document.open();
Paragraph consigneeName = new Paragraph("Ahmed");
Paragraph address = new Paragraph("Casa ST 121");
String codeBL = "14785236987541";
PdfContentByte cb = writer.getDirectContent();
Barcode128 code128 = new Barcode128();
code128.setBaseline(9);
code128.setSize(9);
code128.setCode(codeBL);
code128.setCodeType(Barcode128.CODE128);
Image code128Image = code128.createImageWithBarcode(cb, null, null);
Paragraph right = new Paragraph();
right.add(consigneeName);
right.add(address);
right.add(code128Image);
Chunk glue = new Chunk(new VerticalPositionMark());
Paragraph p = new Paragraph();
p.add(right);
p.add(new Chunk(glue));
p.add(code128Image);
document.add(p);
document.close();
}
您使用的是iText 5還是iText 7?你有什麼嘗試?你問的東西*非常微不足道,所以我們很難理解你的問題:你無法縮放圖像嗎?你無法定義更小的字體大小嗎?你無法創建具有特定維度的表格嗎?你說*我有問題需要製作適合小尺寸頁面的兩列*但你忘了描述問題。請改善你的問題。 –
我剛剛編輯了一些代碼片段的問題,因爲我使用iText5的iText版本,再加上我想要做的事情的鏈接 – ahmed
是否有一個特定的原因,您爲什麼不想使用AcroForm模板做這種工作?這不會更優雅和靈活嗎? –