FOP XSL-FO锚在外部目标中 [英] FOP XSL-FO Anchor in an external destination

查看:127
本文介绍了FOP XSL-FO锚在外部目标中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用XSL-FO(Fop),我成功创建了到外部PDF的链接:

With XSL-FO (Fop), I succeeded in creating a link to an external PDF :

<fo:basic-link show-destination="new">
<xsl:attribute name="external-destination">foo.pdf</xsl:attribute>
</fo:basic-link>

但是,现在,我想在此外部PDF中找到一个定位点.所以我试图建立这样的东西:

But now, I would like to reach an anchor in this external PDF. So I tried to build something like that :

<fo:basic-link show-destination="new">
<xsl:attribute name="external-destination">foo.pdf#anchorId</xsl:attribute>
</fo:basic-link>

不幸的是,当我单击生成的链接时,出现错误.它将尝试打开文档 foo.pdf%23anchorId .

Unfortunately, when I click on the generated link, I get an error. It tries to open the document foo.pdf%23anchorId.

在我的.fo文件中,链接用#正确,但是在转换PDF时会误解此#.

In my .fo file, the link is correct with a # but this # is misinterpreted during the transformation in PDF.

您有解决此问题的想法吗?

Do you have an idea to solve this issue ?

谢谢

约翰

推荐答案

对于FOP,我们有两个链接:内部链接和外部链接.

For FOP we have two of link: Internal and External.

对于外部,您可以使用:

For External you may use:

   <fo:basic-link 
    external-destination="url('http://www.paulmccartney.com')" 
    color="blue" text-decoration="underline">
     Paul McCartney
   </fo:basic-link>

和内部链接是从文档中一个位置到同一文档中另一个位置的链接.创建内部链接有两个步骤:

and Internal links are links from one location in a document to another location in the same document. There are two steps to creating internal links:

首先,为要链接的位置提供唯一的ID. ID是使用id属性指定的.该值可以硬编码或生成.在下面的示例中,我们使用generate-id()XSLT函数生成ID:

First, Give a unique ID to the location being linked to. IDs are specified with the id attribute. The value can be hard coded or generated. In the example below, we use the generate-id() XSLT function to generate IDs:

<fo:block font-weight="bold" font-size="larger" 
 id="{generate-id(.)}" break-before="page">
  <xsl:value-of select="."/>
 </fo:block>

第二,创建指向该位置的链接.与外部链接一样,内部链接也是使用标签创建的.内部目标属性应设置为文档中其他位置的ID值.

Second, Create the link to that location. As with external links, internal links are created with the tag. The internal-destination attribute should be set to the value of an ID elsewhere in the document.

<fo:basic-link internal-destination="{generate-id(.)}">
 <xsl:value-of select="."/>
</fo:basic-link>

我认为您没有在'external-destination'属性中添加'url'关键字

I think you missed to include 'url' keyword in 'external-destination' attribute

这篇关于FOP XSL-FO锚在外部目标中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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