问题
My application is developed in two different version English and Arabic. I have created pdf table in iText with rowspan and colspan which is working perfectly in English version but in arabic version rowspan is not working. when i'm using setRunDirection(3) to put arabic text in my table,the setRowspan(2) is not working.
please tell me how set rowspan value here.
please help me to solve this issue.
Thanks
This is part of code for table size 2 column and 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);
回答1:
When I use table.setRunDirection(PdfWriter.RUN_DIRECTION_RTL) RowSpan is NotWorking!
so I Remove This Line And Add this:
PdfPCell title_cell= new PdfPCell(new Paragraph("متن عربی"));
title_cell.setRunDirection(PdfWriter.RUN_DIRECTION_RTL);
table.addCell(title_cell);
My Table have 6 column and 5 Rows. Right cell in First Row is rowspan 5. My Code here:
PdfPTable table = new PdfPTable(new float[] {10,10,10,10,10,50});
table_mehr.setTotalWidth(PageSize.A4.getWidth()-30);
table_mehr.setLockedWidth(true);
table_mehr.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
table.addCell("ali");
table.addCell("ali");
table.addCell("ali");
table.addCell("ali");
table.addCell("ali");
PdfPCell title_cell = new PdfPCell(new Paragraph("متن عربی"));
title_cell.setRowspan(5);
title_cell.setRunDirection(PdfWriter.RUN_DIRECTION_RTL);
table.addCell(title_cell);
table.addCell("ali");
table.addCell("ali");
table.addCell("ali");
table.addCell("ali");
table.addCell("ali");
table.addCell("ali");
table.addCell("ali");
table.addCell("ali");
table.addCell("ali");
table.addCell("ali");
table.addCell("ali");
table.addCell("ali");
table.addCell("ali");
table.addCell("ali");
table.addCell("ali");
table.addCell("ali");
table.addCell("ali");
table.addCell("ali");
table.addCell("ali");
table.addCell("ali");
doc.add(table);
来源:https://stackoverflow.com/questions/8804585/itext-table-rowspan-for-right-to-left-directionarabic