xslt fo 不显示中文或泰文字体 [英] xslt fo does not show chinese or thai fonts

查看:33
本文介绍了xslt fo 不显示中文或泰文字体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将 XSLT 转换为包含中文字符的 PDF.我正在使用 Fonet.dll 和 csharp .我在控制面板下的区域语言中添加了中文,即ZH和ZHT.

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.

我正在按照代码示例生成pdf

I am following the code example to generate the pdf

XSLT 如下

<?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>

汉字根本不出现我都将编码设置为 encoding="gb2312" 但它没有任何区别.

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

有什么方法可以将字体嵌入到 XSLT 中,以便显示汉字.

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

推荐答案

这可能是字体配置的问题,而不是字符编码的问题.

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

如果您要使用的字体得到有效支持(该网站声明 FO.NET支持 TrueType 和 TrueType 风格的 OpenType 字体"),您必须告诉格式化程序它们在哪里(如果格式化程序没有自动查找对于它们在默认系统字体文件夹中)以及如何使用它们:要么引用它们,要么将整个字体嵌入 PDF 中,要么只嵌入所需的子集.

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.

我没有直接使用 FO.NET 的经验,但根据这个 关于字体的文档页面 你的代码中需要这样的东西(你可能想要嵌入/子集中文字体):

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;

这篇关于xslt fo 不显示中文或泰文字体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆