title: Problem converting HTML with Japanese character To PDF using java with YaHP Html to Pdf Converter
body: <p>I'm trying to convert html string with Japanese character to PDF using YaHP Html to Pdf Converter.</p>
  <p>I am using Eclipse Photon Release (4.8.0)</p>
  <p>Here is my main class that invokes the YaHP Html :</p>
  <pre><code>public static void main(String[] args) {
      
      String pdfOutFileName = &quot;C:\\test\\JP-Test.pdf&quot;;
      double pageHeight = 80;
      String htmlContent = &quot;&lt;html&gt;\r\n&quot; + 
              &quot;   &lt;head&gt;\r\n&quot; + 
              &quot;       &lt;meta http-equiv=Content-Type content=\&quot;text/html; charset=UTF-8\&quot;&gt;\r\n&quot; + 
              &quot;           &lt;style type=\&quot;text/css\&quot;&gt;\r\n&quot; + 
              &quot;               span.cls_005hr{font-family:Arial,serif;font-size:16.8px;color:rgb(50,50,50);font-weight:normal;font-style:normal;text-decoration: none}\r\n&quot; + 
              &quot;               div.cls_005hr{font-family:Arial,serif;font-size:14.8px;color:rgb(50,50,50);font-weight:normal;font-style:normal;text-decoration: none}\r\n&quot; + 
              &quot;           &lt;/style&gt;\r\n&quot; + 
              &quot;       &lt;/head&gt;\r\n&quot; + 
              &quot;       &lt;body&gt;\r\n&quot; + 
              &quot;                   &lt;table border=0 cellpadding=0 cellspacing=0 width=720&gt;\r\n&quot; + 
              &quot;                    &lt;col width=10 &gt;\r\n&quot; + 
              &quot;                    &lt;col width=710 &gt;\r\n&quot; + 
              &quot;                    &lt;tr&gt;\r\n&quot; + 
              &quot;                     &lt;td valign=\&quot;middle\&quot; height=\&quot;80\&quot; bgcolor=\&quot;#f0f0f0\&quot;&gt;\r\n&quot; + 
              &quot;                       &lt;div&gt;&lt;span class=\&quot;cls_005hr\&quot;&gt;JPTesting&lt;/span&gt;&lt;/div&gt;\r\n&quot; + 
              &quot;                     &lt;/td&gt;\r\n&quot; + 
              &quot;                     &lt;td valign=\&quot;middle\&quot; height=\&quot;80\&quot; bgcolor=\&quot;#f0f0f0\&quot;&gt;\r\n&quot; + 
              &quot;                       &lt;div&gt;&lt;span class=\&quot;cls_005hr\&quot;&gt;株式会社　ビー・エス・デーインフォメーションテクノロジー&lt;/span&gt;&lt;/div&gt;\r\n&quot; + 
              &quot;                     &lt;/td&gt;\r\n&quot; + 
              &quot;                   &lt;/span&gt;\r\n&quot; + 
              &quot;                    &lt;/tr&gt;\r\n&quot; + 
              &quot;                   &lt;/table&gt;\r\n&quot; + 
              &quot;       &lt;/body&gt;\r\n&quot; + 
              &quot;&lt;/html&gt;&quot;;
      
      System.out.println(&quot;htmlContent: [&quot; + htmlContent + &quot;]&quot;);
  
      try {
          ByteArrayOutputStream outFormPDF = new ByteArrayOutputStream();
          outFormPDF = PDFUtil.convertHtmlToPDF(htmlContent, pageHeight);
          byte[] bOutFormPDF = outFormPDF.toByteArray();
          
          OutputStream os = new FileOutputStream(pdfOutFileName);
          os.write(bOutFormPDF);
          System.out.println(&quot;Successfully Finished writing PDF to output file&quot;);
          os.close();
  
      } catch (Exception e) {
          System.out.println(e.getMessage());
      }
  </code></pre>
  <p>and here is the PDFUtil class method that calls YaHP Converter</p>
  <pre><code>public static ByteArrayOutputStream convertHtmlToPDF (String htmlContent, double pageHeight) throws CConvertException, IOException {
  
      ByteArrayOutputStream outFormPDF = new ByteArrayOutputStream();
      Scanner scanner = new Scanner(htmlContent).useDelimiter(&quot;\\Z&quot;);
      String htmlContents = scanner.next();
  
      CYaHPConverter converter = new CYaHPConverter();
      Map properties = new HashMap();
      List headerFooterList = new ArrayList();
      
      URL resource = PDFUtil.class.getClassLoader().getResource(&quot;fonts&quot;);
      
      String fontDirectory = resource.getPath() ;
  
      properties.put(IHtmlToPdfTransformer.PDF_RENDERER_CLASS, IHtmlToPdfTransformer.FLYINGSAUCER_PDF_RENDERER);
      properties.put(IHtmlToPdfTransformer.FOP_TTF_FONT_PATH, fontDirectory);
      
      PageSize pageSize = IHtmlToPdfTransformer.LEGALP;
  
      if (pageHeight&gt;0) {
          String sHeight = Double.toString(pageHeight);
          sHeight = sHeight.substring(0,sHeight.indexOf(&quot;.&quot;));
          pageHeight = Double.parseDouble(sHeight);
          System.out.println (&quot;pageHeight : &quot; + pageHeight);
          pageSize = new PageSize(21.6d, pageHeight, 0.7d, 0.5d, 1.5d, 1.5d);
      }
              
      System.out.println (&quot;Calling converter.convertToPdf&quot;);
      converter.convertToPdf(htmlContents, 
                 pageSize, 
                 headerFooterList,
                 &quot;file://tmp/Html2PdfConvertTemp&quot;,
                 outFormPDF,
                 properties);
  
      System.out.println (&quot;Successfully Called converter.convertToPdf&quot;);
      scanner.close();
      
      return outFormPDF;
  }
  </code></pre>
  <p>For some reason, the output PDF file contains &quot;JPTesting&quot;, but does not contain the Japanese letters :  &quot;株式会社　ビー・エス・デーインフォメーションテクノロジー&quot; .</p>
  <p>Any help would be much appreciated.</p>