I am trying to convert your explaination into code instead of
XSL-FO.
I see the missing second fo:list-item-body, but I am unsure how to
match it to this code sample.
public void printPageable(Pageable rcPageable, AttributeSet
rcAttrSet)
throws PrintException
{
// Check the number of pages.
int lnNumOfPages = rcPageable.getNumberOfPages();
if(lnNumOfPages == rcPageable.UNKNOWN_NUMBER_OF_PAGES)
{
lcLog.LogDebug(lnNumOfPages
+ " Unknown Number of Pages "
+ rcPageable);
throw new PrintException("Can't Handle Unknown Number of Pages.");
}
try
{
// Create a temp file to store the PDF.
FileOutputStream lcFileOut = initStream();
// Initialize the default pageformat.
PageFormat lcFormat = initPageFormat(rcAttrSet);
// Create PDF.
FontInfo lcFontInfo = new FontInfo();
PDFRenderer lcPdfRenderer = new PDFRenderer();
lcPdfRenderer.setupFontInfo(lcFontInfo);
lcPdfRenderer.setProducer("Cleetus-FOP");
// Create an AreaTree for Rendering onto the PDFPage.
StreamRenderer lcStrRenderer = new StreamRenderer(lcFileOut,
lcPdfRenderer);
lcStrRenderer.setLogger(new
ConsoleLogger(ConsoleLogger.LEVEL_INFO));
AreaTree lcAreaTree = new AreaTree(lcStrRenderer);
lcAreaTree.setFontInfo(lcFontInfo);
FontState lcFState = new FontState(lcFontInfo, "Helvetica",
"normal",
"normal", 12, 0);
// Start Rendering
lcStrRenderer.startRenderer();
// Loop over the pages.
int lnPageExists = Printable.PAGE_EXISTS;
for(int lnIndex = 0;
lnIndex < lnNumOfPages
&&
lnPageExists != Printable.NO_SUCH_PAGE;
//&&
//lnIndex < 1;
lnIndex++)
{
// Get the PageFormat
PageFormat lcPgFormat = rcPageable.getPageFormat(lnIndex);
if(lcPgFormat == null)
lcPgFormat = lcFormat;
// Initialize the default width and height and X an Y position.
Paper lcPaper = lcFormat.getPaper();
int lnWidth = (int)lcPaper.getWidth() * 1000;
int lnHeight = (int)lcPaper.getHeight() * 1000;
int lnPositionX = (int)lcPaper.getImageableX() * 1000;
int lnPositionY = (int)lcPaper.getImageableY() * 1000;
// Create the SVGDocument
Document lcSvgDoc = SVGUtilities.createSVGDocument(lnWidth/1000,
lnHeight/1000);
// Create the SVGGraphics2D to draw into the SVG Document.
SVGGraphics2D lcSVGGraphics = new SVGGraphics2D(lcSvgDoc);
// Get the Printable and pass the graphics for drawing.
Printable lcPrintable = rcPageable.getPrintable(lnIndex);
lnPageExists = lcPrintable.print(lcSVGGraphics,
lcPgFormat,
lnIndex);
// Get the Root SVg Node from the graphics
// and append it to the SVG Document.
lcSvgDoc.getFirstChild().appendChild(lcSVGGraphics.getRoot());
javax.xml.transform.TransformerFactory factory =
javax.xml.transform.TransformerFactory.newInstance();
javax.xml.transform.Transformer transformer =
factory.newTransformer();
javax.xml.transform.dom.DOMSource source =
new javax.xml.transform.dom.DOMSource(lcSvgDoc);
javax.xml.transform.stream.StreamResult result =
new
javax.xml.transform.stream.StreamResult("test"+lnIndex+".svg");
transformer.transform(source, result);
// Create an SVGArea for rendering onto the PDF Page.
SVGArea lcSvgArea = new SVGArea(lcFState, lnWidth/1000,
lnHeight/1000);
lcSvgArea.setSVGDocument(lcSvgDoc);
// Create a Body Area Container
BodyRegionArea lcBodyRegion = new BodyRegionArea(lnPositionX,
lnPositionY,
lnWidth,
lnHeight);
// Create PageMaster who creates PDF Pages.
PageMaster lcPageMaster = new PageMaster(lnWidth, lnHeight);
lcPageMaster.addBody(lcBodyRegion);
// Create a Page with the PageMaster
Page lcCurPage = lcPageMaster.makePage(lcAreaTree);
//lcCurPage.getBody().addChild(lcSvgArea); // does nothing
lcCurPage.getBody().getMainReferenceArea().addChild(lcSvgArea);// adds
invalid q
//lcCurPage.getBody().addChild(lcSvgArea); // does nothing
//lcBody.getMainReferenceArea().addChildAtStart(lcSvgArea); //
adds invalid q
//lcBody.getMainReferenceArea().addChild(lcSvgArea); // adds
invalid q
//lcBody.addChild(lcSvgArea); // does nothing
lcAreaTree.addPage(lcCurPage);
}
lcStrRenderer.stopRenderer();
lcFileOut.close();
}
catch(Exception e)
{
lcLog.LogWarning("ERROR: "+e);
throw new PrintException(e);
}
}
This will create an invlaid PDF file that will popup an error
saying Illegal 'q' in text object
??
-----Original Message-----
From: Clay Leeds [mailto:[EMAIL PROTECTED]
Sent: Tuesday, April 08, 2003 1:22 PM
To: [EMAIL PROTECTED]
Subject: Re: Error in PDF file
Allow me to clarify what I said. Sorry for the re-post...
My problem was in fo:list-block:
<fo:list-block space-before="6pt" space-after="6pt" font-family="Times">
<fo:list-item>
<fo:list-item-label end-indent="label-end()">
<fo:block font-family="ZapfDingbats">?</fo:block>
</fo:list-item-label>
<fo:list-item-body start-indent="body-start()">
<fo:block>
This is the first entry
in a plain unordered list.
A check symbol is displayed in the bullet.
</fo:block>
</fo:list-item-body>
</fo:list-item>
<fo:list-item>
<fo:list-item-label end-indent="label-end()">
<fo:block font-family="ZapfDingbats">?</fo:block>
</fo:list-item-label>
<fo:list-item-body start-indent="body-start()">
<fo:block></fo:block>
</fo:list-item-body>
</fo:list-item>
</fo:list-block>
I was missing content in 2nd <fo:list-item-body><fo:block>. The PDF file
rendered normally (I think FOP returned a warning), but an error was
given when the file was opened in Adobe Acrobat Reader. Unbeknownst to
me, my XML file did not include data where it was expected.
What did I do? I wrote this list and they recommended I output the FO
file using XALAN.BAT, and look for the problem. I found the problem by
searching all of the fo:list-block items...
Clay Leeds wrote:
> Ethan,
>
> I suspect there's a problem in your XSL-FO file. I had similar things
> happen to me with fo:list-item, and one of the components turned out to
> be empty. This caused an error in the renderer. I processed my XML &
> XSL-FO using XALAN.BAT (included with 0.20.5rc), but set my output to -fo.
>
> the command line would be (assume "c:\java\fop-0.20.5rc>" is command
> prompt):
>
> c:\java\fop-0.20.5rc>xalan.bat -in c:\path\to\your\xmlfile.xml -xsl
> c:\path\to\your\xslfile.xsl -out c:\path\to\your\outputfofile.fo
>
> Hope this helps!
>
> Web Maestro Clay
>
> (note to FOP-DEV: it'd be nice to add a "-fo" output option to FOP, for
> debugging--although xalan.bat does this, it'd be nice not have to learn
> one more thing ;-p)
--
Clay Leeds - [EMAIL PROTECTED]
Web Developer - Medata, Inc. - http://www.medata.com
PGP Public Key: https://mail.medata.com/pgp/cleeds.asc
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]