Bad Japanese formatting when rendering and generating in pdf

I have created an API that generates a report in pdf format in japanese language. I have added the required font-families in the css. The report looks good when I run the api in local. although when I push it to pcf and then try to run it, some japanese characters are messed up.

in local:
Bad Japanese formatting when rendering and generating in pdf

from cloud:
Bad Japanese formatting when rendering and generating in pdf

I am stuck with this problem, need help.

Thanks!

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

It seems more related to fonts, You may try:

  1. Embedding the fonts in your application and on startup copy the fonts into the $HOME/.fonts directory (which for a running application is /home/vcap/app/.fonts). You can use .profile file to copy the file form your artefact to this location.
  2. Use the font specifically in the code eg. from assets in java..something like

    GraphicsEnvironment graphenv = GraphicsEnvironment.getLocalGraphicsEnvironment();
    graphenv.registerFont(Font.createFont(Font.TRUETYPE_FONT, new File(“japanese.ttf”)));


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x