How to display arabic characters in pdf file generated using PDFBox
<p>I'm trying to display an arabic string in a pdf file generated using PDFBox, Actually i can display an arabic string from RTL using ICU4J and a specific font but the problem is this :
even if the string appear correctly from RTL the characters still separated and even if i try some fonts the problem is not solved yet.
Here is a snippet of code used for test:</p>

<pre><code>     PDDocument document = new PDDocument();
     PDPage page = new PDPage(PDRectangle.A4);
     document.addPage(page);

     String dir = "resources/fonts/";
     //I've used several fonts
     PDType0Font farialUni = PDType0Font.load(document, new File(dir + "ARIALUNI.ttf"));
     PDFont fArabType = PDType0Font.load(document, new File(dir + "arabtype.ttf"));
     PDFont fMuka = PDType0Font.load(document, new File(dir + "Mukadimah.ttf"));
     PDFont fFreeSans = PDType0Font.load(document, new File(dir + "FreeSans.ttf"));
     PDFont fNoto = PDType0Font.load(document, new File(dir + "NotoNaskhArabic-Regular.ttf"));

     PDPageContentStream stream = new PDPageContentStream(document, page);

     stream.beginText();
     stream.setFont(fNoto, 12);
     stream.setLeading(12 * 1.2);

     stream.newLineAtOffset(100, 800);
     //Switch text order from to RTL
     BiDiClass bidiClass = new BiDiClass();
     String arabicText = "\u0627\u0644\u0633\u0644\u0627\u0645 \u0639\u0644\u064A\u0643\u0645 ";

     //Use icu to inverse the order
     String out = bidiClass.makeLineLogicalOrder(arabicText, true);
     System.out.println(out);

     stream.showText(out);
     stream.newLine();

     // ligature
     stream.showText(out);

     stream.endText();
     stream.close();


     document.save("example.pdf");
     document.close();
</code></pre>

<p>The resulting string that this code give me is like this :
‫ال س ل ام‪ ‬ع ل ي ك م‪ ‬‬</p>

<p>Note: i add the space character in the resulting string only for clarity.</p>