[xep-support] Re: Cooltool - Bookfolding an existing PDF

From: Kevin Brown <kevin_at_ADDRESS_REMOVED>
Date: Wed Apr 01 2015 - 09:05:43 PST

Fritz:

 

Great question.

When you choose to use a page of a PDF essentially as an image, RenderX is
parsing that PDF page for all assets in the source PDF it needs to build
that specific page.

These assets could be "common" assets used amongst all pages in a PDF.

Common assets like these would include say a logo that is on every page or
the font tables for used fonts.

These are all put together such that the page can be rendered and placed in
an image tag and copied to the PDF.

 

If you take any PDF splitter that is around, say iText programming or
Acrobat or whatever and split an 8 page document in 8 single page documents,
the sum of the bytes will not add up. This is exactly what is happening
here. Each of those PDFs may need the reused information that exists in the
original whole PDF.

 

RenderX is not doing a deeper, smart copy of that - meaning it is not
analyzing all the glyphs used on *all* the pages inside the document and
*all* the other reusable assets, combining them with what may already be in
the PDF itself to come up with one font table. While this type of
calculation and extraction of content is possible, we choose not to do it
when you are using PDF as an image. Remember, this extension allows me to
select a single page from any PDF and use it. I might have 20 different PDFs
and be extracting a page from each. Combining the information across those
would be difficult and still not accurate as it would be almost impossible
to determine that a logo in one is the same logo in another.

 

If the only task was to reorganize the pages then you could do so without
wrapping things up in a self contained unit. However, that is not what the
intention of using a PDF as an image is (to us). Translation - if you only
want to bookfold a PDF, there are tools that can do that, but RenderX
software is much more than that.

 

So note well what this is designed to be and not to be. Can it be used for
bookfolding a single document like you did that has very little reused
content? Sure. Note well that documents with large embedded fonts tables and
logos on each page could be much larger than the small increase you had.
They could be 2x, 3x larger or more.

 

That said, if you are using RenderX to generate the actual PDF in question
you can bookfold the intermediate format. This is much better as you are
using RenderX to create the final PDF. The PDF backend at that time will
determine the single font table to embed and mark/reuse images that are
repeated. This is especially important in large print operations where you
may be processing an 8 page statement run, where the single print file
contains 1000 statements (8 pages each). If you bookfold this in
intermediate format and say the pages have PDF background images, you would
find one font table for the entire document and 8 images for the backgrounds
in the 8000 page document. In fact, the XSL I wrote before that bookfolds
intermediate format actually includes background injecting at that same time
so that the full spread background (potentially with crop/registration
marks) can be injected during the bookfold process and left out of the
template. In this case, you would have only 4 images (one for each spread).

 

If you are interested in that XSL, I believe I posted before but write me
and I can send to you.

 

Kevin Brown

(650) 327-1000 Direct

(650) 328-8008 Fax

(925) 395-1772 Mobile

skype:kbrown01

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

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

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

 

 

 

 

 

From: Kirch Fritz [mailto:Friedrich.Kirch@it2media.de]
Sent: Tuesday, March 31, 2015 11:33 PM
To: kevin@renderx.com; RenderX Community Support List
Subject: AW: [xep-support] Cooltool - Bookfolding an existing PDF

 

Hi,

 

I've tested your folding stylesheet with the XEPUserGuide.pdf

Why is the folded PDF 2,003 KB while the initial PDF is only 1.470 KB?

 

Fritz Kirch

IT2media

 

Von: Xep-support [mailto:xep-support-bounces@renderx.com] Im Auftrag von
Kevin Brown
Gesendet: Mittwoch, 1. April 2015 00:21
An: 'RenderX Community Support List'
Betreff: [xep-support] Cooltool - Bookfolding an existing PDF

 

Recently a few questions were asked about bookfolding. In the past we have
presented a solution that used the RenderX Intermediate Format and shows how
to bookfold a document before final output.

 

But what about a random PDF you have laying around? Well, with RenderX's new
extension (rx:pdf-page) which can be used on <fo:external-graphic/> to
select a specific page of a PDF to use as an image, we can create bookfolded
output from any PDF you have.

 

Bookfolding is typically creating a booklet for saddle stitching, outputting
the document by combining two pages into one in a specific order. When
printed, this document can be combined, folded and stitched into a booklet.
A good example is say you have a 10 page document, you would normally
combine as follows (duplexed) with all pages twice the width of the original
page:

 

10, 1 as page 1

2,9 as page 2

8,3 as page 3

4,7 as page 4

6, 5 as page 5

 

Sometimes you may not want to include the back or front pages as they are
used for the cover. In this case you would have:

 

1 as page 1 as same size

9, 2 as page 2 double the width

3, 8 as page 3 double the width

7, 4 as page 4 double the width

5,6 as page 4 double the width

10 as page 10 as same size

 

So, lets say we have a PDF in hand (even page count of course) and we want
to create a bookfolded document. We may create a simple XML file that
describes this job as follows:

 

<bookfold>
    <document src="XEPUserGuide.pdf" cover="false"/>
    <pagewidth>8.27in</pagewidth>
    <pageheight>11in</pageheight>
    <pages>206</pages>
</bookfold>

 

This simple XML tells us what document to use, whether we want a cover or
not and some information about that PDF. This information we need to feed
the formatter to make sure the document size and pagination is correct.
Using this simple XSL below, we can create a simple XSL FO that takes
advantage of this new extension by placing the PDF pages into a new two
column document using:

 

<fo:external-graphic rx:pdf-page="#" src="XEPUserGuide.pdf"/>

 

Give it a test. Send me any questions or enhancements.

 

 

We are working on a new update to Cloudformatter client which will include
both PDF merging, stamping and this bookfolding among many other sample
templates. And with Cloudformatter, you do not even need RenderX installed
locally, it will format on the web and return the document to you.

 

Kevin Brown

RenderX

 

PS: http://www.cloudformatter.com/Nimbus is our free to use XSL Designer.

 

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:fo="http://www.w3.org/1999/XSL/Format"
    xmlns:rx="http://www.renderx.com/XSL/Extensions"
    version="1.0">
    <xsl:template match="/bookfold">
        <fo:root>
            <fo:layout-master-set>
                <fo:simple-page-master page-width="{pagewidth}"
page-height="{pageheight}" master-name="front">
                    <fo:region-body/>
                </fo:simple-page-master>
                <fo:simple-page-master page-width="2 * {pagewidth}"
page-height="{pageheight}" master-name="all">
                    <fo:region-body column-count="2" column-gap="0in"/>
                </fo:simple-page-master>
                <fo:simple-page-master page-width="{pagewidth}"
page-height="{pageheight}" master-name="back">
                    <fo:region-body/>
                </fo:simple-page-master>
            </fo:layout-master-set>
            <xsl:if test="document/@cover='true'">
                <fo:page-sequence master-reference="front">
                    <fo:flow flow-name="xsl-region-body">
                        <fo:block line-height="0">
                            <fo:external-graphic src="{document/@src}"
rx:pdf-page="1"/>
                        </fo:block>
                    </fo:flow>
                </fo:page-sequence>
            </xsl:if>
            <fo:page-sequence master-reference="all">
                <fo:flow flow-name="xsl-region-body">
                    <xsl:call-template name="pages"/>
                </fo:flow>
            </fo:page-sequence>
            <xsl:if test="document/@cover='true'">
                <fo:page-sequence master-reference="back">
                    <fo:flow flow-name="xsl-region-body">
                        <fo:block line-height="0">
                            <fo:external-graphic src="{document/@src}"
rx:pdf-page="{number(pages)}"/>
                        </fo:block>
                    </fo:flow>
                </fo:page-sequence>
            </xsl:if>
        </fo:root>
    </xsl:template>
    <xsl:template name="pages">
        <xsl:choose>
            <xsl:when test="document/@cover='true'">
                <xsl:call-template name="page">
                    <xsl:with-param name="pgleft" select="number(pages) -
1"/>
                    <xsl:with-param name="pgright" select="2"/>
                    <xsl:with-param name="odd" select="true()"/>
                </xsl:call-template>
            </xsl:when>
            <xsl:otherwise>
                <xsl:call-template name="page">
                    <xsl:with-param name="pgleft" select="number(pages)"/>
                    <xsl:with-param name="pgright" select="1"/>
                    <xsl:with-param name="odd" select="true()"/>
                </xsl:call-template>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>
    <xsl:template name="page">
        <xsl:param name="pgleft"/>
        <xsl:param name="pgright"/>
        <xsl:param name="odd"/>
        <fo:block line-height="0">
            <fo:external-graphic src="{document/@src}"
rx:pdf-page="{$pgleft}"/>
        </fo:block>
        <fo:block line-height="0">
            <fo:external-graphic src="{document/@src}"
rx:pdf-page="{$pgright}"/>
        </fo:block>
        <xsl:if test="not(($pgleft - $pgright) = -1 or ($pgleft - $pgright)
= 1)">
        <xsl:choose>
            <xsl:when test="$odd">
                <xsl:call-template name="page">
                    <xsl:with-param name="pgleft" select="$pgright + 1"/>
                    <xsl:with-param name="pgright" select="$pgleft - 1"/>
                    <xsl:with-param name="odd" select="false()"/>
                </xsl:call-template>
            </xsl:when>
            <xsl:otherwise>
                <xsl:call-template name="page">
                    <xsl:with-param name="pgleft" select="$pgright - 1"/>
                    <xsl:with-param name="pgright" select="$pgleft + 1"/>
                    <xsl:with-param name="odd" select="true()"/>
                </xsl:call-template>
            </xsl:otherwise>
        </xsl:choose>
        </xsl:if>
        
    </xsl:template>
</xsl:stylesheet>

 

**********************************************************************
Diese E-Mail wurde auf Viren ueberprueft.
 <mailto:mailsweeper@it2media.de> mailsweeper@it2media.de
**********************************************************************

_______________________________________________
(*) 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

image001.png
Received on Wed Apr 1 09:02:04 2015

This archive was generated by hypermail 2.1.8 : Wed Apr 01 2015 - 09:02:10 PST