Write arabic text in a pdf file

Hello,

I am using aspose-pdf-4.3.0 with the below code to create a pdf file with arabic text:
Pdf pdf = new Pdf();
Section sec = pdf.getSections().add();
sec.getParagraphs().add(new Text(“مرحبا”));
pdf.save(“C:\Users\cam.EVER-ME\Desktop\test.pdf”);

The problem is that the pdf file created is empty, if i change the arabic word to a latin word, the pdf is well created.

Am i missing something?

Hi karine,

Thanks for contacting support.

Please try using the following code snippet to generate the correct output. For your reference, I have also attached the resultant PDF generated with Aspose.Pdf for Java 4.5.1.

Pdf pdf = new Pdf();
Section sec = pdf.getSections().add();

aspose.pdf.Text text1 = new Text("مرحبا");
text1.getTextInfo().isRightToLeft(true);
sec.getParagraphs().add(text1);

pdf.setUnicode();
pdf.save("C:\\pdftest\\Arabic_test.pdf");