Hi ToM Tobias van Treeck wrote: > > Hi Miguel, > > i had a similar problem recently. I also generated a PDF with a barcode > and an image. > I got the exact same error you got (root vs. page-sequence) and the > reason was a wrong parameter in a table i used (for the column-with i > used % instead of cm) > > Now i have serval suggestions for you: > > 1. Try to isolate your barcode 'code' - meaning create a document with > just the barcode and run it. Does that work? > 2. I used the same barcode 'code' like you but the following proved to > be better for me: > > Namespace: > xmlns:barcode="http://barcode4j.krysalis.org/ns" > > <block ...> > <fo:instream-foreign-object> > <barcode:barcode> > <xsl:attribute name="message"> > <xsl:text>1234567890</xsl:text> > </xsl:attribute> > <barcode:codabar> > <barcode:height>15mm</barcode:height> > <barcode:module-width>0.3mm</barcode:module-width> > <barcode:wide-factor>3.0</barcode:wide-factor> > <barcode:quiet-zone enabled="true">10mw</barcode:quiet-zone> > </barcode:codabar> > </barcode:barcode> > </fo:instream-foreign-object> > > Try that barcodeversion in a separate stylsheet and run it. > > 3. Which version of xalan are you using? Put the newest one with the > endorsed mechanism (http://java.sun.com/j2se/1.4.2/docs/guide/standards/ > ) into your jdk. > > Regards, > ToM > >> Hi folks, >> >> I'm upgrading my FOP version from 0.20 up to 0.95 and I'm getting two >> problems. >> >> The first one, and most important, is that I can't generate barcodes >> with >> Apache FOP and Barcode4j projects. I don't know why but I'm getting >> this >> error: >> javax.xml.transform.TransformerException: org.xml.sax.SAXException: >> Mismatch: page-sequence (http://www.w3.org/1999/XSL/Format) vs. root >> (http://www.w3.org/1999/XSL/Format) >> >> I know that this error uses to be a follow-up error but I have no more >> detail and I'm lost since I have reached a strange situation. >> >> I have the following code on my xslt. >> - Definition: >> <xsl:stylesheet version="1.0" >> xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >> xmlns:fo="http://www.w3.org/1999/XSL/Format" >> xmlns:barcode="org.krysalis.barcode4j.xalan.BarcodeExt" >> xmlns:svg="http://www.w3.org/2000/svg" >> extension-element-prefixes="barcode"> >> - Template: >> <xsl:template match="[EMAIL PROTECTED]'CODIGO_BARRAS']"> >> <fo:block> >> <fo:instream-foreign-object> >> <xsl:variable name="barcode-cfg"> >> <barcode> >> <code128> >> <human-readable>none</human-readable> >> <height>5mm</height> >> <quiet-zone enabled="false"/> >> </code128> >> </barcode> >> </xsl:variable> >> <xsl:copy-of select="barcode:generate($barcode-cfg, .)"/> >> </fo:instream-foreign-object> >> </fo:block> >> </xsl:template> >> >> - Call example: >> <texto class="CODIGO_BARRAS" text-align="left" font-size="12pt" >> module="0.45" height="10" >D106696</texto> >> >> - Java code: >> The following code throws the exception. >> >> public void convertXmlToPdf(final StreamSource xmlSource, final String >> xsl, final OutputStream pdf) throws Exception { >> >> FOUserAgent foUserAgent = instance.fopFactory.newFOUserAgent(); >> // todo, configure urls. >> >> >> foUserAgent.setBaseURL("file:///C:/TRIBUTOS/apps/gt_ear/build/gt_ear/gt_web/"); >> >> >> foUserAgent.setFontBaseURL("file:///C:/TRIBUTOS/apps/gt_ear/build/gt_ear/gt_web/"); >> foUserAgent.setAuthor("Miguel Tablado"); >> >> //Setup XSLT >> Fop fop = instancia.fopFactory.newFop(MimeConstants.MIME_PDF, >> foUserAgent, pdf); >> >> TransformerFactory factory = TransformerFactory.newInstance(); >> Transformer transformer = factory.newTransformer(new >> StreamSource(xsl)); >> >> // Parámetro PATH de las imagenes >> transformer.setParameter("AG_XSLFO_PATH_IMAGES", >> AGFunciones.agregarProtocoloFile(AGConfig.get("VirtualDirTemplates")) >> + >> "/images"); >> >> //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(xmlSource, res); >> >> } >> >> The following one creates the .fo file with no problems. >> private void convertXML2FO(final StreamSource src, final String xslt) >> throws IOException, TransformerException >> , FOPException { >> //Setup output >> final File fo = new File(AGConfig.get("writeXmlFoPdfIntoFile")); >> final OutputStream out = new FileOutputStream(fo); >> >> try { >> //Setup XSLT >> TransformerFactory factory = TransformerFactory.newInstance(); >> Transformer transformer = factory.newTransformer(new >> StreamSource(xslt)); >> >> // Parámetro PATH de las imagenes >> transformer.setParameter("AG_XSLFO_PATH_IMAGES", >> AGFunciones.agregarProtocoloFile(AGConfig.get("VirtualDirTemplates")) >> + >> "/images"); >> >> //Resulting SAX events (the generated FO) must be piped through >> to FOP >> Result res = new StreamResult(out); >> >> //Start XSLT transformation and FOP processing >> transformer.transform(src, res); >> >> } finally { >> out.close(); >> } >> } >> >> The .fo generated snippet is something like this: >> <fo:block> >> <fo:instream-foreign-object> >> <svg:svg height="1.3316mm" viewBox="0 0 120.54 1.3316" >> width="120.54mm"> >> <svg:g style="fill:black; stroke:none"> >> <svg:rect height="1.3316" width="0.42" x="0" y="0"/> >> <svg:rect height="1.3316" width="0.21" x="0.63" y="0"/> >> ... >> <svg:rect height="1.3316" width="0.42" x="120.12" y="0"/> >> </svg:g> >> </svg:svg> >> </fo:instream-foreign-object> >> </fo:block> >> >> Trying to find out the original problem I have tried two things, the >> first >> one is to replace Barcode4j call to svg code. >> Any problem, the resultant pdf has a pretty barcode. >> >> The second one, that follows me to the second problem mentioned at >> introduction, has been configuring logs to get more information, >> but I didn't get success. I'm logging with Bea Weblogic 8.1 SP 5 >> system logs >> whose are java.util.logging and they are printing on FOP Exceptions, >> but not >> INFO logs. >> How can I configure them to succeed? >> Java properties are setted and it doesn't work, I tryied to filter >> logs, but >> there is no special handler... >> >> Many thanks, and excuse me for the text! >> >> Miguel. > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > >
I have modified my xslt in order to apply only the barcode template and I get the simplest fo file as you said, but unfortunately it doesn't works, it doesn't render the svg (the barcode nodeList, really) nor it prits out any exception. By the way if I launch the fo file from command line I get problems finding barcode classes. I don't know what I'm doing wrong because I have put the jar path on the classpath environment variable. About Xalan version, I'm using 2.7.1 and it is working from Weblogic container, not jdk installation one. Any idea? Tx, Miguel. -- View this message in context: http://www.nabble.com/Problems-with-Apache-FOP-and-Barcode4j-tp19069996p19088718.html Sent from the FOP - Users mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
