0

in my Java code, I have stored multiple user names and their Signatures into Postgresql database and I have retrieved all users data into pdf document but the problem is I should print all of users data side by side up to 4 and then it should break into the next line. i didn't understand how to break this line after 4 users data, so, can anyone please, help me how to solve this issue. Thank you.

1.code
PdfPTable userTable = new PdfPTable(users.size()/2);            
            userTable .setWidthPercentage(80.0f);   
                if (users.size() != 0) {
                        for (User j : users) {
                            
                            //User Signature
                            byte[] prSign = j.getUserSigns(); 
                            if(prSign!=null) {
                            
                                    Image signpr = Image.getInstance(prSign); //sign
                                    signpr.scaleToFit(100,80);
                                    userTable.addCell(signpr);
                            }
                            
                        }
                            for (User j : users) {
                            PdfPCell prName = new PdfPCell();
                            prName.setBorder(Rectangle.NO_BORDER);
                            prName.addElement(new Phrase(j.getUserNames()));
                            prName.setHorizontalAlignment(Element.ALIGN_CENTER);
                            userTable.addCell(prName);
                        }
                }
                doc.add(userTable);
  • 1
    Hi, can you make sure your code is runnable/reproducible? Right now the code would not compile since e.g. `users.size()` is not defined. Also, can you attach the current visual result and show/describe the desired visual result? It's much better to speak in visual representation terms to avoid misunderstanding. – Alexey Subach Dec 07 '21 at 07:05
  • 1
    Finally, have you tried iText 7? iText 5 is deprecated and no longer maintained except for security fixes – Alexey Subach Dec 07 '21 at 07:06

0 Answers0