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>€</p>
    <p>áéíóúñö</p>
    <p>Japanese こんにちは</p>
    <p>Chinese 你好</p>
    <p>Korean 안녕</p>
    <p>Saudi Arabian Currency Symbol is ﷼</p>
    <h1> Saudi Arabian Currency Symbol is ﷼ </h1>                    
   <h1> Indian Currency Symbol is ₹</h1>                             
   <H1> European euro Symbol is € </h1>                               
   <h1> United States dollar symbol is $ </h1>                         
   <h1> Chinese Yuan Renminbi symbol is ¥ </h1>                       
   <h1> Kazakhstani tenge symbols is ₸ </h1>  
</body>
</html>
HTML

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

Expected: Non-ASCII characters to be printed as is.
Actual: Non-ASCII characters printing as empty squares

New contributor

Mithesh M is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.