How to embed external pdf/txt file into another using XSL-FO?

拜拜、爱过 提交于 2019-12-04 07:44:29

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>

code-gijoe a very late response since I just started using fop, but you can do (with FOX extension)

    <fo:block-container absolute-position="absolute">
        <fo:block>
            <fo:external-graphic src="src/main/resources/externalpdf/test.pdf"/>
            <fo:block-container absolute-position="absolute" left="0pt" top="100pt" right="200pt" bottom="270pt">
                <fo:block font-weight="bold" font-size="15pt" border="{$border}" text-align="center" line-height="18pt" font-style="italic">
                    Hello
                </fo:block>
            </fo:block-container>
        </fo:block>
    </fo:block-container>

to embed it to the same page and overlay it with some text

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!