我的应用程序是用两种不同版本的英语和阿拉伯语开发 我在iText中使用rowspan和colspan创建了pdf表,它在英文版中完美运行,但在阿拉伯语版本中,rowspan不起作用.当我使用setRunDirection(3)将阿拉伯语文本放入我的表时,setRowspan(2)无效.
请告诉我如何在这里设置rowspan值.
请帮我解决这个问题.
谢谢
这是表大小2列和rowspan 2的代码的一部分.
BaseFont base=BaseFont.createFont("C:/Windows/Font/arial.ttf",BaseFont.IDENTITY_H,BaseFont.EMBEDDED);
Font sourceFont= new Font(base, 9,Font.NORMAL,Color.RED);
PdfPTable tab1=new PdfPTable(2);
tab1.setRunDirection(3);//**(if you comment this line it will work)**
PdfPCell cells;
cells=new PdfPCell(new Paragraph("arabic text", sourceFont));
cells.setRowspan(2);
tab1.addCell(cells);
cells=new PdfPCell(new Paragraph("arabic text", sourceFont));
tab1.addCell(cells);
cells=new PdfPCell(new Paragraph("arabic text", sourceFont));
tab1.addCell(cells);
Run Code Online (Sandbox Code Playgroud)
小智 0
当我使用table.setRunDirection(PdfWriter.RUN_DIRECTION_RTL)
RowSpan 时,它不起作用!\n所以我删除此行并添加此:
PdfPCell title_cell= new PdfPCell(new Paragraph("\xd9\x85\xd8\xaa\xd9\x86 \xd8\xb9\xd8\xb1\xd8\xa8\xdb\x8c"));\ntitle_cell.setRunDirection(PdfWriter.RUN_DIRECTION_RTL);\ntable.addCell(title_cell);\n
Run Code Online (Sandbox Code Playgroud)\n\n我的表有 6 列和 5 行。第一行的右侧单元格的行距为 5。\n我的代码如下:
\n\nPdfPTable table = new PdfPTable(new float[] {10,10,10,10,10,50});\ntable_mehr.setTotalWidth(PageSize.A4.getWidth()-30);\ntable_mehr.setLockedWidth(true);\ntable_mehr.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);\n\n table.addCell("ali");\n table.addCell("ali");\n table.addCell("ali");\n table.addCell("ali");\n table.addCell("ali");\n PdfPCell title_cell = new PdfPCell(new Paragraph("\xd9\x85\xd8\xaa\xd9\x86 \xd8\xb9\xd8\xb1\xd8\xa8\xdb\x8c"));\n title_cell.setRowspan(5);\n title_cell.setRunDirection(PdfWriter.RUN_DIRECTION_RTL);\n\n table.addCell(title_cell);\n table.addCell("ali");\n table.addCell("ali");\n table.addCell("ali");\n table.addCell("ali");\n table.addCell("ali");\n table.addCell("ali");\n table.addCell("ali");\n table.addCell("ali");\n table.addCell("ali");\n table.addCell("ali");\n table.addCell("ali");\n table.addCell("ali");\n table.addCell("ali");\n table.addCell("ali");\n table.addCell("ali");\n table.addCell("ali");\n table.addCell("ali");\n table.addCell("ali");\n table.addCell("ali");\n table.addCell("ali");\n doc.add(table);\n
Run Code Online (Sandbox Code Playgroud)\n
归档时间: |
|
查看次数: |
2202 次 |
最近记录: |