Bug in converting Text file (RTL-Hebrew language) to PDF format

Hello.

I have tried to convert a simple text file (RTL-formatted in Hebrew language) to PDF format.
I am attaching the original text file (Example.txt) and the PDF result (PDFfromTxt.pdf).

Thanks,
Alex.

Hi Alex,

Thanks for your inquiry. In your case, please specify the Hebrew encoding that will be used to load your text file as follows:

Aspose.Words.LoadOptions loadOptions = new Aspose.Words.LoadOptions();
loadOptions.LoadFormat = LoadFormat.Text;
loadOptions.Encoding = Encoding.GetEncoding(1255);
Document doc = new Document(@"C:\Temp\Example.txt", loadOptions);
doc.Save(@"C:\temp\out.pdf");

I hope, this helps.

Best regards,

Hello.

I have applied Text and Encoding settings, as you suggested, and now I can see the converted text in Hebrew, but the RTL problem is still here - the text is left-aligned (instead of right-aligned) and there is a mess with words and dots order in the sentence.

I am attaching the origin (text) and the result (pdf) files.

Thanks,
Alex.

Hi Alex,

Thanks for the additional information.

Please note that Aspose.Words’ page layout engine tries to mimic the way the Microsoft Word’s page layout engine works. To you, this means that if you convert your text file into PDF format using Aspose.Words, the output will appear almost exactly as if it was done by Microsoft Word. Since, Microsoft Word also aligns your text to the left in PDF and Aspose.Words does the same; however, you can programmatically alter this default behaviour by using the following code snippet.

Aspose.Words.LoadOptions loadOptions = new Aspose.Words.LoadOptions();
loadOptions.LoadFormat = LoadFormat.Text;
loadOptions.Encoding = Encoding.GetEncoding(1255);
Document doc = new Document(@"C:\Temp\Example.txt", loadOptions);
foreach(Paragraph para in doc.GetChildNodes(NodeType.Paragraph, true))
    para.ParagraphFormat.Bidi = true;
doc.Save(@"C:\temp\outRTL.pdf");

Secondly, since Hebrew is not my native language, could you please investigate the attached outRTL.pdf document if the result produced by the above code is acceptable for you?

Thanks for your cooperation.

Best regards,

Hello.

After adding paragraphs treatment code, the conversion to PDF works properly and the the result produced in the attached outRTL.pdf is acceptable for us.
Thank you very much for your detailed support.

Alex.

Hi Alex,

Thanks for your feedback. Please let us know any time you have any further queries. We are always glad to help you.

Best regards,