It looks like I'm getting a good PDF file now. I've switched my code so it
reads

     Driver driver = new Driver();
     driver.setOutputStream(out);
     driver.setRenderer(Driver.RENDER_PDF);
     DefaultHandler handler = (DefaultHandler) driver.getContentHandler();

// new details on handler but nothing changed in my code there.
     handler.startDocument(...);
     handler.startElement(...);
     handler.characters(...);
     handler.endElement(...);
     handler.endDocument(...);

I was getting the null pointer exception when I set the renderer before
setting the OutputStream.  I no longer call run or render but still get a
good pdf file.  That must be handled by the SAX events going to the
OutputStream.

I'm getting an error message about "[ERROR]: Logger not set", which I can
fix with the following chunk of code.  Is there a better way to set up the
logger?  I'm not trying to start a logger discussion, just clean up my code
a little.

     Hierarchy hierarchy = Hierarchy.getDefaultHierarchy();
     PatternFormatter formatter = new PatternFormatter( "[%{priority}]:
%{message}\n%{throwable}" );
     LogTarget target = new StreamTarget(System.out, formatter);
     hierarchy.setDefaultLogTarget(target);
     Logger log = hierarchy.getLoggerFor("fop");
     log.setPriority(Priority.INFO);
     driver.setLogger( log );

Thanks again,

JohnPT



                                                                                       
                                                  
                    fop-dev-return-10924-jthaemlitz=oreillyauto.com@XML.               
                                                  
                    APACHE.ORG                                                 To:     
[EMAIL PROTECTED]                            
                                                                               cc:     
                                                  
                    10/17/01 11:49 AM                                          
Subject:     fireing SAX events in .20                    
                    Please respond to fop-dev                                          
                                                  
                                                                                       
                                                  
                                                                                       
                                                  




I'm trying to port my application from using FOP .18 to FOP .20.  My
application used to get the handler (FOTreeBuilder) from the Driver, then
fire SAX events on it.  In .20 I get a null pointer exception, I believe
this is because the InputStream never gets initialized.  Is there a way to
make this work in .20.2?

What the .18 code looks like
     Driver driver = new Driver();
     driver.setRenderer(Driver.RENDER_PDF);
     DefaultHandler handler = (DefaultHandler) driver.getContentHandler();
     ...
     driver.setOutputStream(out);
     driver.format();
     driver.render();

What I thought the .20 code should look like
     Driver driver = new Driver();
     driver.setRenderer(Driver.RENDER_PDF);
     driver.setOutputStream(out);
     DefaultHandler handler = (DefaultHandler) driver.getContentHandler();
     ...
     driver.run();

Thanks,

JohnPT





---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]









---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]

Reply via email to