Czech example

This is a code example of iText PDF, discover more.

25th October 2015
admin-marketing

Switch code for this example

CzechExample.java
  1. /**
  2.  * Example written by Bruno Lowagie.
  3.  */
  4. package sandbox.fonts;
  5.  
  6. import com.itextpdf.text.Document;
  7. import com.itextpdf.text.DocumentException;
  8. import com.itextpdf.text.Font;
  9. import com.itextpdf.text.FontFactory;
  10. import com.itextpdf.text.Paragraph;
  11. import com.itextpdf.text.pdf.BaseFont;
  12. import com.itextpdf.text.pdf.PdfWriter;
  13.  
  14. import java.io.File;
  15. import java.io.FileOutputStream;
  16. import java.io.IOException;
  17. import sandbox.WrapToTest;
  18.  
  19. @WrapToTest
  20. public class CzechExample {
  21.        
  22.     public static final String DEST = "results/fonts/czech.pdf";
  23.     public static final String FONT = "resources/fonts/FreeSans.ttf";
  24.    
  25.     public static void main(String[] args) throws IOException, DocumentException {
  26.         File file = new File(DEST);
  27.         file.getParentFile().mkdirs();
  28.         new CzechExample().createPdf(DEST);
  29.     }
  30.    
  31.     public void createPdf(String dest) throws IOException, DocumentException {
  32.         Document document = new Document();
  33.         PdfWriter.getInstance(document, new FileOutputStream(dest));
  34.         document.open();
  35.         Font f1 = FontFactory.getFont(FONT, "Cp1250", true);
  36.         Paragraph p1 = new Paragraph("Testing of letters \u010c,\u0106,\u0160,\u017d,\u0110", f1);
  37.         document.add(p1);
  38.         Font f2 = FontFactory.getFont(FONT, BaseFont.IDENTITY_H, true);
  39.         Paragraph p2 = new Paragraph("Testing of letters \u010c,\u0106,\u0160,\u017d,\u0110", f2);
  40.         document.add(p2);
  41.         document.close();
  42.     }
  43. }

Resources

Contact

Still have questions? 

We're happy to answer your questions. Reach out to us and we'll get back to you shortly.

Contact us
Stay updated

Join 11,000+ subscribers and become an iText PDF expert by staying up to date with our new products, updates, tips, technical solutions and happenings.

Subscribe Now