You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-users@xmlgraphics.apache.org by "M.Weiss" <m....@gmx.net> on 2002/08/27 12:06:13 UTC
Problem generating PDF from ECS-XMLDocument
Hi everybody,
I hope, you may help me again. ;-)
I want to create a PDF-Document, embedding FOP in a servlet. Until know I
got it up and running reading two files (XML-Data and XSL-Template), but now
I try to only read the XSL-Template from HDD and to create the XML-Structure
on the fly using apaches ECS. For this, I use the following code in the
execute-method of the servlet:
---
public ActionForward executePost(ActionMapping mapping, AbstractForm
form,
HttpServletRequest request, HttpServletResponse response)
throws javax.servlet.ServletException, java.io.IOException
{
ByteArrayOutputStream out = new ByteArrayOutputStream();
PdfErstellenForm peForm = (PdfErstellenForm)form;
response.setContentType("application/pdf");
Driver driver = new Driver();
driver.setOutputStream(out);
driver.setRenderer(Driver.RENDER_PDF);
XMLDocument xmlDoc = new XMLDocument();
XML Page = new XML("Page");
XML Kopf = new XML("Kopf");
XML Daten = new XML("Daten");
Daten.addElement(new XML("Firma").addElement("123"));
Daten.addElement(new XML("Firma").addElement("456"));
Daten.addElement(new XML("Firma").addElement("789"));
xmlDoc.addElement(Page.addElement(Kopf.addElement(Daten)));
System.out.println("xml:"+xmlDoc.toString());
// Results in:
// <?xml version="1.0" standalone="yes"?>
//
<Page><Kopf><Daten><Firma>123</Firma><Firma>456</Firma><Firma>789</Firma></D
aten></Kopf></Page>
DOMFactory domFact = new DOMFactory();
xmlDoc.output(domFact.getOutputStream());
try
{
Transformer transformer =
TransformerFactory.newInstance().newTransformer(new StreamSource(new
FileInputStream(DEFAULT_XSL_TEMPLATE)));
// following line is line 113, mentionned in the StackTrace
below:
transformer.transform(new DOMSource(domFact.createDOM()), new
SAXResult(driver.getContentHandler()));
}
catch (Exception e)
{
e.printStackTrace();
throw new ServletException(e);
}
byte[] content = out.toByteArray();
response.setContentLength(content.length);
response.getOutputStream().write(content);
response.getOutputStream().flush();
return null;
}
---
When running the servlet using TomCat4.0, I got the following StackTrace:
building formatting object tree
building formatting object tree
javax.xml.transform.TransformerException
at
org.apache.xalan.transformer.TransformerImpl.transformNode(TransformerImpl.j
ava:1212)
at
org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:
479)
at
org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:
1118)
at
de.heine.ree.gui.action.PdfErstellenAction2.executePost(PdfErstellenAction2.
java:113)
at
de.heine.ree.gui.action.PrePostAction.executeAction(PrePostAction.java:64)
at
de.heine.ree.gui.action.AbstractAction.perform(AbstractAction.java:51)
at
org.apache.struts.action.ActionServlet.processActionPerform(ActionServlet.ja
va:1787)
at
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1586)
at
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:510)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application
FilterChain.java:247)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh
ain.java:193)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.ja
va:243)
at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
66)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.ja
va:190)
at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
66)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at
org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2347)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180
)
at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
66)
at
org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.
java:170)
at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
64)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170
)
at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
64)
at
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:468)
at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
64)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java
:174)
at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
66)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at
org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:
1027)
at
org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1125
)
at java.lang.Thread.run(Thread.java:484)
---------
java.lang.NullPointerException
at
org.apache.fop.fo.FOTreeBuilder.startDocument(FOTreeBuilder.java:167)
at
org.apache.xalan.transformer.QueuedStartDocument.flush(QueuedStartDocument.j
ava:108)
at
org.apache.xalan.transformer.ResultTreeHandler.flushPending(ResultTreeHandle
r.java:758)
at
org.apache.xalan.transformer.ResultTreeHandler.startElement(ResultTreeHandle
r.java:245)
at
org.apache.xalan.transformer.ResultTreeHandler.startElement(ResultTreeHandle
r.java:209)
at
org.apache.xalan.templates.ElemLiteralResult.execute(ElemLiteralResult.java:
704)
at
org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(Transform
erImpl.java:2154)
at
org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(Transform
erImpl.java:2097)
at
org.apache.xalan.transformer.TransformerImpl.applyTemplateToNode(Transformer
Impl.java:2029)
at
org.apache.xalan.transformer.TransformerImpl.transformNode(TransformerImpl.j
ava:1189)
at
org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:
479)
at
org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:
1118)
at
de.heine.ree.gui.action.PdfErstellenAction2.executePost(PdfErstellenAction2.
java:113)
at
de.heine.ree.gui.action.PrePostAction.executeAction(PrePostAction.java:64)
at
de.heine.ree.gui.action.AbstractAction.perform(AbstractAction.java:51)
at
org.apache.struts.action.ActionServlet.processActionPerform(ActionServlet.ja
va:1787)
at
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1586)
at
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:510)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application
FilterChain.java:247)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh
ain.java:193)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.ja
va:243)
at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
66)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.ja
va:190)
at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
66)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at
org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2347)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180
)
at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
66)
at
org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.
java:170)
at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
64)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170
)
at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
64)
at
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:468)
at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
64)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java
:174)
at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
66)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at
org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:
1027)
at
org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1125
)
at java.lang.Thread.run(Thread.java:484)
javax.servlet.ServletException
at
de.heine.ree.gui.action.PdfErstellenAction2.executePost(PdfErstellenAction2.
java:118)
at
de.heine.ree.gui.action.PrePostAction.executeAction(PrePostAction.java:64)
at
de.heine.ree.gui.action.AbstractAction.perform(AbstractAction.java:51)
at
org.apache.struts.action.ActionServlet.processActionPerform(ActionServlet.ja
va:1787)
at
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1586)
at
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:510)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application
FilterChain.java:247)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh
ain.java:193)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.ja
va:243)
at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
66)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.ja
va:190)
at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
66)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at
org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2347)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180
)
at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
66)
at
org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.
java:170)
at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
64)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170
)
at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
64)
at
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:468)
at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
64)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java
:174)
at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
66)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at
org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:
1027)
at
org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1125
)
at java.lang.Thread.run(Thread.java:484)
So, has anybody an idea where to look at ? As FOP writes out two lines
"building formatting object tree" I'm not quite sure, where problem results
from.
May anybody help me or, does have anybody some running sample-code ?
Thanks for ANY hint in advance.
Regards from south of germany,
Marcus
Re: Problem generating PDF from ECS-XMLDocument
Posted by "J.Pietschmann" <j3...@yahoo.de>.
M.Weiss wrote:
> I want to create a PDF-Document, embedding FOP in a servlet. Until know I
> got it up and running reading two files (XML-Data and XSL-Template), but now
> I try to only read the XSL-Template from HDD and to create the XML-Structure
> on the fly using apaches ECS. For this, I use the following code in the
> execute-method of the servlet:
...
> When running the servlet using TomCat4.0, I got the following StackTrace:
>
> building formatting object tree
> building formatting object tree
...
The real error is here:
> ---------
> java.lang.NullPointerException
> org.apache.fop.fo.FOTreeBuilder.startDocument(FOTreeBuilder.java:167)
and this just "can't happen". Which FOP version are you using?
The two "building formatting object tree" messages are weird,
I'm tempted to say this is a multithreading problem. Do you get
the exception consistently?
Another possibility is that the XSLT processor got a serious hiccup,
though this is really unlikely. Nevertheless, try a more recent
version or another processor, like Saxon.
J.Pietschmann
Re: How to set a Japanies Font?
Posted by Balaji Loganathan <ba...@yahoo.com>.
Check fop documentation,
there is an working example with complete
documentation.
Regards
Balaji
http://digital.yahoo.com.au - Yahoo! Digital How To
- Get the best out of your PC!
How to set a Japanies Font?
Posted by Raj Kumar Kundu <ra...@anshinsoft.com>.
Hi everybody,
I want to generate a PDF file in Japanies font. Is this possible using
FOP?
Best Regards,
Raj