[xep-support] Re: Using rx:insert-document

From: Kevin Brown <kevin_at_ADDRESS_REMOVED>
Date: Thu Nov 05 2015 - 10:23:51 PST

Darren:

 

It is by design. I have posted on this before.

 

rx:insert-document inserts a complete PDF *before* the page-sequence it is
on. NOTE: I have put into development a request to modify this behavior in a
later release, probably implemented by being able to specify before or after
the sequence.

 

A page-sequence in FO cannot be empty, if it is (has no content) then it is
collapsed and not processed and nothing would be created in the case you
present.

 

You can use rx:insert-document to insert a PDF at the start or in-between
page-sequences, but not at the end.

 

There are two ways you can accomplish what you desire.

 

1) If you know all there is about the document in question (meaning the
number of pages), you can use rx:pdf-page attribute to insert each page. In
the sample template I posted before, the XML had something like this:

 

<insert-document src=file://c:/temp/test.pdf <file:///c:\temp\test.pdf>
pages="6"/>

 

Then it had a template like this, that was called recursively to add an
fo:block containing the image of each page (pages holds the total pages,
curpage is an increment, src is the location of the PDF)

 

<xsl:template name="genpage">
    <xsl:param name="pages"/>
    <xsl:param name="curpage"/>
    <xsl:param name="src"/>
    <xsl:if test="$curpage &lt; ($pages + 1)">
      <fo:block line-height="0pt">
        <fo:external-graphic rx:pdf-page="{$curpage}">
          <xsl:attribute name="src">
                <xsl:value-of select="$src"/>
          </xsl:attribute>
        </fo:external-graphic>
      </fo:block>
      <xsl:apply-templates/>
      <xsl:call-template name="genpage">
        <xsl:with-param name="curpage" select="$curpage + 1"/>
        <xsl:with-param name="pages" select="$pages"/>
        <xsl:with-param name="src" select="$src"/>
      </xsl:call-template>
    </xsl:if>
  </xsl:template>

 

You could add such a template and call it at the end of the document you are
producing to append each page of a known-sized document into your document.
Now note that you also need to likely create an empty page-sequence that is
the same size as the PDF in question with no margins as this is inserting
things in the flow.

 

2) If you do not know the number of pages, then you would need a
process to insert a tag into the XEP Intermediate format at the appropriate
place (at the end). The syntax of this tag in XEP Intermediate is:

 

<xep:insert-document src="file:/C:/Users/kbrown01/Desktop/CloudFormatter
Templates/SampleMerge/EPSON009.PDF"/>

 

You would put this immediately before the </xep:document> at the end and
this would append any size PDF at the end of the document. You could in fact
use such a thing to create a simple PDF merger. You could do this and run
it:

 

<xep:document xmlns:xep="http://www.renderx.com/XEP/xep" producer="XEP
4.24.395" creator="Unknown" author="Unknown" title="Untitled">

     <xep:insert-document
src="file:/C:/Users/kbrown01/Desktop/CloudFormatter
Templates/SampleMerge/doc1.PDF"/>

     <xep:insert-document
src="file:/C:/Users/kbrown01/Desktop/CloudFormatter
Templates/SampleMerge/doc2.PDF"/>

     <xep:insert-document
src="file:/C:/Users/kbrown01/Desktop/CloudFormatter
Templates/SampleMerge/doc3.PDF"/>

</xep:document>

 

Running the XEP Intermediate file would join doc1, doc2 and doc3 into a new
document.

 

Kevin Brown

Executive Vice President, Sales & Marketing RenderX, Inc.

(650) 327-1000 Direct

(650) 328-8008 Fax

(925) 395-1772 Mobile

skype:kbrown01

 <mailto:kevin@renderx.com> kevin@renderx.com

 <mailto:sales@renderx.com> sales@renderx.com

 <http://www.renderx.com/> http://www.renderx.com

 

 

 

 

From: Xep-support [mailto:xep-support-bounces@renderx.com] On Behalf Of
Darren Munt
Sent: Wednesday, November 04, 2015 10:39 PM
To: xep-support@renderx.com
Subject: [xep-support] Using rx:insert-document

 

I've just upgraded to the latest XEP version and I'm trying to insert an
existing PDF into a document using the rx:insert-document extension. I
wasn't able to find a working example of this, if there is one I'd
appreciate a link to it. However I found a support query about it and
managed to glean the following XSL from it:

 

<fo:page-sequence master-reference="mainportrait"
rx:insert-document="url(pdfdocname.pdf)">

        <fo:flow flow-name="xsl-region-body">

<fo:block />

        </fo:flow>

</fo:page-sequence>

 

When I send this to RenderX, the resulting document does not include my
static PDF. However when I put some content in the fo:block, the static PDF
is included but so is whatever content I place in the block appears on a new
page at the end. For example:

 

<fo:page-sequence master-reference="mainportrait"
rx:insert-document="url(pdfdocname.pdf)">

        <fo:flow flow-name="xsl-region-body">

<fo:block>.</block>

        </fo:flow>

</fo:page-sequence>

 

I'm not at all sure that I have the syntax correct, but this is the only way
I have been able to get it to work so far. Could you please let me know
where I'm going wrong?

 

I have simplified my FO down to this to reproduce the behaviour:

 

<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format"
xmlns:rx="http://www.renderx.com/XSL/Extensions">

  <fo:layout-master-set>

    <fo:simple-page-master master-name="mainportrait" page-width="21.0cm"
page-height="29.7cm" margin-top="0.5cm" margin-bottom="0.5cm"
margin-left="0.5cm" margin-right="0.5cm">

      <fo:region-body margin-top="0" margin-bottom="0" margin-left="0"
margin-right="0" />

    </fo:simple-page-master>

  </fo:layout-master-set>

  <fo:page-sequence master-reference="mainportrait"
rx:insert-document="url(mypdf.pdf)">

    <fo:flow flow-name="xsl-region-body">

      <fo:block />

    </fo:flow>

  </fo:page-sequence>

</fo:root>

 

Produces a blank document.

 

<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format"
xmlns:rx="http://www.renderx.com/XSL/Extensions">

  <fo:layout-master-set>

    <fo:simple-page-master master-name="mainportrait" page-width="21.0cm"
page-height="29.7cm" margin-top="0.5cm" margin-bottom="0.5cm"
margin-left="0.5cm" margin-right="0.5cm">

      <fo:region-body margin-top="0" margin-bottom="0" margin-left="0"
margin-right="0" />

    </fo:simple-page-master>

  </fo:layout-master-set>

  <fo:page-sequence master-reference="mainportrait"
rx:insert-document="url(mypdf.pdf)">

    <fo:flow flow-name="xsl-region-body">

     <fo:block>.</fo:block>

    </fo:flow>

  </fo:page-sequence>

</fo:root>

 

Produces a document with the inserted PDF and another page at the end with a
full stop.

 

 

Thanks!

 

 

_______________________________________________
(*) To unsubscribe, please visit http://lists.renderx.com/mailman/options/xep-support
(*) By using the Service, you expressly agree to these Terms of Service http://w
ww.renderx.com/terms-of-service.html
Received on Thu Nov 5 10:16:01 2015

This archive was generated by hypermail 2.1.8 : Thu Nov 05 2015 - 10:16:18 PST