BookStackApp / BookStack

A platform to create documentation/wiki content built with PHP & Laravel
https://www.bookstackapp.com/
MIT License
15.32k stars 1.91k forks source link

Error rendering some UTF8 characters on PDF export #719

Open junlicn opened 6 years ago

junlicn commented 6 years ago

For Feature Requests

Desired Feature:

For Bug Reports

Expected Behavior

image

Current Behavior

image

Steps to Reproduce

after installation, login as admin, write chinese , then export from webpages.

ssddanbrown commented 6 years ago

@junlicn Thanks for reporting. Issue confirmed and marked to be fixed for next release.

ssddanbrown commented 6 years ago

Updating the title of this so mulitple issues of the same cause can be merged down into this one.

ssddanbrown commented 6 years ago

So I've had deeper dive into this. Unfortunately supporting all languages looks like it's going to be tricky and I don't really want to include many MB's of font files in the code.

As mentioned within #730 and #746, Using the WKHTML instead of the default DOMPDF to render PDF's will allow much easier support of fonts in addition to better rendering overall. Details of changing to WKHTML can be found in the docs here.

I have made a small tweak in b42b07179fb95b0ffdc370a0e8fa1136b97be364 which should increase default support but I know it doesn't cover Japanese/Chinese characters.

nekromoff commented 6 years ago

Does not work.  i have installed wkhtmltopdf and added it via .env file / correct path and all I get is this: obrazok

obrazok

nekromoff commented 6 years ago

Also, this bug applies to extended set of ASCII - e.g. Central European characters such as ľščťžýáíéúô etc.

nekromoff commented 6 years ago

Based on this, it is just an issue of a selected font: https://stackoverflow.com/questions/16384517/dompdf-character-encoding-utf-8

nekromoff commented 6 years ago

Basically, this fixes the bug for extended ASCII - European characters: setting all fonts in /vendor/dompdf/dompdf/lib/fonts/dompdf_font_family_cache.dist.php to:

DejaVuSans
DejaVuSans-Bold

etc.

ssddanbrown commented 6 years ago

@nekromoff Yeah, WKHTML can be tricky to set up correctly.

In the latest update, Released yesterday, There have been some updates made to DOMPDF exports to increase support but there's a limit to how much we can support without including a large amounts of fonts.

jasoncheng7115 commented 6 years ago

I think this should be the font setting problem, such as the default ubuntu font "DejaVuSans", which is not Chinese.

lkaybob commented 3 years ago

For those who've ended up here to find how to resolve non-English characters missing problem on exported PDF file, try these steps. (I was able to have my Korean page properly exported using wkhtmltopdf.)

  1. Make sure Bookstack uses fonts that supports your language by changing Custom HTML Head Content settings.
    • For example, I used IBM Plex Sans KR.
      <link href='https://fonts.googleapis.com/css?family=IBM+Plex+Sans+KR' rel='stylesheet' type='text/css'>
      <style>
      body, button, input, select, label, textarea {
      font-family: 'IBM Plex Sans', sans-serif;
      }
      </style>
  2. Get a font file that you've set as font-family, and save it to system's default font directory.
    • To make sure if it's installed properly, run fc-list and check if the font is on the list.

To save your time, I recommend using Google Web Fonts Helper to download font files.

akahan989 commented 1 year ago

For those who've ended up here to find how to resolve non-English characters missing problem on exported PDF file, try these steps. (I was able to have my Korean page properly exported using wkhtmltopdf.)

  1. Make sure Bookstack uses fonts that supports your language by changing Custom HTML Head Content settings.
  • For example, I used IBM Plex Sans KR.
    <link href='https://fonts.googleapis.com/css?family=IBM+Plex+Sans+KR' rel='stylesheet' type='text/css'>
    <style>
    body, button, input, select, label, textarea {
      font-family: 'IBM Plex Sans', sans-serif;
    }
    </style>
  1. Get a font file that you've set as font-family, and save it to system's default font directory.
  • To make sure if it's installed properly, run fc-list and check if the font is on the list.

To save your time, I recommend using Google Web Fonts Helper to download font files.

This worked for me, Thank you!!!! and don't forget fc-cache -fv