如何在Apache FOP中设置默认语言 [英] How to set the default language in Apache FOP

查看:192
本文介绍了如何在Apache FOP中设置默认语言的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Apache FOP 2.1生成PDF文件.

I'm generating PDF files using Apache FOP 2.1.

为此,我尝试将默认语言设置为英语.
应该在创建PDF后通过Adobe Reader的选项文件/属性/高级/阅读选项"对此进行验证.该值当前为空.

For this I am trying to set the default language to be English.
This is supposed to be verified after the creation of the PDF via Adobe Reader's option File/Properties/Advanced/Reading Options. This value currently is empty.

我尝试在fo:root元素,页面的第一个页面顺序或.xsl文件的第一个元素中设置xml:lang="en".

I have tried setting xml:lang="en" in fo:root element, in first page-sequence or in the very first element of the .xsl file... Nothing seams to do the trick.

有什么建议吗?
感谢Dimitris.

Any Advice?
Thanks Dimitris.

更新:
我已经按照答案中的建议尝试了2个选项,但2个选项均无效

Update:
I have tried 2 more options as suggested in the answers, neither of the 2 worked

  1. <fo:declarations> <pdf:catalog xmlns:pdf="http://xmlgraphics.apache.org/fop/‌extensions/pdf"> <pdf:string key="Lang">en</pdf:string> </pdf:catalog>
  2. <x:xmpmeta xmlns:x="adobe:ns:meta/"> <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"> <rdf:Description rdf:about="" xmlns:dc="http://purl.org/dc/elements/1.1/"> <dc:title>the document title</dc:title> <dc:language>en</dc:language>
  1. <fo:declarations> <pdf:catalog xmlns:pdf="http://xmlgraphics.apache.org/fop/‌extensions/pdf"> <pdf:string key="Lang">en</pdf:string> </pdf:catalog>
  2. <x:xmpmeta xmlns:x="adobe:ns:meta/"> <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"> <rdf:Description rdf:about="" xmlns:dc="http://purl.org/dc/elements/1.1/"> <dc:title>the document title</dc:title> <dc:language>en</dc:language>

更新2
开始悬赏这个问题.
任何帮助,赞赏和奖励

Update 2
Have started a bounty on this question.
Any help appreciated and rewarderd

推荐答案

根据我尝试过的所有内容,adobe reader显示的文档属性"中的语言"字段与pdf中实际找到的文档语言没有多大关系(总是空的).

According to everything I've tried, the Language field in the Document Properties shown by adobe reader has not much to do with the document language actually found in the pdf (It's alway empty).

带有FOP 2.1的fo:root中的xml:lang ="zh_cn"标记足以使exiftool列出具有英语语言的文档,也足以使pdfbox中的PDFDebugger在文档目录中显示/Lang条目.是根据指定的语言pdf_reference 1.7 表3.25目录字典中的条目".

The xml:lang="en" tag in the fo:root with FOP 2.1 is sufficient for exiftool to list the document as having english language and also for the PDFDebugger from pdfbox to show the /Lang Entry in the Document catalog which is where the language is specified according to the pdf_reference 1.7 Table 3.25 "Entries in the catalog dictionary".

代码

<fo:declarations>
 <pdf:catalog 
   xmlns:pdf="http://xmlgraphics.apache.org/fop/‌extensions/pdf"‌​>
    <pdf:string key="Lang">en</pdf:string>
   </pdf:catalog>

在pdf输出中与xml:lang完全相同.

does exactly the same in the pdf output as the xml:lang.

此外,您还可以在元数据中(也在fo:declarations内部)设置语言

Additonally you can also set the language in the metadata (also inside fo:declarations)

<x:xmpmeta 
  xmlns:x="adobe:ns:meta/" 
  xmlns:dc="http://purl.org/dc/elements/1.1/" 
  xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
    <rdf:RDF>
      <rdf:Description rdf:about="">
        <dc:language><rdf:Bag><rdf:li>en</rdf:li></rdf:Bag></dc:language>

但是,如果xml:lang存在,我的fop 2.1似乎会自动设置该值.

But my fop 2.1 seems to set that too automagically if the xml:lang is there.

因此,如果有人加入可以解释Adobe阅读器中实际显示的文档语言属性的人,这将很有趣.

So it would be interesting if someone drops in who can explain what that document language property in the adobe reader actually shows.

这篇关于如何在Apache FOP中设置默认语言的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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