Adding a utf-8 font to jsPDF library to print utf-8 Arabic pdfs in Angular application

I have been searching for hours to enable the UTF-8 support in jsPDF library, since it is a new feature released in jsPDF 1.4 I can’t find useful resources to enable it

I found two methods in the library addFont() & setFont() but it is not clear in the official docs how to use them to use the new font & if they depend on each other

I am specifically trying to add a font that supports Arabic, like for example (Roboto) or any basic font that support Arabic

The code that I am using (& works well with English html but not Arabic):

printAsPDF() {
    const elementToPrint = document.getElementById('report'); // The html element to become a pdf
    const pdf = new jsPDF();

    pdf.fromHTML(elementToPrint, 30, 30);'hello.pdf');

The fonts that are supported by default:(output of getFontList()):


152 thoughts on “Adding a utf-8 font to jsPDF library to print utf-8 Arabic pdfs in Angular application”

  1. Pingback: cheap stromectol
  2. Aw, this was an exceptionally good post. Spending some time and actual effort to make a top notch article… but what
    can I say… I put things off a lot and never manage to get
    nearly anything done.

  3. Hey I know this is off topic but I was wondering if you knew of any widgets
    I could add to my blog that automatically tweet my newest twitter updates.
    I’ve been looking for a plug-in like this for quite some time and
    was hoping maybe you would have some experience with something like this.

    Please let me know if you run into anything. I truly enjoy reading your blog and I look forward to your new updates.

  4. whoah this weblog is great i like studying your articles.
    Stay up the great work! You realize, many individuals are
    looking round for this information, you can help them greatly.

  5. Hey! This post could not be written any better! Reading this post reminds me of
    my previous room mate! He always kept talking about this.
    I will forward this page to him. Fairly certain he will have a good read.
    Many thanks for sharing!

  6. Pingback: is stromectol
  7. Pingback: ivermectin shampoo
  8. Pingback: viagra comparison
  9. The other day, while I was at work, my cousin stole my iphone and tested to see if it can survive a twenty five foot drop,
    just so she can be a youtube sensation. My iPad is now broken and she has 83 views.
    I know this is totally off topic but I had
    to share it with someone!

  10. Hi! I’ve been following your web site for some time now and finally got the bravery to go ahead and
    give you a shout out from Huffman Texas! Just wanted to mention keep up the good job!

  11. An outstanding share! I have just forwarded this onto a friend who was doing a little research on this.
    And he in fact bought me lunch due to the fact that I found it for
    him… lol. So let me reword this…. Thanks for the meal!!
    But yeah, thanks for spending some time to talk about this topic here on your internet site.

  12. Pretty great post. I just stumbled upon your blog and
    wished to mention that I have truly enjoyed browsing your weblog posts.

    In any case I’ll be subscribing to your rss feed and I hope you write again very soon!

  13. Hello there! I know this is kinda off topic however I’d figured I’d ask.

    Would you be interested in exchanging links or maybe guest
    authoring a blog article or vice-versa? My website
    goes over a lot of the same topics as yours
    and I feel we could greatly benefit from each other. If you are interested feel free to shoot me an e-mail.
    I look forward to hearing from you! Excellent blog by the way!

  14. I’m not sure exactly why but this weblog is loading very slow for me.

    Is anyone else having this issue or is it a issue on my end?

    I’ll check back later on and see if the problem still exists.

  15. Cool blog! Is your theme custom made or did you download
    it from somewhere? A theme like yours with a few simple adjustements would really make my blog
    stand out. Please let me know where you got your design. Cheers


Leave a Comment