W3C home > Mailing lists > Public > www-xsl-fo@w3.org > July 2007

RE: xslt:fo include binaryfile

From: Vladimir Rodimyuk <VladimirR@ukrinvent.com>
Date: Thu, 12 Jul 2007 14:13:56 +0300
To: "Weinzierl, Sabrina (IT/I2F)" <sabrina.weinzierl@ww-informatik.de>
CC: "www-xsl-fo@w3.org" <www-xsl-fo@w3.org>
Message-ID: <C50378BB9C267D4796753862ED9AE1A3279B803A20@UI-OPTERON.ukrinvent.com>
Hi, Sabrina

Yes, there is a way if your XSL-FO formatter allows referencing PDF as an image and including it into resulting one (see attachment text_with_pdf1.pdf" it includes "column_test3.pdf" and "column_test4.pdf").
I'm not sure about FOP, but you surely can do this using XEP XSL-FO formatter.

The trick is to reference a PDF instead of an image in fo:external-graphic and set page margins to zero to prevent undesired page shifting. See below XSL-FO code for it.

<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
    <fo:layout-master-set>
<!-- Define 2 page-sequences for dynamic text and some static content -->
        <fo:simple-page-master master-name="article-regular"
            page-height="11in" page-width="8.50in" margin="0in">
            <fo:region-body  margin-left="1.1in" margin-right="1.2in"
              margin-top="1in" margin-bottom="1in"/>
            <fo:region-before region-name="article-reg-header"
              extent="0.86in" padding-top="0.2in" padding-left="1.1in"
              padding-right="1.1in"/>
            <fo:region-after region-name="article-reg-footer"
              extent="0.86in" padding-top="0.2in" padding-left="1.1in"
              padding-right="1.1in"/>
        </fo:simple-page-master>
        <fo:simple-page-master master-name="article-static"
            page-height="11in" page-width="8.50in" margin ="0in">
            <fo:region-body margin="0in"/>
            <fo:region-before region-name="article-stat-header"
              extent="0.86in" padding-top="0.2in" padding-left="1.1in"
              padding-right="1.1in"/>
            <fo:region-after region-name="article-stat-footer"
              extent="0.86in" padding-top="0.2in" padding-left="1.1in"
              padding-right="1.1in"/>
        </fo:simple-page-master>
        <fo:page-sequence-master master-name="article-1part">
            <fo:repeatable-page-master-reference
              master-reference="article-regular"/>
        </fo:page-sequence-master>
        <fo:page-sequence-master master-name="article-2part">
            <fo:repeatable-page-master-reference
              master-reference="article-static"/>
        </fo:page-sequence-master>
    </fo:layout-master-set>

    <fo:page-sequence master-reference="article-1part">
        <fo:static-content flow-name="article-reg-header">
            <fo:block-container absolute-position="absolute"
              top="0.2in" left="0in">
                <fo:block text-align="center">
                 XSL Formatting Objects Tutorial</fo:block>
            </fo:block-container>
        </fo:static-content>
        <fo:static-content flow-name="article-reg-footer">
            <fo:block-container absolute-position="absolute" top="0.2in" left="0in">
                <fo:block text-align="center">- <fo:page-number/> -</fo:block>
            </fo:block-container>
        </fo:static-content>
        <fo:flow flow-name="xsl-region-body">
<!-- I took some text from web page for dynamic content -->
            <fo:block font-size="10pt" white-space="pre"
              linefeed-treatment="preserve" wrap-option="wrap">
                Graphics

                There is a special inline element for including graphics into XSL FO (XSLFO) - &lt;fo:external-graphic&gt;. The source image is specified by the src attribute whose value is a URI. XEP handles HTTP, FTP, data and filesystem resource locators in URIs. An unqualified URI is treated as a path to a file in the local file system; if the path is relative, it is calculated from the location of the source XSL FO (XSLFO) document.

              </fo:block>
        </fo:flow>
    </fo:page-sequence>

<!-- that's where I placed static content -->
    <fo:page-sequence master-reference="article-2part">
        <fo:static-content flow-name="article-stat-header">
            <fo:block-container absolute-position="absolute"
              top="0.2in" left="0in">
                <fo:block text-align="center">Some Static Content</fo:block>
            </fo:block-container>
        </fo:static-content>
        <fo:static-content flow-name="article-stat-footer">
            <fo:block-container absolute-position="absolute"
              top="0.2in" left="0in">
                <fo:block text-align="center">- <fo:page-number/> -
                </fo:block>
            </fo:block-container>
        </fo:static-content>
        <fo:flow flow-name="xsl-region-body">
          <!-- 1st static page-->
            <fo:block font-size="0" line-height="0">
              <fo:external-graphic
                src="url(&quot;column_test3.pdf&quot;)" />
            </fo:block>
          <!-- 2nd static page-->
            <fo:block font-size="0" line-height="0" break-before="page">
                <fo:external-graphic
                  src="url(&quot;column_test4.pdf&quot;)" />
            </fo:block>
        </fo:flow>
    </fo:page-sequence>
</fo:root>

Respectfully,
Volodymyr Rodymyuk
________________________________________
From: www-xsl-fo-request@w3.org [mailto:www-xsl-fo-request@w3.org] On Behalf Of Weinzierl, Sabrina (IT/I2F)
Sent: Thursday, July 12, 2007 9:55 AM
To: www-xsl-fo@w3.org
Subject: xslt:fo include binaryfile

Hi,
is it possible to include binary file in xslt by link etc.,
just like an image?
We want to create dynamic pdf with xslt:fo..
the last 2 pages are static.
Now i can write the text of the 2 pages in the xslt.
but this is very bizzy.
i wonder if it is possible to have the 2 pages in a separte pdf-file
which will be included at the time,
my fop-process runs.
Can you please help me.
Thank you
Mit freundlichen Grüßen
Sabrina Weinzierl
W&W Informatik GmbH
I2F Vertrieb Front-Office
Postanschrift: 71630 Ludwigsburg
Büroanschrift: Hohenzollernstr. 46, 71630 Ludwigsburg
Büro: K5, 447-449
Telefon: 07141 16-5807
eMail: Sabrina.Weinzierl@ww-informatik.de
internet: http://www.ww-ag.com
W&W Informatik GmbH
Geschäftsführer: Ralf Stankat, Klaus-Rüdiger Willer
Aufsichtsratsvorsitzender: Klaus Peter Frohmüller
Sitz: Ludwigsburg, Registergericht: Amtsgericht Stuttgart HRB 204709, USt-IdNr. DE 176036989



Received on Thursday, 12 July 2007 12:55:10 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 3 October 2007 16:06:14 GMT