Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tagging correctly languages / With Arabic font Adobe Acrobat Reader DC shows only first line of text on the page #1720

Closed
mgroeneweg opened this issue Apr 22, 2018 · 19 comments

Comments

@mgroeneweg
Copy link

Thank you for submitting an issue to jsPDF. Please read carefully.

Are you using the latest version of jsPDF?
Yes

Have you tried using jspdf.debug.js?
No it does not contain all necessary files like vfs.js. I don't know how the build works to create a fresh one.

Steps to reproduce
Test.zip

  • The zip file contains a test HTML.
  • Drop TestSimpleTextArabic.html in the main folder of the jsPDF folder structure and run it.
  • Click the Generate button.
  • I get the result as included in the zip

What I saw
In Chrome it works:
image
In Adobe reader it does not work:
image
With other tests, Adobe reader sometimes pops up an error that there is an issue with the document. No specific information what it does not like.

What I expected
To be able to open the PDF and see all added texts.

@Uzlopak
Copy link
Collaborator

Uzlopak commented May 7, 2018

I think i was able to fix it in the latest commit a month ago. Did you use the current code, or did you use the one i gave you once?

@mgroeneweg
Copy link
Author

mgroeneweg commented May 7, 2018 via email

@Uzlopak
Copy link
Collaborator

Uzlopak commented May 7, 2018

I will think about it, but I think we should release so that we have atleast a new base

@mgroeneweg
Copy link
Author

mgroeneweg commented May 8, 2018

I can appreciate that. However I have not seen much activity since your last commits. When will this be released?

@Uzlopak
Copy link
Collaborator

Uzlopak commented May 8, 2018

I remembered something:

What happens if you remove or comment out these lines in your jspdf


       //lang
        
        var lang = options.lang;
        
        if (lang) {
            xtra += "/Lang (" + lang +")\n";
        }

Does it show then the text completely?

@mgroeneweg
Copy link
Author

Yes now it shows all texts

@Uzlopak
Copy link
Collaborator

Uzlopak commented May 8, 2018

yeah i remember now, that it was this language tagging which i couldnt fix and i didnt found a sample for multiline

@mgroeneweg
Copy link
Author

Seems OK without it so what does it do?
Or, what do we miss without it?

@Uzlopak
Copy link
Collaborator

Uzlopak commented May 8, 2018

Well it shows that a line is in a specific language. Probably used by screen readers or translation software. I dont know.

Can you please do me a favor and just comment out the line xtra += "/Lang (" + lang +")\n";, generate with the new jspdf the test case for arabic language and post the resulting pdf here?
https://github.com/MrRio/jsPDF/blob/master/tests/unicode/arabic.spec.js

Then I could upload it to #1736 and merge it before James releases it today.

I have to go to work, and I have some modifications in my current codebase, which were fixes for this issue, but I dont know if they were good or not, and before I mess up my code, which i didnt touched for 2 months...

@mgroeneweg
Copy link
Author

I tried before to get these tests running on my machine but that failed rather miserably. I'm at work too so I generated the PDF using a hardcoded testcase, with the language tag in comment.

Test case and result are in the zipfile.
TestFor1736.zip

@alidib81
Copy link

would you please help me i get this message when i test your code :
Error in function Object.: saveAs is not defined

@Uzlopak
Copy link
Collaborator

Uzlopak commented May 11, 2018

saveAs not defined => you need FileSaver.js

@alidib81
Copy link

@arasabbasi thanks ,but when i use doc.viewerPreferences({Direction: 'R2L'});
i got error : function not defined

@Uzlopak
Copy link
Collaborator

Uzlopak commented May 12, 2018

Build the package

@alidib81
Copy link

@arasabbasi Some characters do not appear correctly,for example :الامارات looks in pdf:
uae

@alidib81
Copy link

@mgroeneweg can i use another font instead of Amiri ? and how to get base64 of the font ,for example Traditional Arabic font

@Uzlopak
Copy link
Collaborator

Uzlopak commented May 14, 2018

@alidib81 Can be... I had to write the "logic" for connecting letters all by myself and little help of other frameworks. It is kind of hard to code it and have it completely refactorable. But because I dont know if you are using the latest arabic i wont start debugging.

And yes you could use traditional arabic font. Get the ttf and use an online base64 encoder... google wll help you.

@alidib81
Copy link

alidib81 commented May 14, 2018

@arasabbasi i tried to use traditional arabic font. but i got blank page..
i use this convertor is :
https://www.giftofspeed.com/base64-encoder/
and this :https://jpillora.com/base64-encoder/
and this is my code:
var trade = "...........base64 ";
const doc = new jsPDF("p", "pt", "a4");

doc.addFileToVFS("traditional arabic.ttf", trade);
doc.addFont('traditional arabic.ttf', 'trade', 'normal');
  
doc.setFont('trade'); // set font
doc.setFontSize(10);

var testText = "الامارات العربية المتحدة ";

@Uzlopak
Copy link
Collaborator

Uzlopak commented May 14, 2018

doc.text(testText, 10, 10, {lang: 'ar'});
?

@Uzlopak Uzlopak changed the title With Arabic font Adobe Acrobat Reader DC shows only first line of text on the page Tagging correctly languages / With Arabic font Adobe Acrobat Reader DC shows only first line of text on the page May 26, 2018
@Uzlopak Uzlopak closed this as completed Jun 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants