FOP XSL-FO 锚定在外部目的地 [英] FOP XSL-FO Anchor in an external destination

查看:42
本文介绍了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>

其次,创建指向该位置的链接.与外部链接一样,内部链接也是用标签创建的.internal-destination 属性应设置为文档中其他位置的 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天全站免登陆