Guest User

Untitled

a guest
Jul 22nd, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. public class MyClass {
  2. public static void main(String[] args) throws DocumentException, IOException {
  3. Document document = new Document();
  4. document.setPageCount(1);
  5.  
  6. PdfWriter.getInstance(document,
  7. new FileOutputStream("/home/matrix/SimpleImages.pdf"));
  8. document.open();
  9.  
  10. URL verdanaUrl = MyClass.class.getResource("verdana.ttf");
  11.  
  12.  
  13. BaseFont bf = BaseFont.createFont(verdanaUrl.getPath(), BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
  14.  
  15. PdfPTable table = new PdfPTable(2); // Code 1
  16.  
  17. // Code 2
  18. PdfPCell userInfo = new PdfPCell(new Paragraph("Потребител", new Font(bf, 10)));
  19. userInfo.setBackgroundColor(BaseColor.GRAY);
  20. userInfo.setBorder(5);
  21. table.addCell(userInfo);
  22.  
  23. PdfPCell contractInfo = new PdfPCell(new Paragraph("Клиент",new Font(bf, 10)));
  24. contractInfo.setBackgroundColor(BaseColor.GRAY);
  25. contractInfo.setBorder(5);
  26. table.addCell(contractInfo);
  27.  
  28.  
  29. // Code 3
  30. table.addCell("3");
  31. table.addCell("4");
  32.  
  33. // Code 4
  34. table.addCell("5");
  35. table.addCell("6");
  36.  
  37. // Code 5
  38. document.add(table);
  39.  
  40. document.close();
  41. }
  42. }
Add Comment
Please, Sign In to add comment