Pascal,
The method that I am using in my code follows:
public void convertFO2PDF(OPFReader opfReader, File resultfile)
throws IOException, FOPException {
OutputStream out = null;
try {
//configure user agent
FOUserAgent foUserAgent = fopFactory.newFOUserAgent();
//PDF/A-1b
Boolean isPDFA =
Boolean.parseBoolean(FrameMain.applicationProps.getProperty("pdfA"));
if (isPDFA) {
foUserAgent.getRendererOptions().put("pdf-a-mode", "PDF/A-1b");
}
//Accessible PDF
Boolean isAccessiblePDF =
Boolean.parseBoolean(FrameMain.applicationProps.getProperty("accessiblePDF"));
if (isAccessiblePDF) {
foUserAgent.setAccessibility(true);
}
foUserAgent.setTitle(opfReader.getTitle());
foUserAgent.setSubject(opfReader.getSubject());
foUserAgent.setKeywords(opfReader.getIdentifier());
foUserAgent.setProducer("NIMAS2PDF");
File foFile = new File(xmlDir, opfReader.getIdentifier() + ".fo");
//debug message
logger.info("Transforming " + foFile.getName() + " to PDF.");
logger.info("Using " + xsltFile.getName() + " for tranformation.");
// setup output based on parameter
out = new java.io.FileOutputStream(resultfile);
out = new java.io.BufferedOutputStream(out);
// Construct fop with desired output format
Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF,
foUserAgent, out);
// Setup JAXP using identity transformer
TransformerFactory factory = TransformerFactory.newInstance();
Transformer transformer = factory.newTransformer(); //
identity transformer
// Setup input stream
Source src = new StreamSource(foFile);
// 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);
// Result processing
FormattingResults foResults = fop.getResults();
java.util.List pageSequences = foResults.getPageSequences();
for (java.util.Iterator it = pageSequences.iterator();
it.hasNext();) {
PageSequenceResults pageSequenceResults =
(PageSequenceResults) it.next();
logger.info("PageSequence " +
(String.valueOf(pageSequenceResults.getID()).length() > 0
? pageSequenceResults.getID() : "<no id>") + "
generated " + pageSequenceResults.getPageCount() + " pages.");
}
logger.info("Generated " + foResults.getPageCount() + "
pages in total.");
} catch (Exception ex) {
logger.severe(ex.getMessage());
} finally {
out.close();
}
}
I believe the error is actually being thrown by FOP. The
AbstractLayoutManager class has the following method:
private void verifyNonNullPosition(Position pos) {
if (pos == null || pos.getIndex() < 0) {
throw new IllegalArgumentException(
"Only non-null Positions with an index can be checked");}
I am at a loss as to what a no null position even is. I'm also a bit
confused that your not getting the error on your end. Perhaps if I
knew a bit more about the nature of the verifyNonNullPosition method.
Thanks,
Gregory Buchenberger, CDIA+, ECMs
Eightfold Consulting
15710 W. 3rd Place #4
Golden, CO 80401
720-259-7779 Office
720-299-2386 Mobile
877-713-5342 Fax
www.eightfoldconsulting.com
On Fri, Mar 12, 2010 at 2:03 AM, Pascal Sancho <[email protected]> wrote:
>
> Gregory,
>
> I can run your FO file without any exception, either with FOP 0.95, or
> with FOP TRUNK (latest rev).
> I notice that your log message is not like what I can see when I run
> directly FOP, and the exception is thrown by
> org.eightfoldconsulting.nimas2pdf.XMLConverter.convertFO2PDF(),
> witch is not part of the FOP code.
> Can you check the actual source of the exception?
> If it comes from FOP, that would help to give the original one.
>
> Pascal
>
>
> Gregory Buchenberger a écrit :
> > Pascal,
> >
> > I am running fop.jar from the latest revision in Trunk. I just updated
> > and recompiled to be sure. I'm using fop.jar and it's supporting
> > libraries in a java application. I'm running Windows Vista 64bit and
> > have alloted -Xms128m -Xmx1500m to the JVM version1.6.0_16. I've
> > attached my log file in the hopes that it may be of help.
> >
> > I still get the error. In the log I have:
> >
> > <record>
> > <date>2010-03-11T17:34:46</date>
> > <millis>1268354086853</millis>
> > <sequence>132</sequence>
> > <logger>org.eightfoldconsulting.nimas2pdf.XMLConverter</logger>
> > <level>SEVERE</level>
> > <class>org.eightfoldconsulting.nimas2pdf.XMLConverter</class>
> > <method>convertFO2PDF</method>
> > <thread>11</thread>
> > <message>java.lang.IllegalArgumentException: Only non-null Positions
> > with an index can be checked</message>
> > </record>
> >
> > Are you able to produce a PDF from the FO that I sent without error?
> > If so, what revision are you using?
> >
> > Thank you all for your help.
> >
> > Kind Regards,
> >
> > Gregory Buchenberger, CDIA+, ECMs
> >
> >
> > On Thu, Mar 11, 2010 at 3:09 AM, Pascal Sancho <[email protected]>
> > wrote:
> >
> >> Hi Gregory,
> >>
> >> I cannot reproduce the exception with that material.
> >> Can you describe your environment (comprising jar coming with FOP) ?
> >> What FOP SVN revision do you use?
> >> When invoking FOP feeded with an XSL-FO, is there a file location in the
> >> log:
> >> if yes, that should help to retreive the faulty formatting object, if any
> >>
> >> Pascal
> >>
>
>
> ---------------------------------------------------------------------
> 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]