Good day,
I am trying to implement support for Arabic text in a PDF document (RTL direction, bi-directional fonts, etc.). For Word documents, there is an option to set the paragraph direction and specify bi-directional parameters like this:
for (com.aspose.words.Paragraph paragraph : paragraphs) {
paragraph.getParagraphFormat().setBidi(true);
for (Run run : paragraph.getRuns()) {
run.getFont().setName(ARABIC_FONT_NAME);
run.getFont().setLocaleIdBi(ARABIC_LOCALE_ID);
}
}
It doesn’t apply right to left direction for arabic text when I do textFragment.setText().
for (TextFragment textFragment : textFragmentCollection) {
if (textFragment.getText() != null && !textFragment.getText().trim().isEmpty()) {
String srcText = textFragment.getText().trim();
String destText = dictionary.get(srcText); // Ensure the dictionary has Arabic translations
try {
if (destText != null) {
if (targetLocaleId != null) {
textFragment.getTextState().setFont(arabicFont);
}
textFragment.setText(destText);
}
} catch (Exception e) {
log.error("Replace text failed for srcText={}, destText={}", srcText, destText, e);
}
}
}
Also, for some texts it throws an error:
com.aspose.pdf.internal.ms.System.l7k: Format of font "Symbol" is not supported for new composite fonts
at com.aspose.pdf.internal.l7t.lj.lf(Unknown Source)
at com.aspose.pdf.internal.l7t.lj.<init>(Unknown Source)
at com.aspose.pdf.internal.l8j.lf.lI(Unknown Source)
at com.aspose.pdf.internal.l7t.l1p.lI(Unknown Source)
at com.aspose.pdf.internal.l7v.lu.lI(Unknown Source)
at com.aspose.pdf.internal.l7p.lI.lI(Unknown Source)
at com.aspose.pdf.internal.l7j.lI.lI(Unknown Source)
at com.aspose.pdf.TextSegment.setText(Unknown Source)
at com.aspose.pdf.TextFragment.setText(Unknown Source)
This error happens on ubuntu only. On MacOS it’s ok
The issue can be related to the fonts as some fonts are differently distributed for Linux like operating systems. Nevertheless, can you please share the Arabic Text that you are adding and the Font name which you are using? We will log an investigation ticket and share the ID with you.
@asad.ali the text I add varies. Sometimes it’s Arabic, and sometimes it’s regular text like ‘Thank you.’
The font used is Noto Naskh Arabic (installed on the Ubuntu system).
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.
Issue ID(s): PDFJAVA-44368
You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.
The ticket has recently been logged in our issue tracking system and it will be investigated/resolved on a first come first serve basis. As soon as we make some progress towards its resolution, we will inform you. Please be patient and spare us some time.
Hi Asad, I hope you’re doing well.
I would like to know about the status of the ticket.
Primarily, I am interested in RTL support (for the Arabic language).
Do you have any updates or an estimated timeline for its completion?
We are afraid that the ticket has not been yet resolved due to other issues in the queue. However, your comments have been recorded under the ticket and we will surely inform you as soon as we make some progress towards ticket resolution. Please spare us some time.
It is only used to set the reading direction of the document. However, for your specific requirements, investigation ticket has already been logged and we will inform you as soon as we make some progress towards ticket resolution. Please be patient and spare us some time.