如何使用XSL-FO将外部pdf/txt文件嵌入到另一个文件中? [英] How to embed external pdf/txt file into another using XSL-FO?

查看:106
本文介绍了如何使用XSL-FO将外部pdf/txt文件嵌入到另一个文件中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以通过使用XSL-FO/XSLT将外部PDF或TEXT文档嵌入到主PDF中?

Is it possible to embed an external PDF or TEXT document into a master PDF by using XSL-FO/XSLT?

我有xslt样式表来生成PDF文档.但是,输入XML包含嵌入式TEXT或Base64编码的PDF文档.因此,在样式表的HTML版本中,我提取了TEXT或PDF并将其转储到磁盘上.然后在xslt中,我有这个:

I have xslt stylesheet to produce PDF documents. But, the input XML contains inlined TEXT or Base64 encoded PDF documents. So what I do in my HTML version of my stylesheet I extract the TEXT or PDF and dump it on disk. Then in the xslt I have this:

<xsl:when test='(n1:text/@mediaType="application/pdf") or (n1:text/@representation="B64")'>
    <IFRAME name='documentFrame' id='documentFrame' WIDTH='100%' HEIGHT='65%' src='{$DOC_URI}'/>
</xsl:when>

对于HTML转换,它运行良好.是否可以在PDF内实现相同的结果(嵌入文档)?我有一个用于生成pdf的XSLT,但未能实现相同的结果.

For HTML conversion it is working perfectly. Is it possible to achieve the same result (embed document) inside a PDF? I have an XSLT for pdf generation but have been unsuccessful at accomplishing the same result.

我已经尝试过像这样的Apache FOP插件( PDF图片支持):

I have tried add-ons for Apache FOP like this one (PDF Image Support):

 <fox:external-document src="my-doc.pdf"/>

显然,它仅适用于图像.

Apparently it is only for images.

有任何提示吗?

谢谢

推荐答案

所以我发现使用我以前的解决方案是可能的,我只是做得不好.在这里查看: FOP扩展

So I found it is possible using my previous solution, I was just not doing it right. Check it out here: FOP Extension

此外,这是一个使用方法的示例:

Also, here is an example of how to use it:

<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:fox="http://xmlgraphics.apache.org/fop/extensions">
    <fo:layout-master-set>
        <fo:simple-page-master master-name="A4">
            <fo:region-body/>
        </fo:simple-page-master>
    </fo:layout-master-set>
    <fo:page-sequence master-reference="A4">
        <fo:flow flow-name="xsl-region-body">
            <fo:block-container>
                <fo:block>Hello W3Schools</fo:block>    
                <fo:block>
                </fo:block>
            </fo:block-container>
        </fo:flow>
    </fo:page-sequence>

    <fox:external-document content-type="pdf" src="../example_file/test.pdf"/>
</fo:root>

这篇关于如何使用XSL-FO将外部pdf/txt文件嵌入到另一个文件中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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