Problems printing € symbol with jspdf - jspdf

I am tryng to print in my PDF document an Euro/Dollar/Pound Symbol with jsPdf,
i have a really simple piece of code like...
var doc = new jsPDF();
doc.text(10,10,'€');
And the result is just a rare words as you can see in the picture below.
how can i fix it?

They solution that i found, is just import a font that contain the € symbol...
I followed the example of this web.
Link: https://github.com/MrRio/jsPDF
inside the folder examples/js/basic.js you can see how to import a font.
remember that you have to pass a base64 code to make it works.

Related

UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in position 356: character maps to <undefined>

enter image description here
Its is a project of mobile app development by using library kivy.
after login in to the app there was a page which express feelings, I supposed to print feelings text like cotations which expressed by some great people.
But at that place I am getting so error like "UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in position 356: character maps to "
The issue is probably occurring since you did not specify a file encoding on line 55 in your main.py file as shown in your screenshot image.
I would recommend adding , encoding='utf-8' as another parameter in your call to open. If that does not work, try another file encoding.
So to be completely clear, that line should be:
with open(f"quotes/{feel}.txt", encoding='utf-8') as file:

adding a jsPDF font?

I found some information on the Internet, but it works. I get errors when I add my own font. Here the error.
Function Error output#file:///C:/Users/jspdf.debug.js line 1449 > srcScript : 1985: 87: string contains invalid character
Could you maybe share the section of your code where you add the font, it's hard to give an answer from the error.
But normally you add a font by converting a tff file to a base64 string and adding it like this:
doc.addFileToVFS('font-name.ttf', base64StringOfTffFile);
doc.addFont('font-name.ttf', 'font-name', 'normal');
doc.setFont('font-name', 'normal');

importxml of url with Hebrew returns in encoding other than UTF-8 that chrome doesn't recognize

For example, in the dummy spreadsheet (tab 'desired outcome'), under "Link 1" you will see this URL:
http://www.promotion-il.co.il/service/%5DE%5E4%5D9%5E5-%5E8%5D9%5D7-%5D7%5E9%5DE%5DC%5D9-%5DC%5E2%5E1%5E7%5D9%5DD/
However, the actual URL in UTF-8 is:
http://www.promotion-il.co.il/service/%D7%9E%D7%A4%D7%99%D7%A5-%D7%A8%D7%99%D7%97-%D7%97%D7%A9%D7%9E%D7%9C%D7%99-%D7%9C%D7%A2%D7%A1%D7%A7%D7%99%D7%9D/
The actual URL string that contains Hebrew is:
http://www.promotion-il.co.il/service/מפיץ-ריח-חשמלי-לעסקים/
I will also add that the same URL has returned with a proper UTF-8 encoding for other blog posts. (See second example in the same tab).
Why is it happening?
How can it be fixed?
Thanks in advance!
This is the solution I came up with eventually:
I saw that for the imported urls - in order to fix a broken url 2 repalcements were needed:
5D --> D7%9
5E --> D7%A
I used this formula in a separate column to achieve it:
==ARRAYFORMULA(SUBSTITUTE(SUBSTITUTE((<COLUMN WITH IMPORTED URLS HERE>),"5D","D7%9"),"5E","D7%A"))

got wrong characters encoding using pdfbox to extract text from pdf

Recently,I have to index pdf into ElasticSearch and using pdfbox to extract text from pdf, however I got wrong characters encoding like this
Ýëĭ2ĈjŬj§ė¥
1 ŋ?nij"2$ 2016£ 2Ú 5Õ,”Òªj§?ně#ij"2ě
^ë2ļŘœ A$j§?n 2016£ě#ëÖĭ2Ĉļê
2 èÅŋ?n$ 2016£ 2Ú 6ÕöĿS¿ ĿS¿ ĿS
Õ¿ ĿSÖ¿ eöĿS&غĨĘ
http://www.sse.com.cnLćĈ
A$j§Ýëĭ2ĈŘĐ
My code is exactly the same as this page says here. I try pdfbox lib version from 0.8.x to 2.0.x, but it still can not work.
Any help or advice will be grateful!
I got answer from #Tilman comment.
See pdfbox.apache.org/1.8/faq.html#notext and the answer below too.

Adding symbols to word document using docx4j

I am trying to add a Wingdings symbol using the following code to the docx.
P symp = factory.createP();
R symr = factory.createR();
Sym sym = factory.createRSym();
sym.setFont("Wingdings");
sym.setChar("FOFC");
symr.getContent().add(sym);
symp.getContent().add(symr);
mainPart.getContent().add(symp);
I get invalid content errors on opening the document. When I tried to add the symbols directly to a word docx, unzipped the docx and looked at the document.xml, I see the paragraph has rsidR and rsidDefault attributes. When I read about these attributes from this link, How to generate RSID attributes correctly in Word .docx files using Apache POI?, I see that they are random and only necessary to track changes in the document. So then, why does Microsoft word keeps expecting it and gives me the errors?
Any ideas/suggestions?
I wonder whether Sym support is in docx4j in the way you expect.
I tried your code and got the same issue, but I must confess to not having investigated symbols before. As an experiment, I added a symbol using the relevant “Insert” menu command in Word 2010, and then checked the resulting OpenXML—it’s really quite different to the mark-up expected when inserting an Sym element.
Rather than manipulating symbols, have you tried inserting the text directly instead? For example, this will insert a tick character (not sure if that’s what you’re after):
P p = factory.createP();
R r = factory.createR();
RPr rpr = factory.createRPr();
Text text = factory.createText();
RFonts rfonts = factory.createRFonts();
rfonts.setAscii("Wingdings");
rfonts.setCs("Wingdings");
rfonts.setHAnsi("Wingdings");
rpr.setRFonts(rfonts);
r.setRPr(rpr);
text.setValue("\uF0FC");
r.getContent().add(text);
p.getContent().add(r);
mainPart.getContent().add(p);

Resources