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
jspdf justify arabic text #1660
Comments
Justifying utf8 text is not possible. Please provide complete code you wrote to generate the pdf and the generated file. |
I solved it manually by edit of jspdf.js
|
if (align === "right") { //The passed in x coordinate defines the //rightmost point of the text. left = x - maxLineLength; x -= lineWidths[0]; text = []; for (var i = 0, len = da.length; i < len; i++) { delta = maxLineLength - lineWidths[i]; if (i === 0) { newX = x *k; newY = (pageHeight - y)*k; } else { newX = (prevWidth - lineWidths[i]) * k; newY = -leading; } //this is my code if(i === len-1){ text.push([da[i], newX-21, newY]); prevWidth = lineWidths[i]; }else{ text.push([da[i], newX, newY]); prevWidth = lineWidths[i]; } //end } } |
you manually wrote -21 to newX? |
yes if that allowed :) |
issue not solved yet return the same problem if I changed a length of string |
I wrote already what I need: |
PR :
|
Hello @arasabbasi I tried to add arabic To my page doc.setLanguage('ar-SA') Language 'ar-SA' form this => file https://github.com/MrRio/jsPDF/blob/master/plugins/arabic.js I use angular 5 framework + typescript Result after save >> Please help me to Thank you keep up the good work |
I started debugging .... |
@Abdullah-FAl |
Please tell me how to download the latest version of jsPDF 1.4.0 #1654 Thank you for quick reply |
How to give me an example ؟ ## Documentation |
https://github.com/MrRio/jsPDF/blob/master/tests/unicode/arabic.spec.js Btw. I committed right now a bugfix to repair the arabic plugin. Please refresh and rebuild. |
|
git pull origin master |
Oh Ok |
any update for justifing of arabice text |
@saadss1990 |
:( thanks |
When the next stable release will be available via |
sounds good 👍 |
@saadss1990 i saw that you have successfully added Arabic text. while i keep getting foreign symbols. var doc = new jsPDF();
doc.setFont('NafeesNastaleeq '); // set font
doc.text("مرحبا", 20, 20, { maxWidth: 250, align: "right", lang: 'ar' })
doc.save('sample.pdf'); |
Hello @ahawary92
Thank God with the help of my brother @arasabbasi Result after save >> |
Right now i am more worried about the right alignment, which doesnt work as expected, if you use maxWidth parameter.... |
@arasabbasi How to generator base64 |
I know now why the alignment doesnt work... it is a little bit tricky... |
Fixed the right alignment hopefully with PR #1669 But somehow, if I write two times with arabic font in Acrobat Reader only one arabic text is shown :( @saadss1990 So I am not writing the justification-nethod for Unicode-text. |
hello i get doc.addFileToVFS is not a function ? why it happend ? |
@arasabbasi |
Hello @arasabbasi `const doc = new jsPDF();
i want to mention that i'm working in angular 6 application here is the result: the second column from left is arabic words but rendered as html i hope that there is a solution for this |
Hello @DevMahmoudFawzy first the bad news: fromHTML is deprecated so I wont touch the code of it anymore. Right now I work for the next release to have a different html method based on html2canvas, which will take away alot of the html-parsing. |
thanks for the reply and keeping me updated about the new stuff. |
Hello @arasabbasi |
html2pdf solved the problem for me.. but the only issue with it which i personally can live with it is that it render the html as an image in pdf so you can not copy the text or something like that. the source code i posted as an answer on stackOverFlow here https://stackoverflow.com/questions/51289430/adding-a-utf-8-font-to-jspdf-library-to-print-utf-8-arabic-pdfs-in-angular-appli/53636468#53636468 |
so i'm, arabic text doesn't appear correctly. |
yes but this solution for .text() but fromHTML() is not working :( any luck please ? |
@Abdullah-FAI I have an issue in the environment.base64 give an error any idea ? |
@Uzlopak any update regarding support html() for the Arabic language? |
@ramyrgab not that I know of, any help is welcome, though :) |
Thank you @HackbrettXXX, I have an issue in html method with Arabic font, it's not correct, |
I guess the problem is that the content of the page has to be piped through bidiEngine and the arabicParser to the .html-method. I touched the code like 2-3 years ago the last time. --- redacted to avoid implementation --- |
Even without the proposed change, arabic works as expected: https://raw.githack.com/Uzlopak/jsPDF-arabic-test/main/arabic.html So what is the real issue here?! |
This issue is stale because it has been open 90 days with no activity. It will be closed soon. Please comment/reopen if this issue is still relevant. |
Hi, I think I have the same problem, I wan't to make an arabic pdf, but I don't know what is the issue because I set the language to 'ar-SA' and added fonts but still doesn't appear to work! |
@Joseph42A please provide more information: jspdf version, code snippets, etc. |
How to specify the font you want to use?
|
i solved it with html also
|
I have an issue with justifying Arabic I add algin "right" it work with me but there is small issue the last line not fit with paragraph
@arasabbasi
The text was updated successfully, but these errors were encountered: