IText table rowspan for direction from right to left (Arabic)

My application is developed in two different versions of English and Arabic. I created a pdf table in iText with rowspan and colspan, which works fine in the English version, but doesn't work in the Arabic version of rowspan. when i use setRunDirection (3) to put arabic text in my table, setRowspan (2) does not work.

please tell me how rowspan is set here.

please help me solve this problem.

thanks

This is part of the code for the size column of table 2 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); 
+5
source share
1 answer

When I use table.setRunDirection(PdfWriter.RUN_DIRECTION_RTL) RowSpan does not work! so I delete this line and add:

 PdfPCell title_cell= new PdfPCell(new Paragraph("متن عربی")); title_cell.setRunDirection(PdfWriter.RUN_DIRECTION_RTL); table.addCell(title_cell); 

My table has 6 columns and 5 rows. The right cell in the first line is line 5. My code is 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); 
0
source

Source: https://habr.com/ru/post/1390240/


All Articles