Re: Capturing FOP logging message event in an embedded application using FOP 0.94

2007-11-14 Thread Michael Tracey Zellmann
Thanks for the response.

I am trying to think of a way to still succeed.

What I want to do is to send all logging messages from anything related to
FOP to their own file.

In the logging.properties, I tried:
org.apache.fop.FileHandler = java.util.logging.FileHandler
org.apache.fop.FileHandler.pattern = logs/docgen.log
org.apache.fop.FileHandler.limit = 5000
org.apache.fop.FileHandler.formatter = java.util.logging.SimpleFormatter

but that does not work.

I can say
java.util.logging.FileHandler.pattern = logs/docgenAll.log
and that will send all logging messages from any source to the file
docgenALL -
hwoever, I don't want all the messages - only ones froma class in the fop
hierarchy.

What should I do to accomplish this ?



On Nov 13, 2007 3:04 PM, Andreas L Delmelle [EMAIL PROTECTED] wrote:

 On Nov 13, 2007, at 18:29, Michael Tracey Zellmann wrote:

 Hi

  I have developed an application that generates PDFs of
  documentation in an eclipse environment controlled by a variety of
  SWT widgets.
 
  My customer would like his users to know when FOP has encountered a
  problem, but give them a simple message. We are already trapping
  exceptions, so I am interested in the kinds of events where FOP may
  generate a WARNING or SEVERE logging message. Like - the text has
  exceeded the allowed width and is overwriting another area, or the
  bookmark ids are pointing to a null view-port, for instance. I know
  how to write a File Handler to route those message to a file. Is
  there a way I can capture an event that will tell us to pop a
  dialog to the user, and hopefully get part of the logging message ?

 I fear you have stumbled upon a well-known shortcoming of FOP 0.9x:
 the error-reporting is not really what it should be. We all know it,
 but haven't found the time so far to take steps towards implementing
 something better, so exceptions and log messages are all there is to
 catch FTM... :(


 Sorry

 Andreas

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




Capturing FOP logging message event in an embedded application using FOP 0.94

2007-11-13 Thread Michael Tracey Zellmann
I have developed an application that generates PDFs of documentation in an
eclipse environment controlled by a variety of SWT widgets.

My customer would like his users to know when FOP has encountered a problem,
but give them a simple message. We are already trapping exceptions, so I am
interested in the kinds of events where FOP may generate a WARNING or SEVERE
logging message. Like - the text has exceeded the allowed width and is
overwriting another area, or the bookmark ids are pointing to a null
view-port, for instance. I know how to write a File Handler to route those
message to a file. Is there a way I can capture an event that will tell us
to pop a dialog to the user, and hopefully get part of the logging message ?


Re: getting FOP to work with Java using 0.94

2007-11-02 Thread Michael Tracey Zellmann
Thanks.

closing the OutputStream fixed my problem, and your way of getting the
xml file is clearly better.

I used to get a Fop instance directly from the constructor, but that
is deprecated now, in favor of the FopFactory. That was the change I
had encountered.

On Nov 2, 2007 3:41 AM, Jeremias Maerki [EMAIL PROTECTED] wrote:
 FOP's API hasn't changed. I don't remember any change in that area that
 could trigger this, but I could also be wrong. Anyway, what I'm missing
 in your code snippet is a try..finally around the code where the
 OutputStream is closed in the finally section. That omission is most
 likely the reason for the file corruption.

 As a side-note, it's inefficient to load the XML file as a DOM and then
 pass it to the XSL transformation. Please take a look at our examples
 and use a SAX-based approach:
 http://xmlgraphics.apache.org/fop/0.94/embedding.html#ExampleXML2PDF

 Jeremias Maerki




 On 02.11.2007 00:42:58 Michael Tracey Zellmann wrote:
  I was using 0.93 successfully some time ago, and I have another
  application to use,
  so I downloaded 0.94.
 
  I am using Java 1.5.0_11
 
  I tried to set things up correctly, but the PDF I generated can't be
  read by Adobe Reader 8. I get a message that the file has been damaged
  and can't be repaired.
 
  I have some code that reads a source document, builds an Fop from a
  FopFactory using MimeConstants.MIME_PDF and an OutputStream. I build a
  Transformer from a TransformerFactory using an XSLT file, get a
  SAXResult from the fop, and then transform the source into the result.
 
  I have tried a very simple style sheet but no success.
 
  Can anyone help me understand what is wrong, or point me to a basic
  example that will work with the new version?
 
  Here is the code:
 
 
 DocumentBuilderFactory dbf =
  DocumentBuilderFactory.newInstance();
 DocumentBuilder db = null;
 Document input = null;
 try {
 db = dbf.newDocumentBuilder();
 input = db.parse(new
  File(input/astruct/primitives/System.xml));
 } catch (ParserConfigurationException e) { 
  e.printStackTrace();
 } catch (SAXException e) { e.printStackTrace();
 } catch (IOException e) { e.printStackTrace(); }
 Source src = new DOMSource(input);
 FopFactory fopFactory = FopFactory.newInstance();
 OutputStream out = null;
 File outputDir = new File(output);
 File outputFile = new File(outputDir, System.pdf);
 try {
 out = new BufferedOutputStream(new
  FileOutputStream(outputFile));
 } catch (FileNotFoundException e) {e.printStackTrace();}
 Fop fop = null;
 try {
 fop = fopFactory.newFop(MimeConstants.MIME_PDF, out);
 } catch (FOPException e) { e.printStackTrace(); }
 File xsltFile = new File(xslt/module-fo.xslt);
 TransformerFactory trFactory = 
  TransformerFactory.newInstance();
 Transformer transformer = null;
 try {
 transformer = trFactory.newTransformer(new
  StreamSource(xsltFile));
 } catch (TransformerConfigurationException e)
  {e.printStackTrace();}
 Result res = null;
 try {
 res = new SAXResult(fop.getDefaultHandler());
 } catch (FOPException e) { e.printStackTrace(); }
 try {
 transformer.transform(src, res);
 } catch (TransformerException e) { e.printStackTrace();}
 


 -
 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]