bpampuch / pdfmake

Client/server side PDF printing in pure JavaScript
http://pdfmake.org
Other
11.7k stars 2.04k forks source link

Right to left language (RTL) #184

Open eladsof opened 9 years ago

eladsof commented 9 years ago

Hi,

Is there support for right to left language? I was able to change the font but the letter are written in the wrong order (LTR).

ammarmohamed2016 commented 1 year ago

Any updates about this issue?

ElHawary-Ebutler commented 1 year ago

My Solution is

Create a helper function that takes a text and return it formatted while reversing the rtl language Arabic: `export function handleArabicCharacters(message: string) { let arabic = []; let english = [];

var regex = new RegExp( "[\u0600-\u06ff]|[\u0750-\u077f]|[\ufb50-\ufc3f]|[\ufe70-\ufefc]" );

arabic = message.split(" ").filter((e) => regex.test(e)); english = message.split(" ").filter((e) => !regex.test(e)); return ${english.join(" ")} ${arabic.reverse().join(" ")}; }`

then import it and use it inside the docDefinition obj like this

columns: [ { text: 'Remarks:', style: { alignment: 'left', bold: true, fontSize: 11 }, margin: [0, 6, 0, 3], width: 70, }, { text:${handleArabicCharacters(orderData?.order_remarks)}, style: { alignment: 'right', font: 'Arial', fontSize: 10 }, margin: [0, 6, 0, 3], }, ],

Change the regex to match the language needed. I hope this can help
ammarmohamed2016 commented 1 year ago

It's working fine for string but still facing issue in layout direction . Capture

20Abd01 commented 1 year ago

I have been facing this problem for two years and it has not been resolved yet. Do I have to search for another tool? The problem has existed since 2015. This is very bad. Why don't you solve the problem? @liborm85

saghishiri commented 10 months ago

+1

mahyabagheri commented 10 months ago

+1

alikehel commented 9 months ago

+1

itaisir commented 8 months ago

why this issue is not fixed ?

liborm85 commented 8 months ago

@itaisir Try read my post above.

saleh-esmaili commented 2 months ago

Wow. About 9 years since the start of topic, still no update for RTL layouts and language. It would be great if this option added.