0

I am Convert a XSLT to PDF with Chinese characters in it. I am using Fonet.dll and csharp . I have added Chinese language's i.e. ZH and ZHT in the regional languages under control panel.

I am following the code example to generate the pdf

The XSLT is as follows

<?xml version="1.0" encoding="gb2312"?>
<xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:fo="http://www.w3.org/1999/XSL/Format"  >
  <xsl:template match="/" >

    <fo:root xml:lang="en"
        xmlns:fo="http://www.w3.org/1999/XSL/Format" >
      <fo:layout-master-set>
        <fo:simple-page-master page-height="350mm"
                               page-width="271mm"
                               master-name="PageMaster">
          <fo:region-body />
        </fo:simple-page-master>
      </fo:layout-master-set>
      <fo:page-sequence master-reference="PageMaster">
        <fo:flow flow-name="xsl-region-body" >

          <fo:block  font-family="MingLiU">
             hello-  您好
          </fo:block>
          <fo:block font-family="MS Mincho"
            >カニ入りスープなしの麺をください。</fo:block>
        </fo:flow>
      </fo:page-sequence>
    </fo:root> 
  </xsl:template>
</xsl:stylesheet>

The Chinese characters do not appear at all I all set the encoding to encoding="gb2312" but it did not make any difference.

Is there are a way I can embed the fonts in the XSLT so that the Chinese characters appear.

C. M. Sperberg-McQueen
  • 24,596
  • 5
  • 38
  • 65
user1339913
  • 1,017
  • 3
  • 15
  • 36

2 Answers2

0

Probably your output does not use the right encoding. You can set the output encoding with

<xsl:output encoding="gb2312" />
cvesters
  • 678
  • 5
  • 14
  • Thank you for the suggestion but it did not make any difference the Chinese characters are still missing. – user1339913 Feb 05 '16 at 16:09
  • Are you sure that the program you use to create the PDF can handle the encoding? Can we see the FO output? – cvesters Feb 06 '16 at 12:48
0

This is probably a matter of font configuration, not of character encoding.

Provided that the fonts you want to use are effectively supported (the website states that FO.NET "supports TrueType and TrueType flavoured OpenType fonts"), you have to tell the formatter where they are (if the formatter does not automatically looks for them in the default system font folders) and how to use them: either reference them, embed the whole font in the PDF, or embed just the needed subset.

I have no direct experience using FO.NET, but according to this documentation page about fonts you need something like this in your code (you probably want to embed / subset the Chinese fonts):

FonetDriver driver = FonetDriver.Make();
driver.Renderer = RendererEngine.PDF;

// Font embedding/linking is set via PdfRendererOptions class
PdfRendererOptions options = new PdfRendererOptions();

// Use FontType enumeration to specify either Link, Embed or Subset
//options.FontType = FontType.Link;
options.FontType = FontType.Embed;
//options.FontType = FontType.Subset;

driver.Options = options;
lfurini
  • 3,729
  • 4
  • 30
  • 48