docker-wkhtmltopdf icon indicating copy to clipboard operation
docker-wkhtmltopdf copied to clipboard

Chinese and Japanese characters not printing in 3.16.2-0.12.6-full

Open mithesh109 opened this issue 5 months ago • 1 comments

Hello, I'm stuck in an issue wherein the wkhtmltopdf prints just tofus for non-ascii characters (Chinese, Japanese, Korean etc). Can you please help me to resolve this issue.

My Dockerfile

FROM surnet/alpine-wkhtmltopdf:3.16.2-0.12.6-full as wkhtmltopdf

FROM ruby:3.0.5-alpine3.16

# RUN apk update -qq && apk add  nodejs  
#build-essential libssl-dev libyaml-dev -dev libreadline-dev openssl curl libcurl4 libcurl4-openssl-dev
RUN apk add --update \
  build-base \
  mariadb-dev \
  sqlite-dev \
  nodejs \
  tzdata \
  git \
  && rm -rf /var/cache/apk/*

# Install dependencies for wkhtmltopdf
RUN apk add --no-cache \
    libstdc++ \
    libx11 \
    libxrender \
    libxext \
    libssl1.1 \
    ca-certificates \
    fontconfig \
    freetype \
    ttf-dejavu \
    ttf-droid \
    ttf-freefont \
    ttf-liberation \
    # more fonts
  && apk add --no-cache --virtual .build-deps \
    msttcorefonts-installer \
  # Install microsoft fonts
  && update-ms-fonts \
  && fc-cache -f \
  # Clean up when done
  && rm -rf /tmp/* \
  && apk del .build-deps

COPY --from=wkhtmltopdf /bin/wkhtmltopdf /bin/wkhtmltopdf
... Rest of the content

wkthmltopdf version is wkhtmltopdf 0.12.6 (with patched qt)

This is the command I use for testing in bash terminal

wkhtmltopdf --encoding utf-8 - - > ./app/test.pdf <<HTML
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <style>
        body {
          font-family: sans-serif; /* Specify your preferred font family here */
          color: #eb1313;
        }
      </style>
</head>
<body>
    <p>&euro;</p>
    <p>áéíóúñö</p>
    <p>Japanese こんにちは</p>
    <p>Chinese 你好</p>
    <p>Korean 안녕</p>
    <p>Saudi Arabian Currency Symbol is &#65020;</p>
    <h1> Saudi Arabian Currency Symbol is &#65020; </h1>                    
   <h1> Indian Currency Symbol is &#8377;</h1>                             
   <H1> European euro Symbol is &#128; </h1>                               
   <h1> United States dollar symbol is &#36; </h1>                         
   <h1> Chinese Yuan Renminbi symbol is &#165; </h1>                       
   <h1> Kazakhstani tenge symbols is &#8376; </h1>  
</body>
</html>
HTML

The output pdf file prints tofu for the Japanese, Chinese and Korean languages. test.pdf

mithesh109 avatar Jan 15 '24 07:01 mithesh109

Please try with the newest version surnet/alpine-wkhtmltopdf:3.19.0-0.12.6-full and make sure a font with the characters you want to use is installed and correctly registered.

chdanielmueller avatar Jan 23 '24 10:01 chdanielmueller