简体   繁体   中英

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. Is it possible to achieve this using XSL-FO?

This is what I have tried now in my XSL file

   <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).

<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 .

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).

Either way, you need the PDF Images Plugin to reference PDF files as the source for fo:external-graphic or fox:external-document .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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