Return-Path: Delivered-To: apmail-forrest-user-archive@www.apache.org Received: (qmail 63294 invoked from network); 6 Jul 2010 05:31:12 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 6 Jul 2010 05:31:12 -0000 Received: (qmail 43457 invoked by uid 500); 6 Jul 2010 05:31:12 -0000 Delivered-To: apmail-forrest-user-archive@forrest.apache.org Received: (qmail 43262 invoked by uid 500); 6 Jul 2010 05:31:09 -0000 Mailing-List: contact user-help@forrest.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: user@forrest.apache.org List-Id: Delivered-To: mailing list user@forrest.apache.org Received: (qmail 43255 invoked by uid 99); 6 Jul 2010 05:31:08 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 06 Jul 2010 05:31:08 +0000 X-ASF-Spam-Status: No, hits=2.9 required=10.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_NONE,SPF_HELO_PASS,SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (nike.apache.org: local policy) Received: from [80.67.31.39] (HELO smtprelay01.ispgateway.de) (80.67.31.39) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 06 Jul 2010 05:30:58 +0000 Received: from [91.16.221.48] (helo=mackie.fritz.box) by smtprelay01.ispgateway.de with esmtpa (Exim 4.68) (envelope-from ) id 1OW0jt-0002fO-Nb for user@forrest.apache.org; Tue, 06 Jul 2010 07:30:38 +0200 Message-ID: <4C32BF7D.4000305@soethe.net> Date: Tue, 06 Jul 2010 07:30:37 +0200 From: Ferdinand Soethe User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; de; rv:1.9.1.10) Gecko/20100512 Thunderbird/3.0.5 MIME-Version: 1.0 To: user@forrest.apache.org Subject: Re: Convert xdoc document to PDF References: In-Reply-To: Content-Type: multipart/alternative; boundary="------------000808090509000504040603" X-Df-Sender: 246568 X-Virus-Checked: Checked by ClamAV on apache.org This is a multi-part message in MIME format. --------------000808090509000504040603 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Hi Alan, as far as I remember the stylesheets for pdf-generation have moved from core into the pdf-output-plugin. So you may be looking at outdated style sheets. Which might also explain the errors you are getting (some changes were required in the transformations to accomodate that last fop-update). Check out plugins/org.apache.forrest.plugin.output.pdf/resources/stylesheets for the current stylesheets (from head). After using Forrest with the pdf-plugin for the first time, you will also find the stylesheets in build/plugins/org.apache.forrest.plugin.output.pdf/resources/stylesheets. Yet I agree with Brian, these style sheets were designed to be used in a pipeline, so you may have to make some major adjustments. Regards, Ferdinand Soethe Am 06.07.10 06:27, schrieb Alan Wang: > Hi All, > > I am writing a program similar to pdf output plugin to convert xdoc > pages in xml document ( xdoc similar to > http://xmlgraphics.apache.org/fop/index.xml), and would like to > generate the pdf output using fop (0.95 on Mac os 10.5) as shown in > the following. However I am getting the following errors from console. > > (Location of error unknown)org.apache.fop.fo.ValidationException: > Error(Unknown location): For fo:simple-page-master, fo:region-body > must be declared before fo:region-before. > > 1. Where can I find the xsl to convert from xdoc to fo. I find one > from apache forrest > distribution( apache-forrest-0.8/main/webapp/skins/common/xslt/fo/document-to-fo.xsl)? > Or Am I using the wrong one for converting from xdoc to fo? > > 2. Is anything wrong with my code? > > Regards, > Alan > > > ======================================================== > public class fop { > public static void main(String[] args) throws Exception { > // configure fopFactory as desired > FopFactory fopFactory = FopFactory.newInstance(); > fopFactory.setStrictValidation(false); > fopFactory.setStrictUserConfigValidation(false); > // configure foUserAgent as desired > FOUserAgent foUserAgent = fopFactory.newFOUserAgent(); > > // Setup output > OutputStream out = new java.io.FileOutputStream(new > File("mypdf.pdf")); > out = new java.io.BufferedOutputStream(out); > > // Construct fop with desired output format > Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, > foUserAgent, out); > > // Setup XSLT > TransformerFactory factory = TransformerFactory.newInstance(); > Transformer transformer = factory.newTransformer(new StreamSource(new > File("/Downloads/apache-forrest-0.8/main/webapp/skins/common/xslt/fo/document-to-fo.xsl"))); > > // Set the value of a in the stylesheet > transformer.setParameter("versionParam", "2.0"); > > // Setup input for XSLT transformation > Source src = new > StreamSource("http://xmlgraphics.apache.org/fop/index.xml"); > > // Resulting SAX events (the generated FO) must be piped > through to FOP > Result res = new SAXResult(fop.getDefaultHandler()); > > // Start XSLT transformation and FOP processing > transformer.transform(src, res); > out.close(); > } > } --------------000808090509000504040603 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Hi Alan,

as far as I remember the stylesheets  for pdf-generation have moved from core into the pdf-output-plugin.

So you may be looking at outdated style sheets. Which might also explain the errors you are getting (some changes were required in the transformations to accomodate that last fop-update).

Check out plugins/org.apache.forrest.plugin.output.pdf/resources/stylesheets for the current stylesheets (from head).
After using Forrest with the pdf-plugin for the first time, you will also find the stylesheets in build/plugins/org.apache.forrest.plugin.output.pdf/resources/stylesheets.

Yet I agree with Brian, these style sheets were designed to be used in a pipeline, so you may have to make some major adjustments.

Regards,
Ferdinand Soethe

Am 06.07.10 06:27, schrieb Alan Wang:
Hi All,

I am writing a program similar to pdf output plugin to convert xdoc pages in xml document ( xdoc similar to http://xmlgraphics.apache.org/fop/index.xml), and would like to generate the pdf output using fop (0.95 on Mac os 10.5) as shown in the following.  However I am getting the following errors from console.

(Location of error unknown)org.apache.fop.fo.ValidationException: Error(Unknown location): For fo:simple-page-master, fo:region-body must be declared before fo:region-before.

1. Where can I find the xsl to convert from xdoc to fo. I find one from apache forrest distribution( apache-forrest-0.8/main/webapp/skins/common/xslt/fo/document-to-fo.xsl)? Or Am I using the wrong one for converting from xdoc to fo?

2. Is anything wrong with my code?

Regards,
Alan

 

========================================================
public class fop {
public static void main(String[] args) throws Exception {
     // configure fopFactory as desired
            FopFactory fopFactory = FopFactory.newInstance();
            fopFactory.setStrictValidation(false);
            fopFactory.setStrictUserConfigValidation(false);
            
            // configure foUserAgent as desired
            FOUserAgent foUserAgent = fopFactory.newFOUserAgent();

            // Setup output
            OutputStream out = new java.io.FileOutputStream(new File("mypdf.pdf"));
            out = new java.io.BufferedOutputStream(out);

            // Construct fop with desired output format
            Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, foUserAgent, out);

            // Setup XSLT
            TransformerFactory factory = TransformerFactory.newInstance();
Transformer transformer = factory.newTransformer(new StreamSource(new File("/Downloads/apache-forrest-0.8/main/webapp/skins/common/xslt/fo/document-to-fo.xsl")));

            // Set the value of a <param> in the stylesheet
            transformer.setParameter("versionParam", "2.0");

            // Setup input for XSLT transformation
Source src = new StreamSource("http://xmlgraphics.apache.org/fop/index.xml");

            // Resulting SAX events (the generated FO) must be piped through to FOP
            Result res = new SAXResult(fop.getDefaultHandler());

            // Start XSLT transformation and FOP processing
            transformer.transform(src, res);
            
            out.close();
}
}

--------------000808090509000504040603--