Java 如何在iTEXT中重塑表格
我正在使用iTEXT和java创建一个简单的PDF,其中包含一个特定形式的表。 我的表格在PDF文件中的形状应该是这样的 编辑: 我试图在代码中使用行跨度Java 如何在iTEXT中重塑表格,java,itext,tabular,Java,Itext,Tabular,我正在使用iTEXT和java创建一个简单的PDF,其中包含一个特定形式的表。 我的表格在PDF文件中的形状应该是这样的 编辑: 我试图在代码中使用行跨度 cell1.setRowspan(2); cell1.setVerticalAlignment(Element.ALIGN_MIDDLE); cell1.setPaddingTop(-13); cell1.setPaddingBottom(10); P
cell1.setRowspan(2);
cell1.setVerticalAlignment(Element.ALIGN_MIDDLE);
cell1.setPaddingTop(-13);
cell1.setPaddingBottom(10);
PdfPCell cell2 = new PdfPCell(new Phrase("Cell 2"));
cell2.setVerticalAlignment(Element.ALIGN_MIDDLE);
cell2.setPaddingTop(-13);
cell2.setPaddingBottom(10);
PdfPCell cell3 = new PdfPCell(new Phrase("Cell 2"));
cell3.setVerticalAlignment(Element.ALIGN_MIDDLE);
cell3.setPaddingTop(-13);
cell3.setPaddingBottom(10);
//cell.setBorder(Rectangle.NO_BORDER);
Paragraph p= new Paragraph("توفة توفايات",arabic);
Paragraph p2= new Paragraph("سناء علاء حسين",arabic);
Paragraph p3= new Paragraph("سناء سءء~ حسين",arabic);
p.setAlignment(PdfPCell.ALIGN_LEFT);
p2.setAlignment(PdfPCell.ALIGN_LEFT);
cell1.addElement(p);
cell2.addElement(p2);
table.addCell(cell1);
table.addCell(cell2);
table.completeRow();
事实上,我不知道我是否以正确的方式完成了行跨度,因为我的PDF只显示了p
和p2
,p3
在PDF中没有位置
我该怎么做?是的,您可以使用
iText7
File outputFile = new File("output.pdf");
PdfDocument pdfDocument = new PdfDocument(new PdfWriter(outputFile));
Document layoutDocument = new Document(pdfDocument);
// table magic
Table table = new Table(new float[]{20f, 20f});
table.addCell(new Cell(1,2).add(new Paragraph("Lorem")));
table.addCell(new Cell().add(new Paragraph("Ipsum")));
table.addCell(new Cell().add(new Paragraph("Dolor")));
layoutDocument.add(table);
// close
pdfDocument.close();
是的,您可以使用
iText7
File outputFile = new File("output.pdf");
PdfDocument pdfDocument = new PdfDocument(new PdfWriter(outputFile));
Document layoutDocument = new Document(pdfDocument);
// table magic
Table table = new Table(new float[]{20f, 20f});
table.addCell(new Cell(1,2).add(new Paragraph("Lorem")));
table.addCell(new Cell().add(new Paragraph("Ipsum")));
table.addCell(new Cell().add(new Paragraph("Dolor")));
layoutDocument.add(table);
// close
pdfDocument.close();
你应该分享你已经尝试过的东西。StackOverflow是关于帮助彼此解决问题。而不是外包开发。你应该分享你已经尝试过的东西。StackOverflow是关于帮助彼此解决问题。而不是外包开发。