简体   繁体   English

如何在使用XSL-FO生成另一个PDF文件的同时合并PDF文件?

[英]How To Merge a PDF File while generating another PDF file using XSL-FO?

I am generating a PDF File using XSL-FO, and I have a scenario where I need to merge a PDF file with the one I'm generating using XSL-FO. 我正在使用XSL-FO生成PDF文件,并且有一种情况需要将PDF文件与使用XSL-FO生成的文件合并。 Is it possible to achieve this using XSL-FO? 使用XSL-FO是否可以实现此目的?

This is what I have tried now in my XSL file 这就是我现在在XSL文件中尝试过的

   <xsl:template match="body">
    <xsl:for-each select="paragraph">
     <fo:block space-after="1.4em">
    <xsl:apply-templates select="d:htmlparse(., '', true())/node()"/>
        </fo:block>
    </xsl:for-each>
      <fox:external-document xmlns:fox="http://xmlgraphics.apache.org/fop/1.0/extensions"  content-type="pdf" src='./tobedssssconv.pdf'/>
    </xsl:template> 

First of all, the extension element fox:external-document is meant to be at the same level of fo:page-sequence elements, not inside an fo:flow with other block-level objects (you are probably getting some validation error while processing your file). 首先,扩展元素fox:external-document应该位于fo:page-sequence元素的同一级别,而不是在与其他块级对象的fo:flow内部(处理时可能会遇到一些验证错误)您的文件)。

<fo:page-sequence>
    <!-- .... -->
</fo:page-sequence>

<fox:external-document .... />

<fo:page-sequence>
    <!-- .... -->
</fo:page-sequence>

This way, you will have the pages generated for the first fo:page-sequence , then the pages from the "included" PDF, then the pages for the second fo:page-sequence . 这样,您将为第一个fo:page-sequence生成fo:page-sequence ,然后为“包含的” PDF中的页面生成,再为第二个fo:page-sequence

Otherwise, if you want to insert something between fo:block elements, you can use fo:external-graphic (inside an fo:block or another block-level element). 否则,如果要在fo:block元素之间插入某些内容,则可以使用fo:external-graphic (在fo:block或另一个块级元素内)。

Either way, you need the PDF Images Plugin to reference PDF files as the source for fo:external-graphic or fox:external-document . 无论哪种方式,都需要PDF Images Plugin来引用PDF文件作为fo:external-graphicfox:external-document

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM