How to display Arabic strings from RTL in PDF generated using itext 7 API?

后端 未结 1 988
终归单人心
终归单人心 2020-12-12 03:07

I\'m struggling with this problem for hours now but I can\'t find a way out, the problem is that:

I wrote a program that generate a pdf file using itext version 7 (a

相关标签:
1条回答
  • 2020-12-12 03:25

    Step 1: load pdfCalligraph and licensekey jars into your classpath

    Step 2: load license key from xml file:

    LicenseKey.loadLicenseFile("itextkey-typography.xml");
    

    Step 3: Create your Document as usual:

    Document document = new Document(new PdfDocument(new PdfWriter(outFileName)));
    
    PdfFont bf = PdfFontFactory.createFont(ARABIC_FONT, PdfEncodings.IDENTITY_H);
    document.setFont(bf);
    
    document.add(new Paragraph(ARABIC_TEXT).setTextAlignment(TextAlignment.RIGHT));
    
    document.close();
    
    0 讨论(0)
提交回复
热议问题