From user-return-4933-apmail-forrest-user-archive=forrest.apache.org@forrest.apache.org Tue Jul 06 04:28:39 2010 Return-Path: Delivered-To: apmail-forrest-user-archive@www.apache.org Received: (qmail 52660 invoked from network); 6 Jul 2010 04:28:39 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 6 Jul 2010 04:28:39 -0000 Received: (qmail 99562 invoked by uid 500); 6 Jul 2010 04:28:39 -0000 Delivered-To: apmail-forrest-user-archive@forrest.apache.org Received: (qmail 99366 invoked by uid 500); 6 Jul 2010 04:28:36 -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 99359 invoked by uid 99); 6 Jul 2010 04:28:35 -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 04:28:35 +0000 X-ASF-Spam-Status: No, hits=2.2 required=10.0 tests=FREEMAIL_FROM,HTML_MESSAGE,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of alan.yi.wang@gmail.com designates 209.85.214.176 as permitted sender) Received: from [209.85.214.176] (HELO mail-iw0-f176.google.com) (209.85.214.176) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 06 Jul 2010 04:28:27 +0000 Received: by iwn37 with SMTP id 37so3556241iwn.21 for ; Mon, 05 Jul 2010 21:27:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:date:message-id :subject:from:to:content-type; bh=DdQ7th121xhR56gZHW1yeu8XUHhFb9VQHyAut0vjGVY=; b=RQE+5cfYLvNhe3qOA0dLtZ/BnzWCmwId7xKpfwCsaBQm/l5qMq4IKgJh5cFtBs9dAU WhsMCg5LOQ1Qh3x+7tgnNphBNXTkKzfBaZm10cqgyq4mkBU/MH/QjKlI1ilMK1qyXORk Yn33f70XodBfAQH42PMtCkITLWMsWU4GoNBTk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=kNU7lVIBwxhFOjRMctCWWr5nsSaWUnoxy1vM4MCs6TYV6xc5XQ3Nx4aAhipBrSKQ89 jUua1DZmN7LeL7q+KzucW00f0aR3MDXFS7ofKZlggoon6iJhvFaygm4Z2yKcYmsVYcsr CEzHMcoM8s912HzBvn29NfpyPMnfWf4sFTZt0= MIME-Version: 1.0 Received: by 10.231.150.19 with SMTP id w19mr4525845ibv.62.1278390426576; Mon, 05 Jul 2010 21:27:06 -0700 (PDT) Received: by 10.231.35.1 with HTTP; Mon, 5 Jul 2010 21:27:06 -0700 (PDT) Date: Mon, 5 Jul 2010 21:27:06 -0700 Message-ID: Subject: Convert xdoc document to PDF From: Alan Wang To: user@forrest.apache.org Content-Type: multipart/alternative; boundary=001636e1eed542a819048ab07714 X-Virus-Checked: Checked by ClamAV on apache.org --001636e1eed542a819048ab07714 Content-Type: text/plain; charset=ISO-8859-1 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(); } } --001636e1eed542a819048ab07714 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
H= i All,


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

1. Where can I find the xsl to convert from xdoc to fo. I find one fro= m apache forrest distribution(=A0apache-forrest-0.8/main/webapp/skins/commo= n/xslt/fo/document-to-fo.xsl)? Or Am I using the wrong one for converting f= rom xdoc to fo?

2. Is anything wrong with my code?

=
Regards,
Alan

=A0

=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D
public class fop {
public static = void main(String[] args) throws Exception {
=A0=A0 =A0 // configure fopFactory as desired
=A0=A0 =A0 =A0 =A0 =A0 =A0FopFactory fopFactory =3D FopFactory.newInst= ance();
=A0=A0 =A0 =A0 =A0 =A0 =A0fopFactory.setStrictValidation(= false);
=A0=A0 =A0 =A0 =A0 =A0 =A0fopFactory.setStrictUserConfigV= alidation(false);
=A0=A0 =A0 =A0 =A0 =A0 =A0
=A0=A0 =A0 =A0 =A0 =A0 =A0// configure foUserAgent as desired
=A0=A0 =A0 =A0 =A0 =A0 =A0FOUserAgent foUserAgent =3D fopFactory.newFOUse= rAgent();

=A0=A0 =A0 =A0 =A0 =A0 =A0// Setup outpu= t
=A0=A0 =A0 =A0 =A0 =A0 =A0OutputStream out =3D new java.io.File= OutputStream(new File("mypdf.pdf"));
=A0=A0 =A0 =A0 =A0 =A0 =A0out =3D new java.io.BufferedOutputStream(out= );

=A0=A0 =A0 =A0 =A0 =A0 =A0// Construct fop with= desired output format
=A0=A0 =A0 =A0 =A0 =A0 =A0Fop fop =3D fopF= actory.newFop(MimeConstants.MIME_PDF, foUserAgent, out);

=A0=A0 =A0 =A0 =A0 =A0 =A0// Setup XSLT
=A0= =A0 =A0 =A0 =A0 =A0 =A0TransformerFactory factory =3D TransformerFactory.ne= wInstance();
Tr= ansformer transformer =3D factory.newTransformer(new StreamSource(new File(= "/Downloads/apache-forrest-0.8/main/webapp/skins/common/xslt/fo/docume= nt-to-fo.xsl")));

=A0=A0 =A0 =A0 =A0 =A0 =A0// Set the value of a <par= am> in the stylesheet
=A0=A0 =A0 =A0 =A0 =A0 =A0transformer.se= tParameter("versionParam", "2.0");

=
=A0=A0 =A0 =A0 =A0 =A0 =A0// Setup input for XSLT transformation

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

=A0=A0 =A0 =A0 =A0 =A0 =A0// Start XSLT transformation and FOP pro= cessing
=A0=A0 =A0 =A0 =A0 =A0 =A0transformer.transform(src, res);
= =A0=A0 =A0 =A0 =A0 =A0 =A0
=A0=A0 =A0 =A0 =A0 =A0 =A0out.close();=
}
}
--001636e1eed542a819048ab07714--