Problem that could lose me my job

classic Classic list List threaded Threaded
22 messages Options
12
Reply | Threaded
Open this post in threaded view
|

Problem that could lose me my job

Theresa Jayne Forster

I have just come across a problem that may lose me my job unless I can resolve it.

1.       I am using Fop-1.0

2.       I create PDFs and then view them in Sumatra PDF – perfectly fine

3.       Try to open the same file in Adobe Acrobat – it reports that the file is corrupt and cannot be repaired..

 

Help please.

 

Kindest regards

 


Theresa Forster

Senior Software Developer

 

Reply | Threaded
Open this post in threaded view
|

Re: Problem that could lose me my job

Craig Ringer-2
On 3/02/2012 8:14 PM, Theresa Jayne Forster wrote:

I have just come across a problem that may lose me my job unless I can resolve it.

1.       I am using Fop-1.0

2.       I create PDFs and then view them in Sumatra PDF – perfectly fine

3.       Try to open the same file in Adobe Acrobat – it reports that the file is corrupt and cannot be repaired..

 

As a senior software developer, I'm sure you're aware that reports like this really need to be accompanied by details like:

- Sample files or reliable procedures for generating them;
- Sample input used to generate the problem files;
- Information about your environment (Java and OS version etc);
- Details about fonts, configuration, etc; and
- if at all possible a self-contained test case.

--
Craig Ringer
Reply | Threaded
Open this post in threaded view
|

RE: Problem that could lose me my job

Theresa Jayne Forster

Sorry, I was under pressure to roll back the servers that we had just upgraded to use the fop 1.0 system.

One of the failing PDFs is at http://www.inbrand1.co.uk/failsinadobe.pdf

The FO that generated it is at http://www.inbrand1.co.uk/failsinadobe.fo

 

The fopconfig has nothing except font configurations in it. A couple have kerning xml files as they produce incorrectly without.

 

The routine that produces the PDF is as follows

 

public File generatePDFromFO(File foFile) {

        OutputStream ot = null;

        BufferedOutputStream out = null;

        File tempFile = null;

        try {

            tempFile = File.createTempFile("W2P", ".pdf");

            out = new BufferedOutputStream( new FileOutputStream(tempFile));

            fopFactory.setStrictValidation(false);

            DefaultConfigurationBuilder cfgBuilder = new DefaultConfigurationBuilder();

            Configuration cfg = cfgBuilder.buildFromFile(new File("/fopconfig.xml"));

            fopFactory.setUserConfig(cfg);

            FOUserAgent useragent= fopFactory.newFOUserAgent();

            useragent.setTargetResolution(300);

            Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF,useragent,out);

            TransformerFactory factory = TransformerFactory.newInstance();

            Source src = new StreamSource(foFile);

            Transformer transformer = factory.newTransformer();

            Result res = new SAXResult(fop.getDefaultHandler());

            transformer.transform(src, res);   

        } catch (IOException ioe) {

            LOGGER.error("IOException ",ioe);

            ioe.printStackTrace();

        } catch (SAXException se) {

            LOGGER.error("Sax Exception ",se);

            se.printStackTrace();

        } catch (ConfigurationException ce) {

            LOGGER.error("Configuration Exception ",ce);

            ce.printStackTrace();

        } catch (TransformerConfigurationException tce) {

            LOGGER.error("Transformer Configuration Exception",tce);

            tce.printStackTrace();

        } catch (TransformerException te) {

            LOGGER.error("Transformer Exception ",te);

            te.printStackTrace();

        }

        return tempFile;

    }   

 

 

Fop config file here

 

<fop xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >

                <strict-configuration>true</strict-configuration>

                <base>C:\preprocessor\filestore\</base>

 

                <font-base>/Fonts</font-base>

 

                <cache-file>/fop-cache</cache-file>

                <!--

************************************************************************

  Add fonts here

************************************************************************

-->

                <renderers>

                                <renderer mime="application/pdf">

                                                <fonts>

                                                                <font embed-url="FRUTL___.TTF" kerning="yes" metrics-url="FrutigerLight.xml">

                                                                  <font-triplet name="Frutiger" style="normal" weight="200"/>

                                                                </font>                                                                               

                                                                <font embed-url="FRUTB___.TTF" kerning="yes">

                                                                  <font-triplet name="Frutiger" style="normal" weight="400"/>

                                                                </font>               

                                                                <font embed-url="tfarrow-medium.TTF">

                                                                  <font-triplet name="TFArrow" style="normal" weight="400"/>

                                                                </font>               

                                                                <font embed-url="HELVNBL_.TTF">

                                                                  <font-triplet name="HelveticaNeue" style="normal" weight="900"/>

                                                                </font>                                                               

                                                                <font embed-url="helveticaneue_85hv.ttf">

                                                                  <font-triplet name="HelveticaNeue" style="normal" weight="800"/>

                                                                </font>                                                               

                                                                <font embed-url="HELVNBI_.TTF">

                                                                  <font-triplet name="HelveticaNeue" style="italic" weight="700"/>

                                                                </font>                                                               

                                                                <font embed-url="HELVNM__.TTF">

                                                                  <font-triplet name="HelveticaNeue" style="normal" weight="500"/>

                                                                </font>               

                                                                <font embed-url="HELVNI__.TTF">

                                                                  <font-triplet name="HelveticaNeue" style="italic" weight="400"/>

                                                                </font>               

                                                                <font embed-url="lte50259.ttf">

                                                                  <font-triplet name="HelveticaNeue" style="normal" weight="400"/>

                                                                  <font-triplet name="HelveticaNeue" style="roman" weight="400"/>

                                                                </font>               

                                                                <font embed-url="HELVNL__.TTF">

                                                                  <font-triplet name="HelveticaNeue" style="normal" weight="300"/>

                                                                </font>               

                                                                <font embed-url="HELVNT__.TTF" kerning="yes" metrics-url="HelveticaNeueLight.xml">

                                                                  <font-triplet name="HelveticaNeue" style="normal" weight="200"/>

                                                                </font>               

                                                                <font embed-url="HELVNUL_.TTF">

                                                                  <font-triplet name="HelveticaNeue" style="normal" weight="100"/>

                                                                </font>               

                                                                <font embed-url="LTe50872.ttf">

                                                                                <font-triplet name="HelveticaNeueCond" style="normal" weight="400"/>

                                                                </font>

                                                                <font embed-url="LTe50874.ttf">

                                                                                <font-triplet name="HelveticaNeueCond" style="normal" weight="700"/>

                                                                </font>                                                               

                                                </fonts>

                                </renderer>

                                <renderer mime="image/png">

                                  <transparent-page-background>true</transparent-page-background>

                                  <fonts><auto-detect/></fonts>

                                </renderer>                     

                </renderers>   

</fop>

 

Kindest regards

 


Theresa Forster

Senior Software Developer

Reply | Threaded
Open this post in threaded view
|

Re: Problem that could lose me my job

David J.B.Hollis
Hi,

I've just opened the FO file in oXygen, and it throws up a number of errors:

@ margin-top not allowed in fo:region-start
@ z-index not allowed in fo:region-body
@ z-index not allowed in fo:region-before
@ z-index not allowed in fo:region-after

... about 20 or so in the fo:simple-page-master section

HTH
David




Sorry, I was under pressure to roll back the servers that we had just upgraded to use the fop 1.0 system.
One of the failing PDFs is at http://www.inbrand1.co.uk/failsinadobe.pdf
The FO that generated it is at http://www.inbrand1.co.uk/failsinadobe.fo
 
The fopconfig has nothing except font configurations in it. A couple have kerning xml files as they produce incorrectly without.
 
The routine that produces the PDF is as follows
 
public File generatePDFromFO(File foFile) {
        OutputStream ot = null;
        BufferedOutputStream out = null;
        File tempFile = null;
        try {
            tempFile = File.createTempFile("W2P", ".pdf");
            out = new BufferedOutputStream( new FileOutputStream(tempFile));
            fopFactory.setStrictValidation(false);
            DefaultConfigurationBuilder cfgBuilder = new DefaultConfigurationBuilder();
            Configuration cfg = cfgBuilder.buildFromFile(new File("/fopconfig.xml"));
            fopFactory.setUserConfig(cfg);
            FOUserAgent useragent= fopFactory.newFOUserAgent();
            useragent.setTargetResolution(300);
            Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF,useragent,out);
            TransformerFactory factory = TransformerFactory.newInstance();
            Source src = new StreamSource(foFile);
            Transformer transformer = factory.newTransformer();
            Result res = new SAXResult(fop.getDefaultHandler());
            transformer.transform(src, res);   
        } catch (IOException ioe) {
            LOGGER.error("IOException ",ioe);
            ioe.printStackTrace();
        } catch (SAXException se) {
            LOGGER.error("Sax Exception ",se);
            se.printStackTrace();
        } catch (ConfigurationException ce) {
            LOGGER.error("Configuration Exception ",ce);
            ce.printStackTrace();
        } catch (TransformerConfigurationException tce) {
            LOGGER.error("Transformer Configuration Exception",tce);
            tce.printStackTrace();
        } catch (TransformerException te) {
            LOGGER.error("Transformer Exception ",te);
            te.printStackTrace();
        }
        return tempFile;
    }   
 
 
Fop config file here
 
                <strict-configuration>true</strict-configuration>
                <base>C:\preprocessor\filestore\</base>
 
                <font-base>/Fonts</font-base>
 
                <cache-file>/fop-cache</cache-file>
                <!--
************************************************************************
  Add fonts here
************************************************************************
-->
                <renderers>
                                <renderer mime="application/pdf">
                                                <fonts>
                                                                <font embed-url="FRUTL___.TTF" kerning="yes" metrics-url="FrutigerLight.xml">
                                                                  <font-triplet name="Frutiger" style="normal" weight="200"/>
                                                                </font>                                                                               
                                                                <font embed-url="FRUTB___.TTF" kerning="yes">
                                                                  <font-triplet name="Frutiger" style="normal" weight="400"/>
                                                                </font>               
                                                                <font embed-url="tfarrow-medium.TTF">
                                                                  <font-triplet name="TFArrow" style="normal" weight="400"/>
                                                                </font>               
                                                                <font embed-url="HELVNBL_.TTF">
                                                                  <font-triplet name="HelveticaNeue" style="normal" weight="900"/>
                                                                </font>                                                               
                                                                <font embed-url="helveticaneue_85hv.ttf">
                                                                  <font-triplet name="HelveticaNeue" style="normal" weight="800"/>
                                                                </font>                                                               
                                                                <font embed-url="HELVNBI_.TTF">
                                                                  <font-triplet name="HelveticaNeue" style="italic" weight="700"/>
                                                                </font>                                                               
                                                                <font embed-url="HELVNM__.TTF">
                                                                  <font-triplet name="HelveticaNeue" style="normal" weight="500"/>
                                                                </font>               
                                                                <font embed-url="HELVNI__.TTF">
                                                                  <font-triplet name="HelveticaNeue" style="italic" weight="400"/>
                                                                </font>               
                                                                <font embed-url="lte50259.ttf">
                                                                  <font-triplet name="HelveticaNeue" style="normal" weight="400"/>
                                                                  <font-triplet name="HelveticaNeue" style="roman" weight="400"/>
                                                                </font>               
                                                                <font embed-url="HELVNL__.TTF">
                                                                  <font-triplet name="HelveticaNeue" style="normal" weight="300"/>
                                                                </font>               
                                                                <font embed-url="HELVNT__.TTF" kerning="yes" metrics-url="HelveticaNeueLight.xml">
                                                                  <font-triplet name="HelveticaNeue" style="normal" weight="200"/>
                                                                </font>               
                                                                <font embed-url="HELVNUL_.TTF">
                                                                  <font-triplet name="HelveticaNeue" style="normal" weight="100"/>
                                                                </font>               
                                                                <font embed-url="LTe50872.ttf">
                                                                                <font-triplet name="HelveticaNeueCond" style="normal" weight="400"/>
                                                                </font>
                                                                <font embed-url="LTe50874.ttf">
                                                                                <font-triplet name="HelveticaNeueCond" style="normal" weight="700"/>
                                                                </font>                                                               
                                                </fonts>
                                </renderer>
                                <renderer mime="image/png">
                                  <transparent-page-background>true</transparent-page-background>
                                  <fonts><auto-detect/></fonts>
                                </renderer>                     
                </renderers>   
</fop>
 
Kindest regards
 

Theresa Forster
Senior Software Developer


Reply | Threaded
Open this post in threaded view
|

RE: Problem that could lose me my job

Theresa Jayne Forster

Why would that make the output PDF invalid to Adobe and not to Sumatra pdf?

 

 

Kindest regards

 


Theresa Forster

Senior Software Developer

From: David J. B. Hollis [mailto:[hidden email]]
Sent: 03 February 2012 13:19
To: [hidden email]
Subject: Re: Problem that could lose me my job

 

Hi,

 

I've just opened the FO file in oXygen, and it throws up a number of errors:

 

@ margin-top not allowed in fo:region-start

@ z-index not allowed in fo:region-body

@ z-index not allowed in fo:region-before

@ z-index not allowed in fo:region-after

 

... about 20 or so in the fo:simple-page-master section

 

HTH

David

 

 

 



Sorry, I was under pressure to roll back the servers that we had just upgraded to use the fop 1.0 system.

One of the failing PDFs is at http://www.inbrand1.co.uk/failsinadobe.pdf

The FO that generated it is at http://www.inbrand1.co.uk/failsinadobe.fo

 

The fopconfig has nothing except font configurations in it. A couple have kerning xml files as they produce incorrectly without.

 

The routine that produces the PDF is as follows

 

public File generatePDFromFO(File foFile) {

        OutputStream ot = null;

        BufferedOutputStream out = null;

        File tempFile = null;

        try {

            tempFile = File.createTempFile("W2P", ".pdf");

            out = new BufferedOutputStream( new FileOutputStream(tempFile));

            fopFactory.setStrictValidation(false);

            DefaultConfigurationBuilder cfgBuilder = new DefaultConfigurationBuilder();

            Configuration cfg = cfgBuilder.buildFromFile(new File("/fopconfig.xml"));

            fopFactory.setUserConfig(cfg);

            FOUserAgent useragent= fopFactory.newFOUserAgent();

            useragent.setTargetResolution(300);

            Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF,useragent,out);

            TransformerFactory factory = TransformerFactory.newInstance();

            Source src = new StreamSource(foFile);

            Transformer transformer = factory.newTransformer();

            Result res = new SAXResult(fop.getDefaultHandler());

            transformer.transform(src, res);   

        } catch (IOException ioe) {

            LOGGER.error("IOException ",ioe);

            ioe.printStackTrace();

        } catch (SAXException se) {

            LOGGER.error("Sax Exception ",se);

            se.printStackTrace();

        } catch (ConfigurationException ce) {

            LOGGER.error("Configuration Exception ",ce);

            ce.printStackTrace();

        } catch (TransformerConfigurationException tce) {

            LOGGER.error("Transformer Configuration Exception",tce);

            tce.printStackTrace();

        } catch (TransformerException te) {

            LOGGER.error("Transformer Exception ",te);

            te.printStackTrace();

        }

        return tempFile;

    }   

 

 

Fop config file here

 

                <strict-configuration>true</strict-configuration>

                <base>C:\preprocessor\filestore\</base>

 

                <font-base>/Fonts</font-base>

 

                <cache-file>/fop-cache</cache-file>

                <!--

************************************************************************

  Add fonts here

************************************************************************

-->

                <renderers>

                                <renderer mime="application/pdf">

                                                <fonts>

                                                                <font embed-url="FRUTL___.TTF" kerning="yes" metrics-url="FrutigerLight.xml">

                                                                  <font-triplet name="Frutiger" style="normal" weight="200"/>

                                                                </font>                                                                               

                                                                <font embed-url="FRUTB___.TTF" kerning="yes">

                                                                  <font-triplet name="Frutiger" style="normal" weight="400"/>

                                                                </font>               

                                                                <font embed-url="tfarrow-medium.TTF">

                                                                  <font-triplet name="TFArrow" style="normal" weight="400"/>

                                                                </font>               

                                                                <font embed-url="HELVNBL_.TTF">

                                                                  <font-triplet name="HelveticaNeue" style="normal" weight="900"/>

                                                                </font>                                                               

                                                                <font embed-url="helveticaneue_85hv.ttf">

                                                                  <font-triplet name="HelveticaNeue" style="normal" weight="800"/>

                                                                </font>                                                               

                                                                <font embed-url="HELVNBI_.TTF">

                                                                  <font-triplet name="HelveticaNeue" style="italic" weight="700"/>

                                                                </font>                                                               

                                                                <font embed-url="HELVNM__.TTF">

                                                                  <font-triplet name="HelveticaNeue" style="normal" weight="500"/>

                                                                </font>               

                                                                <font embed-url="HELVNI__.TTF">

                                                                  <font-triplet name="HelveticaNeue" style="italic" weight="400"/>

                                                                </font>               

                                                                <font embed-url="lte50259.ttf">

                                                                  <font-triplet name="HelveticaNeue" style="normal" weight="400"/>

                                                                  <font-triplet name="HelveticaNeue" style="roman" weight="400"/>

                                                                </font>               

                                                                <font embed-url="HELVNL__.TTF">

                                                                  <font-triplet name="HelveticaNeue" style="normal" weight="300"/>

                                                                </font>               

                                                                <font embed-url="HELVNT__.TTF" kerning="yes" metrics-url="HelveticaNeueLight.xml">

                                                                  <font-triplet name="HelveticaNeue" style="normal" weight="200"/>

                                                                </font>               

                                                                <font embed-url="HELVNUL_.TTF">

                                                                  <font-triplet name="HelveticaNeue" style="normal" weight="100"/>

                                                                </font>               

                                                                <font embed-url="LTe50872.ttf">

                                                                                <font-triplet name="HelveticaNeueCond" style="normal" weight="400"/>

                                                                </font>

                                                                <font embed-url="LTe50874.ttf">

                                                                                <font-triplet name="HelveticaNeueCond" style="normal" weight="700"/>

                                                                </font>                                                               

                                                </fonts>

                                </renderer>

                                <renderer mime="image/png">

                                  <transparent-page-background>true</transparent-page-background>

                                  <fonts><auto-detect/></fonts>

                                </renderer>                     

                </renderers>   

</fop>

 

Kindest regards

 


Theresa Forster

Senior Software Developer


 

Reply | Threaded
Open this post in threaded view
|

Re: Problem that could lose me my job

mehdi houshmand
Hi Theresa,

The PDF you put up isn't complete, it's as if FOP stopped creating the
document for some reason. Was an exception thrown? Would there be any
reason why FOP wouldn't finish writing to file? If so, I'd suggest you
try FOP trunk as well to see if the same problem arises, if so, then
the stacktrace should give an indication as to what is causing the
problem.

Mehdi

On 3 February 2012 13:32, Theresa Jayne Forster <[hidden email]> wrote:

> Why would that make the output PDF invalid to Adobe and not to Sumatra pdf?
>
>
>
>
>
> Kindest regards
>
>
>
>
> Theresa Forster
>
> Senior Software Developer
>
> From: David J. B. Hollis [mailto:[hidden email]]
> Sent: 03 February 2012 13:19
> To: [hidden email]
> Subject: Re: Problem that could lose me my job
>
>
>
> Hi,
>
>
>
> I've just opened the FO file in oXygen, and it throws up a number of errors:
>
>
>
> @ margin-top not allowed in fo:region-start
>
> @ z-index not allowed in fo:region-body
>
> @ z-index not allowed in fo:region-before
>
> @ z-index not allowed in fo:region-after
>
>
>
> ... about 20 or so in the fo:simple-page-master section
>
>
>
> HTH
>
> David
>
>
>
>
>
>
>
>
>
> Sorry, I was under pressure to roll back the servers that we had just
> upgraded to use the fop 1.0 system.
>
> One of the failing PDFs is at http://www.inbrand1.co.uk/failsinadobe.pdf
>
> The FO that generated it is at http://www.inbrand1.co.uk/failsinadobe.fo
>
>
>
> The fopconfig has nothing except font configurations in it. A couple have
> kerning xml files as they produce incorrectly without.
>
>
>
> The routine that produces the PDF is as follows
>
>
>
> public File generatePDFromFO(File foFile) {
>
>         OutputStream ot = null;
>
>         BufferedOutputStream out = null;
>
>         File tempFile = null;
>
>         try {
>
>             tempFile = File.createTempFile("W2P", ".pdf");
>
>             out = new BufferedOutputStream( new FileOutputStream(tempFile));
>
>             fopFactory.setStrictValidation(false);
>
>             DefaultConfigurationBuilder cfgBuilder = new
> DefaultConfigurationBuilder();
>
>             Configuration cfg = cfgBuilder.buildFromFile(new
> File("/fopconfig.xml"));
>
>             fopFactory.setUserConfig(cfg);
>
>             FOUserAgent useragent= fopFactory.newFOUserAgent();
>
>             useragent.setTargetResolution(300);
>
>             Fop fop =
> fopFactory.newFop(MimeConstants.MIME_PDF,useragent,out);
>
>             TransformerFactory factory = TransformerFactory.newInstance();
>
>             Source src = new StreamSource(foFile);
>
>             Transformer transformer = factory.newTransformer();
>
>             Result res = new SAXResult(fop.getDefaultHandler());
>
>             transformer.transform(src, res);
>
>         } catch (IOException ioe) {
>
>             LOGGER.error("IOException ",ioe);
>
>             ioe.printStackTrace();
>
>         } catch (SAXException se) {
>
>             LOGGER.error("Sax Exception ",se);
>
>             se.printStackTrace();
>
>         } catch (ConfigurationException ce) {
>
>             LOGGER.error("Configuration Exception ",ce);
>
>             ce.printStackTrace();
>
>         } catch (TransformerConfigurationException tce) {
>
>             LOGGER.error("Transformer Configuration Exception",tce);
>
>             tce.printStackTrace();
>
>         } catch (TransformerException te) {
>
>             LOGGER.error("Transformer Exception ",te);
>
>             te.printStackTrace();
>
>         }
>
>         return tempFile;
>
>     }
>
>
>
>
>
> Fop config file here
>
>
>
> <fop xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >
>
>                 <strict-configuration>true</strict-configuration>
>
>                 <base>C:\preprocessor\filestore\</base>
>
>
>
>                 <font-base>/Fonts</font-base>
>
>
>
>                 <cache-file>/fop-cache</cache-file>
>
>                 <!--
>
> ************************************************************************
>
>   Add fonts here
>
> ************************************************************************
>
> -->
>
>                 <renderers>
>
>                                 <renderer mime="application/pdf">
>
>                                                 <fonts>
>
>                                                                 <font
> embed-url="FRUTL___.TTF" kerning="yes" metrics-url="FrutigerLight.xml">
>
>
> <font-triplet name="Frutiger" style="normal" weight="200"/>
>
>
> </font>
>
>                                                                 <font
> embed-url="FRUTB___.TTF" kerning="yes">
>
>
> <font-triplet name="Frutiger" style="normal" weight="400"/>
>
>
> </font>
>
>                                                                 <font
> embed-url="tfarrow-medium.TTF">
>
>
> <font-triplet name="TFArrow" style="normal" weight="400"/>
>
>
> </font>
>
>                                                                 <font
> embed-url="HELVNBL_.TTF">
>
>
> <font-triplet name="HelveticaNeue" style="normal" weight="900"/>
>
>
> </font>
>
>                                                                 <font
> embed-url="helveticaneue_85hv.ttf">
>
>
> <font-triplet name="HelveticaNeue" style="normal" weight="800"/>
>
>
> </font>
>
>                                                                 <font
> embed-url="HELVNBI_.TTF">
>
>
> <font-triplet name="HelveticaNeue" style="italic" weight="700"/>
>
>
> </font>
>
>                                                                 <font
> embed-url="HELVNM__.TTF">
>
>
> <font-triplet name="HelveticaNeue" style="normal" weight="500"/>
>
>
> </font>
>
>                                                                 <font
> embed-url="HELVNI__.TTF">
>
>
> <font-triplet name="HelveticaNeue" style="italic" weight="400"/>
>
>
> </font>
>
>                                                                 <font
> embed-url="lte50259.ttf">
>
>
> <font-triplet name="HelveticaNeue" style="normal" weight="400"/>
>
>
> <font-triplet name="HelveticaNeue" style="roman" weight="400"/>
>
>
> </font>
>
>                                                                 <font
> embed-url="HELVNL__.TTF">
>
>
> <font-triplet name="HelveticaNeue" style="normal" weight="300"/>
>
>
> </font>
>
>                                                                 <font
> embed-url="HELVNT__.TTF" kerning="yes" metrics-url="HelveticaNeueLight.xml">
>
>
> <font-triplet name="HelveticaNeue" style="normal" weight="200"/>
>
>
> </font>
>
>                                                                 <font
> embed-url="HELVNUL_.TTF">
>
>
> <font-triplet name="HelveticaNeue" style="normal" weight="100"/>
>
>
> </font>
>
>                                                                 <font
> embed-url="LTe50872.ttf">
>
>
> <font-triplet name="HelveticaNeueCond" style="normal" weight="400"/>
>
>                                                                 </font>
>
>                                                                 <font
> embed-url="LTe50874.ttf">
>
>
> <font-triplet name="HelveticaNeueCond" style="normal" weight="700"/>
>
>
> </font>
>
>                                                 </fonts>
>
>                                 </renderer>
>
>                                 <renderer mime="image/png">
>
>
> <transparent-page-background>true</transparent-page-background>
>
>                                   <fonts><auto-detect/></fonts>
>
>                                 </renderer>
>
>                 </renderers>
>
> </fop>
>
>
>
> Kindest regards
>
>
>
>
> Theresa Forster
>
> Senior Software Developer
>
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Problem that could lose me my job

Pascal Sancho
In reply to this post by Theresa Jayne Forster
Hi,

you should read FOP trace (from stdin or stderr).
This reveals what is wrong in your XSL-FO: FOP throws a lot of
exceptions, that prevent it to generate any PDF.

At least, your app should report you if PDF has been generated or not.


Le 03/02/2012 14:32, Theresa Jayne Forster a écrit :

> Why would that make the output PDF invalid to Adobe and not to Sumatra pdf?
>
> Kindest regards
>
> Theresa Forster
>
> Hi,
>
> I've just opened the FO file in oXygen, and it throws up a number of errors:
>
> @ margin-top not allowed in fo:region-start
> @ z-index not allowed in fo:region-body
> @ z-index not allowed in fo:region-before
> @ z-index not allowed in fo:region-after
>
> ... about 20 or so in the fo:simple-page-master section
>
> HTH
>
> David
>
> Sorry, I was under pressure to roll back the servers that we had just
> upgraded to use the fop 1.0 system.
>
> One of the failing PDFs is at http://www.inbrand1.co.uk/failsinadobe.pdf
>
> The FO that generated it is at http://www.inbrand1.co.uk/failsinadobe.fo
>
>  
>
> The fopconfig has nothing except font configurations in it. A couple
> have kerning xml files as they produce incorrectly without.
>
>  
>
> The routine that produces the PDF is as follows
>
>  
>
> public File generatePDFromFO(File foFile) {
>
>         OutputStream ot = null;
>
>         BufferedOutputStream out = null;
>
>         File tempFile = null;
>
>         try {
>
>             tempFile = File.createTempFile("W2P", ".pdf");
>
>             out = new BufferedOutputStream( new FileOutputStream(tempFile));
>
>             fopFactory.setStrictValidation(false);
>
>             DefaultConfigurationBuilder cfgBuilder = new
> DefaultConfigurationBuilder();
>
>             Configuration cfg = cfgBuilder.buildFromFile(new
> File("/fopconfig.xml"));
>
>             fopFactory.setUserConfig(cfg);
>
>             FOUserAgent useragent= fopFactory.newFOUserAgent();
>
>             useragent.setTargetResolution(300);
>
>             Fop fop =
> fopFactory.newFop(MimeConstants.MIME_PDF,useragent,out);
>
>             TransformerFactory factory = TransformerFactory.newInstance();
>
>             Source src = new StreamSource(foFile);
>
>             Transformer transformer = factory.newTransformer();
>
>             Result res = new SAXResult(fop.getDefaultHandler());
>
>             transformer.transform(src, res);  
>
>         } catch (IOException ioe) {
>
>             LOGGER.error("IOException ",ioe);
>
>             ioe.printStackTrace();
>
>         } catch (SAXException se) {
>
>             LOGGER.error("Sax Exception ",se);
>
>             se.printStackTrace();
>
>         } catch (ConfigurationException ce) {
>
>             LOGGER.error("Configuration Exception ",ce);
>
>             ce.printStackTrace();
>
>         } catch (TransformerConfigurationException tce) {
>
>             LOGGER.error("Transformer Configuration Exception",tce);
>
>             tce.printStackTrace();
>
>         } catch (TransformerException te) {
>
>             LOGGER.error("Transformer Exception ",te);
>
>             te.printStackTrace();
>
>         }
>
>         return tempFile;
>
>     }  
>
>  
>
>  
>
> Fop config file here
>
>  
>
> <fop xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >
>
>                 <strict-configuration>true</strict-configuration>
>
>                 <base>C:\preprocessor\filestore\</base>
>
>  
>
>                 <font-base>/Fonts</font-base>
>
>  
>
>                 <cache-file>/fop-cache</cache-file>
>
>                 <!--
>
> ************************************************************************
>
>   Add fonts here
>
> ************************************************************************
>
> -->
>
>                 <renderers>
>
>                                 <renderer mime="application/pdf">
>
>                                                 <fonts>
>
>                                                                 <font
> embed-url="FRUTL___.TTF" kerning="yes" metrics-url="FrutigerLight.xml">
>
>                                                                  
> <font-triplet name="Frutiger" style="normal" weight="200"/>
>
>                                                                
> </font>                                                                              
>
>                                                                 <font
> embed-url="FRUTB___.TTF" kerning="yes">
>
>                                                                  
> <font-triplet name="Frutiger" style="normal" weight="400"/>
>
>                                                                
> </font>              
>
>                                                                 <font
> embed-url="tfarrow-medium.TTF">
>
>                                                                  
> <font-triplet name="TFArrow" style="normal" weight="400"/>
>
>                                                                
> </font>              
>
>                                                                 <font
> embed-url="HELVNBL_.TTF">
>
>                                                                  
> <font-triplet name="HelveticaNeue" style="normal" weight="900"/>
>
>                                                                
> </font>                                                              
>
>                                                                 <font
> embed-url="helveticaneue_85hv.ttf">
>
>                                                                  
> <font-triplet name="HelveticaNeue" style="normal" weight="800"/>
>
>                                                                
> </font>                                                              
>
>                                                                 <font
> embed-url="HELVNBI_.TTF">
>
>                                                                  
> <font-triplet name="HelveticaNeue" style="italic" weight="700"/>
>
>                                                                
> </font>                                                              
>
>                                                                 <font
> embed-url="HELVNM__.TTF">
>
>                                                                  
> <font-triplet name="HelveticaNeue" style="normal" weight="500"/>
>
>                                                                
> </font>              
>
>                                                                 <font
> embed-url="HELVNI__.TTF">
>
>                                                                  
> <font-triplet name="HelveticaNeue" style="italic" weight="400"/>
>
>                                                                
> </font>              
>
>                                                                 <font
> embed-url="lte50259.ttf">
>
>                                                                  
> <font-triplet name="HelveticaNeue" style="normal" weight="400"/>
>
>                                                                  
> <font-triplet name="HelveticaNeue" style="roman" weight="400"/>
>
>                                                                
> </font>              
>
>                                                                 <font
> embed-url="HELVNL__.TTF">
>
>                                                                  
> <font-triplet name="HelveticaNeue" style="normal" weight="300"/>
>
>                                                                
> </font>              
>
>                                                                 <font
> embed-url="HELVNT__.TTF" kerning="yes" metrics-url="HelveticaNeueLight.xml">
>
>                                                                  
> <font-triplet name="HelveticaNeue" style="normal" weight="200"/>
>
>                                                                
> </font>              
>
>                                                                 <font
> embed-url="HELVNUL_.TTF">
>
>                                                                  
> <font-triplet name="HelveticaNeue" style="normal" weight="100"/>
>
>                                                                
> </font>              
>
>                                                                 <font
> embed-url="LTe50872.ttf">
>
>                                                                                
> <font-triplet name="HelveticaNeueCond" style="normal" weight="400"/>
>
>                                                                 </font>
>
>                                                                 <font
> embed-url="LTe50874.ttf">
>
>                                                                                
> <font-triplet name="HelveticaNeueCond" style="normal" weight="700"/>
>
>                                                                
> </font>                                                              
>
>                                                 </fonts>
>
>                                 </renderer>
>
>                                 <renderer mime="image/png">
>
>                                  
> <transparent-page-background>true</transparent-page-background>
>
>                                   <fonts><auto-detect/></fonts>
>
>                                 </renderer>                    
>
>                 </renderers>  
>
> </fop>
>
>  
>
> Kindest regards
>
>  
>
>
> Theresa Forster
>
> Senior Software Developer
>
>
>  
>

--
Pascal

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

Reply | Threaded
Open this post in threaded view
|

Re: Problem that could lose me my job

Craig Ringer-2
In reply to this post by Theresa Jayne Forster
On 3/02/2012 8:58 PM, Theresa Jayne Forster wrote:

Sorry, I was under pressure to roll back the servers that we had just upgraded to use the fop 1.0 system.

One of the failing PDFs is at http://www.inbrand1.co.uk/failsinadobe.pdf

The FO that generated it is at http://www.inbrand1.co.uk/failsinadobe.fo

 

"Adobe" (or even "Adobe Acrobat" or "Adobe Reader") can be a lot of different things. Versions are important.

That said, the PDF is clearly broken. Adobe Reader X fails with "There was an error opening this document. The file is damaged and could not be repaired". It isn't handled by Chrome either.

Re David's comment about the XSL-FO being non-confirming: If fop produces a broken PDF silently and without error output that is a fop bug, even if it's triggered by bad XSL-FO input. A warning should be emitted if valid PDF can be produced - though possibly not displaying how the author intended - but if no valid PDF can be produced that surely must be a fatal error. I know you're not actually saying it's *not* a fop bug, just being clear that IMO bad FO -> bad PDF *is* a fop bug.

However, looking at your code below, I see little reason to believe this is a fop bug. All you've shown so far is that your code ignores errors if fop does tell you about them. Have you looked at your application's error logs to see if fop is throwing an exception and if so, what? That's the only place you'll see errors since your code otherwise ignores them:

        } catch (IOException ioe) {

            LOGGER.error("IOException ",ioe);

            ioe.printStackTrace();

        } catch (SAXException se) {

            LOGGER.error("Sax Exception ",se);

            se.printStackTrace();

        } catch (ConfigurationException ce) {

            LOGGER.error("Configuration Exception ",ce);

            ce.printStackTrace();

        } catch (TransformerConfigurationException tce) {

            LOGGER.error("Transformer Configuration Exception",tce);

            tce.printStackTrace();

        } catch (TransformerException te) {

            LOGGER.error("Transformer Exception ",te);

            te.printStackTrace();

        }

        return tempFile;



... that's some "interesting" error handling code. LOGGER clearly doesn't throw another (wrapping) exception since otherwise `te.printStackTrace()' would never be getting executed. That means your code is logging an error (two different ways) then IGNORING IT.

Not only is that error handling code rather skeezy, but you assign a value to tempFile early on and do not clear it when an error occurs, so you MAY RETURN A HALF-WRITTEN GARBAGE FILE TO THE CALLER if an error occurs.

I strongly advise you to fix your error handling code and re-test. There are at least a few bugs in that code:

- After some errors you may return a handle to an incompletely written temp file without any indication it's broken

- You don't close your file handle(s) or streams, so you're relying on the objects' finialisation to do it for you when the gc gets
  around to cleaning them up. This is not usually a good idea. You really need to be using try{}finally{} blocks to clean up
  resources like this.

Try correcting your error handling code and seeing if the problem changes.

Please also send any messages fop 1.0 logs with detailed logging enabled when it is producing the faulty PDF. I'm sure you've looked at the logs as part of basic first-step troubleshooting anyway, so you should have no problem bringing them to hand...

Here's a 30-second quickly hacked out version of how I'd want to tweak this. I haven't tested this code and don't claim I'm any expert, I'm just sure it's closer than what you're using right now:

    // Of course you'd use your app's real exception classes instead of this demo
    // scratch code....
    public class MyApplicationRuntimeException extends RuntimeException {
        public MyApplicationRuntimeException(Throwable err) { super(err); }
        public MyApplicationRuntimeException(String msg) { super(msg); }
        public MyApplicationRuntimeException(String msg, Throwable err) { super(msg,err); }
    }

    public File generatePDFromFO(File foFile) {
        File tempFile = File.createTempFile("W2P", ".pdf");
        try {
            fopFactory.setStrictValidation(false);  // <--  This is a **HINT** you're doing something **WRONG**
            DefaultConfigurationBuilder cfgBuilder = new DefaultConfigurationBuilder();
            Configuration cfg = cfgBuilder.buildFromFile(new File("/fopconfig.xml"));  // <-- You're reparsing and re-applying the config for each file?!?
            fopFactory.setUserConfig(cfg);
            FOUserAgent useragent = fopFactory.newFOUserAgent();
            useragent.setTargetResolution(300);
            TransformerFactory factory = TransformerFactory.newInstance();
            BufferedOutputSteam out = new BufferedOutputStream(new FileOutputStream(tempFile));
            try {
                Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF,useragent,out);
                Source src = new StreamSource(foFile);
                Transformer transformer = factory.newTransformer();
                Result res = new SAXResult(fop.getDefaultHandler());
                transformer.transform(src, res);
                return tempFile;
            } finally {
                // Always close the output stream when we're done.
                //
                // See: Apache IOUtils. You can do the same thing more verbosely
                // by hand with another try/catch block.
                IOUtils.closeQuietly(out);
            }
        // For the following I'd use a Java 7 multi-catch to reduce the repetition
        // or if limited to Java <= 6 I'd assign the exception to a local variable
        // and fall out of the catch  in each clause, so I could use the same 3 lines
        // once at the end of the method to handle all error cases together. Up to you
        // though, that's just style preference so I've left it how you had it.
        } catch (IOException ioe) {
            tempFile.delete(); // Get rid of the failed tempfile if it was created, ignoring error
            LOGGER.error("IOException ",ioe);
            throw new MyApplicationRuntimeException("I/O error while producing PDF from XSL-FO", ioe);
        } catch (SAXException se) {
            tempFile.delete();
            LOGGER.error("Sax Exception ",se);
            throw new MyApplicationRuntimeException("SAX XML error while producing PDF from XSL-FO", ioe);
        } catch (ConfigurationException ce) {
            tempFile.delete();
            LOGGER.error("Configuration Exception ",ce);
            throw new MyApplicationRuntimeException("Fop configuration error while producing PDF from XSL-FO", ioe);
        } catch (TransformerConfigurationException tce) {
            tempFile.delete();
            LOGGER.error("Transformer Configuration Exception",tce);
            throw new MyApplicationRuntimeException("XML Tranformer configuration error while producing PDF from XSL-FO", ioe);
        } catch (TransformerException te) {
            tempFile.delete();
            LOGGER.error("Transformer Exception ",te);
            throw new MyApplicationRuntimeException("XML transformer error while producing PDF from XSL-FO", ioe);
        }
    }
  }
Reply | Threaded
Open this post in threaded view
|

RE: Problem that could lose me my job

Theresa Jayne Forster
In reply to this post by mehdi houshmand
Ok I have put the complete log for the generation on a gist as it is Waaaaay
to big to post here https://gist.github.com/1730300
I will check the code I have that sends the pdf to the client then check it
is flushing and completing before deleting the file to prevent clutter
Maybe I need to change my fileisreadystrategy


Thanks for the heads up there at least it gives me somewhere to look.


Kindest regards


Theresa Forster
Senior Software Developer

-----Original Message-----
From: mehdi houshmand [mailto:[hidden email]]
Sent: 03 February 2012 13:51
To: [hidden email]
Subject: Re: Problem that could lose me my job

Hi Theresa,

The PDF you put up isn't complete, it's as if FOP stopped creating the
document for some reason. Was an exception thrown? Would there be any
reason why FOP wouldn't finish writing to file? If so, I'd suggest you
try FOP trunk as well to see if the same problem arises, if so, then
the stacktrace should give an indication as to what is causing the
problem.

Mehdi

On 3 February 2012 13:32, Theresa Jayne Forster <[hidden email]>
wrote:
> Why would that make the output PDF invalid to Adobe and not to Sumatra
pdf?

>
>
>
>
>
> Kindest regards
>
>
>
>
> Theresa Forster
>
> Senior Software Developer
>
> From: David J. B. Hollis [mailto:[hidden email]]
> Sent: 03 February 2012 13:19
> To: [hidden email]
> Subject: Re: Problem that could lose me my job
>
>
>
> Hi,
>
>
>
> I've just opened the FO file in oXygen, and it throws up a number of
errors:

>
>
>
> @ margin-top not allowed in fo:region-start
>
> @ z-index not allowed in fo:region-body
>
> @ z-index not allowed in fo:region-before
>
> @ z-index not allowed in fo:region-after
>
>
>
> ... about 20 or so in the fo:simple-page-master section
>
>
>
> HTH
>
> David
>
>
>
>
>
>
>
>
>
> Sorry, I was under pressure to roll back the servers that we had just
> upgraded to use the fop 1.0 system.
>
> One of the failing PDFs is at http://www.inbrand1.co.uk/failsinadobe.pdf
>
> The FO that generated it is at http://www.inbrand1.co.uk/failsinadobe.fo
>
>
>
> The fopconfig has nothing except font configurations in it. A couple have
> kerning xml files as they produce incorrectly without.
>
>
>
> The routine that produces the PDF is as follows
>
>
>
> public File generatePDFromFO(File foFile) {
>
>         OutputStream ot = null;
>
>         BufferedOutputStream out = null;
>
>         File tempFile = null;
>
>         try {
>
>             tempFile = File.createTempFile("W2P", ".pdf");
>
>             out = new BufferedOutputStream( new
FileOutputStream(tempFile));

>
>             fopFactory.setStrictValidation(false);
>
>             DefaultConfigurationBuilder cfgBuilder = new
> DefaultConfigurationBuilder();
>
>             Configuration cfg = cfgBuilder.buildFromFile(new
> File("/fopconfig.xml"));
>
>             fopFactory.setUserConfig(cfg);
>
>             FOUserAgent useragent= fopFactory.newFOUserAgent();
>
>             useragent.setTargetResolution(300);
>
>             Fop fop =
> fopFactory.newFop(MimeConstants.MIME_PDF,useragent,out);
>
>             TransformerFactory factory = TransformerFactory.newInstance();
>
>             Source src = new StreamSource(foFile);
>
>             Transformer transformer = factory.newTransformer();
>
>             Result res = new SAXResult(fop.getDefaultHandler());
>
>             transformer.transform(src, res);
>
>         } catch (IOException ioe) {
>
>             LOGGER.error("IOException ",ioe);
>
>             ioe.printStackTrace();
>
>         } catch (SAXException se) {
>
>             LOGGER.error("Sax Exception ",se);
>
>             se.printStackTrace();
>
>         } catch (ConfigurationException ce) {
>
>             LOGGER.error("Configuration Exception ",ce);
>
>             ce.printStackTrace();
>
>         } catch (TransformerConfigurationException tce) {
>
>             LOGGER.error("Transformer Configuration Exception",tce);
>
>             tce.printStackTrace();
>
>         } catch (TransformerException te) {
>
>             LOGGER.error("Transformer Exception ",te);
>
>             te.printStackTrace();
>
>         }
>
>         return tempFile;
>
>     }
>
>
>
>
>
> Fop config file here
>
>
>
> <fop xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >
>
>                 <strict-configuration>true</strict-configuration>
>
>                 <base>C:\preprocessor\filestore\</base>
>
>
>
>                 <font-base>/Fonts</font-base>
>
>
>
>                 <cache-file>/fop-cache</cache-file>
>
>                 <!--
>
> ************************************************************************
>
>   Add fonts here
>
> ************************************************************************
>
> -->
>
>                 <renderers>
>
>                                 <renderer mime="application/pdf">
>
>                                                 <fonts>
>
>                                                                 <font
> embed-url="FRUTL___.TTF" kerning="yes" metrics-url="FrutigerLight.xml">
>
>
> <font-triplet name="Frutiger" style="normal" weight="200"/>
>
>
> </font>
>
>                                                                 <font
> embed-url="FRUTB___.TTF" kerning="yes">
>
>
> <font-triplet name="Frutiger" style="normal" weight="400"/>
>
>
> </font>
>
>                                                                 <font
> embed-url="tfarrow-medium.TTF">
>
>
> <font-triplet name="TFArrow" style="normal" weight="400"/>
>
>
> </font>
>
>                                                                 <font
> embed-url="HELVNBL_.TTF">
>
>
> <font-triplet name="HelveticaNeue" style="normal" weight="900"/>
>
>
> </font>
>
>                                                                 <font
> embed-url="helveticaneue_85hv.ttf">
>
>
> <font-triplet name="HelveticaNeue" style="normal" weight="800"/>
>
>
> </font>
>
>                                                                 <font
> embed-url="HELVNBI_.TTF">
>
>
> <font-triplet name="HelveticaNeue" style="italic" weight="700"/>
>
>
> </font>
>
>                                                                 <font
> embed-url="HELVNM__.TTF">
>
>
> <font-triplet name="HelveticaNeue" style="normal" weight="500"/>
>
>
> </font>
>
>                                                                 <font
> embed-url="HELVNI__.TTF">
>
>
> <font-triplet name="HelveticaNeue" style="italic" weight="400"/>
>
>
> </font>
>
>                                                                 <font
> embed-url="lte50259.ttf">
>
>
> <font-triplet name="HelveticaNeue" style="normal" weight="400"/>
>
>
> <font-triplet name="HelveticaNeue" style="roman" weight="400"/>
>
>
> </font>
>
>                                                                 <font
> embed-url="HELVNL__.TTF">
>
>
> <font-triplet name="HelveticaNeue" style="normal" weight="300"/>
>
>
> </font>
>
>                                                                 <font
> embed-url="HELVNT__.TTF" kerning="yes"
metrics-url="HelveticaNeueLight.xml">

>
>
> <font-triplet name="HelveticaNeue" style="normal" weight="200"/>
>
>
> </font>
>
>                                                                 <font
> embed-url="HELVNUL_.TTF">
>
>
> <font-triplet name="HelveticaNeue" style="normal" weight="100"/>
>
>
> </font>
>
>                                                                 <font
> embed-url="LTe50872.ttf">
>
>
> <font-triplet name="HelveticaNeueCond" style="normal" weight="400"/>
>
>                                                                 </font>
>
>                                                                 <font
> embed-url="LTe50874.ttf">
>
>
> <font-triplet name="HelveticaNeueCond" style="normal" weight="700"/>
>
>
> </font>
>
>                                                 </fonts>
>
>                                 </renderer>
>
>                                 <renderer mime="image/png">
>
>
> <transparent-page-background>true</transparent-page-background>
>
>                                   <fonts><auto-detect/></fonts>
>
>                                 </renderer>
>
>                 </renderers>
>
> </fop>
>
>
>
> Kindest regards
>
>
>
>
> Theresa Forster
>
> Senior Software Developer
>
>
>
Reply | Threaded
Open this post in threaded view
|

RE: Problem that could lose me my job

Theresa Jayne Forster
In reply to this post by Craig Ringer-2

The stacktraces were added to allow me to quickly debug without trapesing through the mega log that log4J is spewing out from the whole system (I know its wrong hell I cringe whenever I see some of the code but it is based on the old system just upgraded for Fop 1.0 as the old system was 0.23 with a handful of custom addons like accepting font-weight=”bold” and z-index=”2” to using a bare 1.0

 

 

Kindest regards

 


Theresa Forster

Senior Software Developer

From: Craig Ringer [mailto:[hidden email]]
Sent: 03 February 2012 14:00
To: [hidden email]
Cc: Theresa Jayne Forster
Subject: Re: Problem that could lose me my job

 

On 3/02/2012 8:58 PM, Theresa Jayne Forster wrote:

Sorry, I was under pressure to roll back the servers that we had just upgraded to use the fop 1.0 system.

One of the failing PDFs is at http://www.inbrand1.co.uk/failsinadobe.pdf

The FO that generated it is at http://www.inbrand1.co.uk/failsinadobe.fo

 

"Adobe" (or even "Adobe Acrobat" or "Adobe Reader") can be a lot of different things. Versions are important.

That said, the PDF is clearly broken. Adobe Reader X fails with "There was an error opening this document. The file is damaged and could not be repaired". It isn't handled by Chrome either.

Re David's comment about the XSL-FO being non-confirming: If fop produces a broken PDF silently and without error output that is a fop bug, even if it's triggered by bad XSL-FO input. A warning should be emitted if valid PDF can be produced - though possibly not displaying how the author intended - but if no valid PDF can be produced that surely must be a fatal error. I know you're not actually saying it's *not* a fop bug, just being clear that IMO bad FO -> bad PDF *is* a fop bug.

However, looking at your code below, I see little reason to believe this is a fop bug. All you've shown so far is that your code ignores errors if fop does tell you about them. Have you looked at your application's error logs to see if fop is throwing an exception and if so, what? That's the only place you'll see errors since your code otherwise ignores them:


        } catch (IOException ioe) {

            LOGGER.error("IOException ",ioe);

            ioe.printStackTrace();

        } catch (SAXException se) {

            LOGGER.error("Sax Exception ",se);

            se.printStackTrace();

        } catch (ConfigurationException ce) {

            LOGGER.error("Configuration Exception ",ce);

            ce.printStackTrace();

        } catch (TransformerConfigurationException tce) {

            LOGGER.error("Transformer Configuration Exception",tce);

            tce.printStackTrace();

        } catch (TransformerException te) {

            LOGGER.error("Transformer Exception ",te);

            te.printStackTrace();

        }

        return tempFile;

 


... that's some "interesting" error handling code. LOGGER clearly doesn't throw another (wrapping) exception since otherwise `te.printStackTrace()' would never be getting executed. That means your code is logging an error (two different ways) then IGNORING IT.

Not only is that error handling code rather skeezy, but you assign a value to tempFile early on and do not clear it when an error occurs, so you MAY RETURN A HALF-WRITTEN GARBAGE FILE TO THE CALLER if an error occurs.

I strongly advise you to fix your error handling code and re-test. There are at least a few bugs in that code:

- After some errors you may return a handle to an incompletely written temp file without any indication it's broken

- You don't close your file handle(s) or streams, so you're relying on the objects' finialisation to do it for you when the gc gets
  around to cleaning them up. This is not usually a good idea. You really need to be using try{}finally{} blocks to clean up
  resources like this.

Try correcting your error handling code and seeing if the problem changes.

Please also send any messages fop 1.0 logs with detailed logging enabled when it is producing the faulty PDF. I'm sure you've looked at the logs as part of basic first-step troubleshooting anyway, so you should have no problem bringing them to hand...

Here's a 30-second quickly hacked out version of how I'd want to tweak this. I haven't tested this code and don't claim I'm any expert, I'm just sure it's closer than what you're using right now:

    // Of course you'd use your app's real exception classes instead of this demo
    // scratch code....
    public class MyApplicationRuntimeException extends RuntimeException {
        public MyApplicationRuntimeException(Throwable err) { super(err); }
        public MyApplicationRuntimeException(String msg) { super(msg); }
        public MyApplicationRuntimeException(String msg, Throwable err) { super(msg,err); }
    }

    public File generatePDFromFO(File foFile) {
        File tempFile = File.createTempFile("W2P", ".pdf");
        try {
            fopFactory.setStrictValidation(false);  // <--  This is a **HINT** you're doing something **WRONG**
            DefaultConfigurationBuilder cfgBuilder = new DefaultConfigurationBuilder();
            Configuration cfg = cfgBuilder.buildFromFile(new File("/fopconfig.xml"));  // <-- You're reparsing and re-applying the config for each file?!?
            fopFactory.setUserConfig(cfg);
            FOUserAgent useragent = fopFactory.newFOUserAgent();
            useragent.setTargetResolution(300);
            TransformerFactory factory = TransformerFactory.newInstance();
            BufferedOutputSteam out = new BufferedOutputStream(new FileOutputStream(tempFile));
            try {
                Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF,useragent,out);
                Source src = new StreamSource(foFile);
                Transformer transformer = factory.newTransformer();
                Result res = new SAXResult(fop.getDefaultHandler());
                transformer.transform(src, res);
                return tempFile;
            } finally {
                // Always close the output stream when we're done.
                //
                // See: Apache IOUtils. You can do the same thing more verbosely
                // by hand with another try/catch block.
                IOUtils.closeQuietly(out);
            }
        // For the following I'd use a Java 7 multi-catch to reduce the repetition
        // or if limited to Java <= 6 I'd assign the exception to a local variable
        // and fall out of the catch  in each clause, so I could use the same 3 lines
        // once at the end of the method to handle all error cases together. Up to you
        // though, that's just style preference so I've left it how you had it.
        } catch (IOException ioe) {
            tempFile.delete(); // Get rid of the failed tempfile if it was created, ignoring error
            LOGGER.error("IOException ",ioe);
            throw new MyApplicationRuntimeException("I/O error while producing PDF from XSL-FO", ioe);
        } catch (SAXException se) {
            tempFile.delete();
            LOGGER.error("Sax Exception ",se);
            throw new MyApplicationRuntimeException("SAX XML error while producing PDF from XSL-FO", ioe);
        } catch (ConfigurationException ce) {
            tempFile.delete();
            LOGGER.error("Configuration Exception ",ce);
            throw new MyApplicationRuntimeException("Fop configuration error while producing PDF from XSL-FO", ioe);
        } catch (TransformerConfigurationException tce) {
            tempFile.delete();
            LOGGER.error("Transformer Configuration Exception",tce);
            throw new MyApplicationRuntimeException("XML Tranformer configuration error while producing PDF from XSL-FO", ioe);
        } catch (TransformerException te) {
            tempFile.delete();
            LOGGER.error("Transformer Exception ",te);
            throw new MyApplicationRuntimeException("XML transformer error while producing PDF from XSL-FO", ioe);
        }
    }
  }

Reply | Threaded
Open this post in threaded view
|

RE: Problem that could lose me my job

Theresa Jayne Forster
In reply to this post by Theresa Jayne Forster
Ok Checked the deletion code, it doesn’t appear to be that , I stopped that
part happening but the pdf is still ending up corrupt for adobe and Foxit
(but still valid with no errors on Sumatra PDF)  

Kindest regards
Theresa Forster
Senior Software Developer

-----Original Message-----
From: Theresa Jayne Forster [mailto:[hidden email]]
Sent: 03 February 2012 14:06
To: [hidden email]
Subject: RE: Problem that could lose me my job

Ok I have put the complete log for the generation on a gist as it is Waaaaay
to big to post here https://gist.github.com/1730300
I will check the code I have that sends the pdf to the client then check it
is flushing and completing before deleting the file to prevent clutter
Maybe I need to change my fileisreadystrategy


Thanks for the heads up there at least it gives me somewhere to look.


Kindest regards


Theresa Forster
Senior Software Developer

-----Original Message-----
From: mehdi houshmand [mailto:[hidden email]]
Sent: 03 February 2012 13:51
To: [hidden email]
Subject: Re: Problem that could lose me my job

Hi Theresa,

The PDF you put up isn't complete, it's as if FOP stopped creating the
document for some reason. Was an exception thrown? Would there be any
reason why FOP wouldn't finish writing to file? If so, I'd suggest you
try FOP trunk as well to see if the same problem arises, if so, then
the stacktrace should give an indication as to what is causing the
problem.

Mehdi

On 3 February 2012 13:32, Theresa Jayne Forster <[hidden email]>
wrote:
> Why would that make the output PDF invalid to Adobe and not to Sumatra
pdf?

>
>
>
>
>
> Kindest regards
>
>
>
>
> Theresa Forster
>
> Senior Software Developer
>
> From: David J. B. Hollis [mailto:[hidden email]]
> Sent: 03 February 2012 13:19
> To: [hidden email]
> Subject: Re: Problem that could lose me my job
>
>
>
> Hi,
>
>
>
> I've just opened the FO file in oXygen, and it throws up a number of
errors:

>
>
>
> @ margin-top not allowed in fo:region-start
>
> @ z-index not allowed in fo:region-body
>
> @ z-index not allowed in fo:region-before
>
> @ z-index not allowed in fo:region-after
>
>
>
> ... about 20 or so in the fo:simple-page-master section
>
>
>
> HTH
>
> David
>
>
>
>
>
>
>
>
>
> Sorry, I was under pressure to roll back the servers that we had just
> upgraded to use the fop 1.0 system.
>
> One of the failing PDFs is at http://www.inbrand1.co.uk/failsinadobe.pdf
>
> The FO that generated it is at http://www.inbrand1.co.uk/failsinadobe.fo
>
>
>
> The fopconfig has nothing except font configurations in it. A couple have
> kerning xml files as they produce incorrectly without.
>
>
>
> The routine that produces the PDF is as follows
>
>
>
> public File generatePDFromFO(File foFile) {
>
>         OutputStream ot = null;
>
>         BufferedOutputStream out = null;
>
>         File tempFile = null;
>
>         try {
>
>             tempFile = File.createTempFile("W2P", ".pdf");
>
>             out = new BufferedOutputStream( new
FileOutputStream(tempFile));

>
>             fopFactory.setStrictValidation(false);
>
>             DefaultConfigurationBuilder cfgBuilder = new
> DefaultConfigurationBuilder();
>
>             Configuration cfg = cfgBuilder.buildFromFile(new
> File("/fopconfig.xml"));
>
>             fopFactory.setUserConfig(cfg);
>
>             FOUserAgent useragent= fopFactory.newFOUserAgent();
>
>             useragent.setTargetResolution(300);
>
>             Fop fop =
> fopFactory.newFop(MimeConstants.MIME_PDF,useragent,out);
>
>             TransformerFactory factory = TransformerFactory.newInstance();
>
>             Source src = new StreamSource(foFile);
>
>             Transformer transformer = factory.newTransformer();
>
>             Result res = new SAXResult(fop.getDefaultHandler());
>
>             transformer.transform(src, res);
>
>         } catch (IOException ioe) {
>
>             LOGGER.error("IOException ",ioe);
>
>             ioe.printStackTrace();
>
>         } catch (SAXException se) {
>
>             LOGGER.error("Sax Exception ",se);
>
>             se.printStackTrace();
>
>         } catch (ConfigurationException ce) {
>
>             LOGGER.error("Configuration Exception ",ce);
>
>             ce.printStackTrace();
>
>         } catch (TransformerConfigurationException tce) {
>
>             LOGGER.error("Transformer Configuration Exception",tce);
>
>             tce.printStackTrace();
>
>         } catch (TransformerException te) {
>
>             LOGGER.error("Transformer Exception ",te);
>
>             te.printStackTrace();
>
>         }
>
>         return tempFile;
>
>     }
>
>
>
>
>
> Fop config file here
>
>
>
> <fop xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >
>
>                 <strict-configuration>true</strict-configuration>
>
>                 <base>C:\preprocessor\filestore\</base>
>
>
>
>                 <font-base>/Fonts</font-base>
>
>
>
>                 <cache-file>/fop-cache</cache-file>
>
>                 <!--
>
> ************************************************************************
>
>   Add fonts here
>
> ************************************************************************
>
> -->
>
>                 <renderers>
>
>                                 <renderer mime="application/pdf">
>
>                                                 <fonts>
>
>                                                                 <font
> embed-url="FRUTL___.TTF" kerning="yes" metrics-url="FrutigerLight.xml">
>
>
> <font-triplet name="Frutiger" style="normal" weight="200"/>
>
>
> </font>
>
>                                                                 <font
> embed-url="FRUTB___.TTF" kerning="yes">
>
>
> <font-triplet name="Frutiger" style="normal" weight="400"/>
>
>
> </font>
>
>                                                                 <font
> embed-url="tfarrow-medium.TTF">
>
>
> <font-triplet name="TFArrow" style="normal" weight="400"/>
>
>
> </font>
>
>                                                                 <font
> embed-url="HELVNBL_.TTF">
>
>
> <font-triplet name="HelveticaNeue" style="normal" weight="900"/>
>
>
> </font>
>
>                                                                 <font
> embed-url="helveticaneue_85hv.ttf">
>
>
> <font-triplet name="HelveticaNeue" style="normal" weight="800"/>
>
>
> </font>
>
>                                                                 <font
> embed-url="HELVNBI_.TTF">
>
>
> <font-triplet name="HelveticaNeue" style="italic" weight="700"/>
>
>
> </font>
>
>                                                                 <font
> embed-url="HELVNM__.TTF">
>
>
> <font-triplet name="HelveticaNeue" style="normal" weight="500"/>
>
>
> </font>
>
>                                                                 <font
> embed-url="HELVNI__.TTF">
>
>
> <font-triplet name="HelveticaNeue" style="italic" weight="400"/>
>
>
> </font>
>
>                                                                 <font
> embed-url="lte50259.ttf">
>
>
> <font-triplet name="HelveticaNeue" style="normal" weight="400"/>
>
>
> <font-triplet name="HelveticaNeue" style="roman" weight="400"/>
>
>
> </font>
>
>                                                                 <font
> embed-url="HELVNL__.TTF">
>
>
> <font-triplet name="HelveticaNeue" style="normal" weight="300"/>
>
>
> </font>
>
>                                                                 <font
> embed-url="HELVNT__.TTF" kerning="yes"
metrics-url="HelveticaNeueLight.xml">

>
>
> <font-triplet name="HelveticaNeue" style="normal" weight="200"/>
>
>
> </font>
>
>                                                                 <font
> embed-url="HELVNUL_.TTF">
>
>
> <font-triplet name="HelveticaNeue" style="normal" weight="100"/>
>
>
> </font>
>
>                                                                 <font
> embed-url="LTe50872.ttf">
>
>
> <font-triplet name="HelveticaNeueCond" style="normal" weight="400"/>
>
>                                                                 </font>
>
>                                                                 <font
> embed-url="LTe50874.ttf">
>
>
> <font-triplet name="HelveticaNeueCond" style="normal" weight="700"/>
>
>
> </font>
>
>                                                 </fonts>
>
>                                 </renderer>
>
>                                 <renderer mime="image/png">
>
>
> <transparent-page-background>true</transparent-page-background>
>
>                                   <fonts><auto-detect/></fonts>
>
>                                 </renderer>
>
>                 </renderers>
>
> </fop>
>
>
>
> Kindest regards
>
>
>
>
> Theresa Forster
>
> Senior Software Developer
>
>
>
Reply | Threaded
Open this post in threaded view
|

RE: Problem that could lose me my job

Theresa Jayne Forster
UPDATE: Tried on 0.95-1 and 0.95 (the latter needed the Avalon framework
adding manually to the pom)
Still does not work, any suggestions why I am getting a pdf that works in a
3rd party viewer and not in adobe.

Kindest regards


Theresa Forster
Senior Software Developer
-----Original Message-----
From: Theresa Jayne Forster [mailto:[hidden email]]
Sent: 03 February 2012 14:44
To: [hidden email]
Subject: RE: Problem that could lose me my job

Ok Checked the deletion code, it doesn’t appear to be that , I stopped that
part happening but the pdf is still ending up corrupt for adobe and Foxit
(but still valid with no errors on Sumatra PDF)  

Kindest regards
Theresa Forster
Senior Software Developer

-----Original Message-----
From: Theresa Jayne Forster [mailto:[hidden email]]
Sent: 03 February 2012 14:06
To: [hidden email]
Subject: RE: Problem that could lose me my job

Ok I have put the complete log for the generation on a gist as it is Waaaaay
to big to post here https://gist.github.com/1730300
I will check the code I have that sends the pdf to the client then check it
is flushing and completing before deleting the file to prevent clutter
Maybe I need to change my fileisreadystrategy


Thanks for the heads up there at least it gives me somewhere to look.


Kindest regards


Theresa Forster
Senior Software Developer

-----Original Message-----
From: mehdi houshmand [mailto:[hidden email]]
Sent: 03 February 2012 13:51
To: [hidden email]
Subject: Re: Problem that could lose me my job

Hi Theresa,

The PDF you put up isn't complete, it's as if FOP stopped creating the
document for some reason. Was an exception thrown? Would there be any
reason why FOP wouldn't finish writing to file? If so, I'd suggest you
try FOP trunk as well to see if the same problem arises, if so, then
the stacktrace should give an indication as to what is causing the
problem.

Mehdi

On 3 February 2012 13:32, Theresa Jayne Forster <[hidden email]>
wrote:
> Why would that make the output PDF invalid to Adobe and not to Sumatra
pdf?

>
>
>
>
>
> Kindest regards
>
>
>
>
> Theresa Forster
>
> Senior Software Developer
>
> From: David J. B. Hollis [mailto:[hidden email]]
> Sent: 03 February 2012 13:19
> To: [hidden email]
> Subject: Re: Problem that could lose me my job
>
>
>
> Hi,
>
>
>
> I've just opened the FO file in oXygen, and it throws up a number of
errors:

>
>
>
> @ margin-top not allowed in fo:region-start
>
> @ z-index not allowed in fo:region-body
>
> @ z-index not allowed in fo:region-before
>
> @ z-index not allowed in fo:region-after
>
>
>
> ... about 20 or so in the fo:simple-page-master section
>
>
>
> HTH
>
> David
>
>
>
>
>
>
>
>
>
> Sorry, I was under pressure to roll back the servers that we had just
> upgraded to use the fop 1.0 system.
>
> One of the failing PDFs is at http://www.inbrand1.co.uk/failsinadobe.pdf
>
> The FO that generated it is at http://www.inbrand1.co.uk/failsinadobe.fo
>
>
>
> The fopconfig has nothing except font configurations in it. A couple have
> kerning xml files as they produce incorrectly without.
>
>
>
> The routine that produces the PDF is as follows
>
>
>
> public File generatePDFromFO(File foFile) {
>
>         OutputStream ot = null;
>
>         BufferedOutputStream out = null;
>
>         File tempFile = null;
>
>         try {
>
>             tempFile = File.createTempFile("W2P", ".pdf");
>
>             out = new BufferedOutputStream( new
FileOutputStream(tempFile));

>
>             fopFactory.setStrictValidation(false);
>
>             DefaultConfigurationBuilder cfgBuilder = new
> DefaultConfigurationBuilder();
>
>             Configuration cfg = cfgBuilder.buildFromFile(new
> File("/fopconfig.xml"));
>
>             fopFactory.setUserConfig(cfg);
>
>             FOUserAgent useragent= fopFactory.newFOUserAgent();
>
>             useragent.setTargetResolution(300);
>
>             Fop fop =
> fopFactory.newFop(MimeConstants.MIME_PDF,useragent,out);
>
>             TransformerFactory factory = TransformerFactory.newInstance();
>
>             Source src = new StreamSource(foFile);
>
>             Transformer transformer = factory.newTransformer();
>
>             Result res = new SAXResult(fop.getDefaultHandler());
>
>             transformer.transform(src, res);
>
>         } catch (IOException ioe) {
>
>             LOGGER.error("IOException ",ioe);
>
>             ioe.printStackTrace();
>
>         } catch (SAXException se) {
>
>             LOGGER.error("Sax Exception ",se);
>
>             se.printStackTrace();
>
>         } catch (ConfigurationException ce) {
>
>             LOGGER.error("Configuration Exception ",ce);
>
>             ce.printStackTrace();
>
>         } catch (TransformerConfigurationException tce) {
>
>             LOGGER.error("Transformer Configuration Exception",tce);
>
>             tce.printStackTrace();
>
>         } catch (TransformerException te) {
>
>             LOGGER.error("Transformer Exception ",te);
>
>             te.printStackTrace();
>
>         }
>
>         return tempFile;
>
>     }
>
>
>
>
>
> Fop config file here
>
>
>
> <fop xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >
>
>                 <strict-configuration>true</strict-configuration>
>
>                 <base>C:\preprocessor\filestore\</base>
>
>
>
>                 <font-base>/Fonts</font-base>
>
>
>
>                 <cache-file>/fop-cache</cache-file>
>
>                 <!--
>
> ************************************************************************
>
>   Add fonts here
>
> ************************************************************************
>
> -->
>
>                 <renderers>
>
>                                 <renderer mime="application/pdf">
>
>                                                 <fonts>
>
>                                                                 <font
> embed-url="FRUTL___.TTF" kerning="yes" metrics-url="FrutigerLight.xml">
>
>
> <font-triplet name="Frutiger" style="normal" weight="200"/>
>
>
> </font>
>
>                                                                 <font
> embed-url="FRUTB___.TTF" kerning="yes">
>
>
> <font-triplet name="Frutiger" style="normal" weight="400"/>
>
>
> </font>
>
>                                                                 <font
> embed-url="tfarrow-medium.TTF">
>
>
> <font-triplet name="TFArrow" style="normal" weight="400"/>
>
>
> </font>
>
>                                                                 <font
> embed-url="HELVNBL_.TTF">
>
>
> <font-triplet name="HelveticaNeue" style="normal" weight="900"/>
>
>
> </font>
>
>                                                                 <font
> embed-url="helveticaneue_85hv.ttf">
>
>
> <font-triplet name="HelveticaNeue" style="normal" weight="800"/>
>
>
> </font>
>
>                                                                 <font
> embed-url="HELVNBI_.TTF">
>
>
> <font-triplet name="HelveticaNeue" style="italic" weight="700"/>
>
>
> </font>
>
>                                                                 <font
> embed-url="HELVNM__.TTF">
>
>
> <font-triplet name="HelveticaNeue" style="normal" weight="500"/>
>
>
> </font>
>
>                                                                 <font
> embed-url="HELVNI__.TTF">
>
>
> <font-triplet name="HelveticaNeue" style="italic" weight="400"/>
>
>
> </font>
>
>                                                                 <font
> embed-url="lte50259.ttf">
>
>
> <font-triplet name="HelveticaNeue" style="normal" weight="400"/>
>
>
> <font-triplet name="HelveticaNeue" style="roman" weight="400"/>
>
>
> </font>
>
>                                                                 <font
> embed-url="HELVNL__.TTF">
>
>
> <font-triplet name="HelveticaNeue" style="normal" weight="300"/>
>
>
> </font>
>
>                                                                 <font
> embed-url="HELVNT__.TTF" kerning="yes"
metrics-url="HelveticaNeueLight.xml">

>
>
> <font-triplet name="HelveticaNeue" style="normal" weight="200"/>
>
>
> </font>
>
>                                                                 <font
> embed-url="HELVNUL_.TTF">
>
>
> <font-triplet name="HelveticaNeue" style="normal" weight="100"/>
>
>
> </font>
>
>                                                                 <font
> embed-url="LTe50872.ttf">
>
>
> <font-triplet name="HelveticaNeueCond" style="normal" weight="400"/>
>
>                                                                 </font>
>
>                                                                 <font
> embed-url="LTe50874.ttf">
>
>
> <font-triplet name="HelveticaNeueCond" style="normal" weight="700"/>
>
>
> </font>
>
>                                                 </fonts>
>
>                                 </renderer>
>
>                                 <renderer mime="image/png">
>
>
> <transparent-page-background>true</transparent-page-background>
>
>                                   <fonts><auto-detect/></fonts>
>
>                                 </renderer>
>
>                 </renderers>
>
> </fop>
>
>
>
> Kindest regards
>
>
>
>
> Theresa Forster
>
> Senior Software Developer
>
>
>



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

Reply | Threaded
Open this post in threaded view
|

Re: Problem that could lose me my job

Luis Bernardo
Attached is a edited source and generated pdf that opens in Adobe
Reader. If it is true to what you expect I can't tell.

I just removed some attributes that are not allowed in the elements they
had been put in (and the FOP error messages were very clear about
those). And as someone else said, side regions do not have margins, only
extents, so no need to use them. I removed those, and the z-indexes too.


On 2/3/12 3:07 PM, Theresa Jayne Forster wrote:

> UPDATE: Tried on 0.95-1 and 0.95 (the latter needed the Avalon framework
> adding manually to the pom)
> Still does not work, any suggestions why I am getting a pdf that works in a
> 3rd party viewer and not in adobe.
>
> Kindest regards
>
>
> Theresa Forster
> Senior Software Developer
> -----Original Message-----
> From: Theresa Jayne Forster [mailto:[hidden email]]
> Sent: 03 February 2012 14:44
> To: [hidden email]
> Subject: RE: Problem that could lose me my job
>
> Ok Checked the deletion code, it doesn’t appear to be that , I stopped that
> part happening but the pdf is still ending up corrupt for adobe and Foxit
> (but still valid with no errors on Sumatra PDF)
>
> Kindest regards
> Theresa Forster
> Senior Software Developer
>
> -----Original Message-----
> From: Theresa Jayne Forster [mailto:[hidden email]]
> Sent: 03 February 2012 14:06
> To: [hidden email]
> Subject: RE: Problem that could lose me my job
>
> Ok I have put the complete log for the generation on a gist as it is Waaaaay
> to big to post here https://gist.github.com/1730300
> I will check the code I have that sends the pdf to the client then check it
> is flushing and completing before deleting the file to prevent clutter
> Maybe I need to change my fileisreadystrategy
>
>
> Thanks for the heads up there at least it gives me somewhere to look.
>
>
> Kindest regards
>
>
> Theresa Forster
> Senior Software Developer
>
> -----Original Message-----
> From: mehdi houshmand [mailto:[hidden email]]
> Sent: 03 February 2012 13:51
> To: [hidden email]
> Subject: Re: Problem that could lose me my job
>
> Hi Theresa,
>
> The PDF you put up isn't complete, it's as if FOP stopped creating the
> document for some reason. Was an exception thrown? Would there be any
> reason why FOP wouldn't finish writing to file? If so, I'd suggest you
> try FOP trunk as well to see if the same problem arises, if so, then
> the stacktrace should give an indication as to what is causing the
> problem.
>
> Mehdi
>
> On 3 February 2012 13:32, Theresa Jayne Forster<[hidden email]>
> wrote:
>> Why would that make the output PDF invalid to Adobe and not to Sumatra
> pdf?
>>
>>
>>
>>
>> Kindest regards
>>
>>
>>
>>
>> Theresa Forster
>>
>> Senior Software Developer
>>
>> From: David J. B. Hollis [mailto:[hidden email]]
>> Sent: 03 February 2012 13:19
>> To: [hidden email]
>> Subject: Re: Problem that could lose me my job
>>
>>
>>
>> Hi,
>>
>>
>>
>> I've just opened the FO file in oXygen, and it throws up a number of
> errors:
>>
>>
>> @ margin-top not allowed in fo:region-start
>>
>> @ z-index not allowed in fo:region-body
>>
>> @ z-index not allowed in fo:region-before
>>
>> @ z-index not allowed in fo:region-after
>>
>>
>>
>> ... about 20 or so in the fo:simple-page-master section
>>
>>
>>
>> HTH
>>
>> David
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> Sorry, I was under pressure to roll back the servers that we had just
>> upgraded to use the fop 1.0 system.
>>
>> One of the failing PDFs is at http://www.inbrand1.co.uk/failsinadobe.pdf
>>
>> The FO that generated it is at http://www.inbrand1.co.uk/failsinadobe.fo
>>
>>
>>
>> The fopconfig has nothing except font configurations in it. A couple have
>> kerning xml files as they produce incorrectly without.
>>
>>
>>
>> The routine that produces the PDF is as follows
>>
>>
>>
>> public File generatePDFromFO(File foFile) {
>>
>>          OutputStream ot = null;
>>
>>          BufferedOutputStream out = null;
>>
>>          File tempFile = null;
>>
>>          try {
>>
>>              tempFile = File.createTempFile("W2P", ".pdf");
>>
>>              out = new BufferedOutputStream( new
> FileOutputStream(tempFile));
>>              fopFactory.setStrictValidation(false);
>>
>>              DefaultConfigurationBuilder cfgBuilder = new
>> DefaultConfigurationBuilder();
>>
>>              Configuration cfg = cfgBuilder.buildFromFile(new
>> File("/fopconfig.xml"));
>>
>>              fopFactory.setUserConfig(cfg);
>>
>>              FOUserAgent useragent= fopFactory.newFOUserAgent();
>>
>>              useragent.setTargetResolution(300);
>>
>>              Fop fop =
>> fopFactory.newFop(MimeConstants.MIME_PDF,useragent,out);
>>
>>              TransformerFactory factory = TransformerFactory.newInstance();
>>
>>              Source src = new StreamSource(foFile);
>>
>>              Transformer transformer = factory.newTransformer();
>>
>>              Result res = new SAXResult(fop.getDefaultHandler());
>>
>>              transformer.transform(src, res);
>>
>>          } catch (IOException ioe) {
>>
>>              LOGGER.error("IOException ",ioe);
>>
>>              ioe.printStackTrace();
>>
>>          } catch (SAXException se) {
>>
>>              LOGGER.error("Sax Exception ",se);
>>
>>              se.printStackTrace();
>>
>>          } catch (ConfigurationException ce) {
>>
>>              LOGGER.error("Configuration Exception ",ce);
>>
>>              ce.printStackTrace();
>>
>>          } catch (TransformerConfigurationException tce) {
>>
>>              LOGGER.error("Transformer Configuration Exception",tce);
>>
>>              tce.printStackTrace();
>>
>>          } catch (TransformerException te) {
>>
>>              LOGGER.error("Transformer Exception ",te);
>>
>>              te.printStackTrace();
>>
>>          }
>>
>>          return tempFile;
>>
>>      }
>>
>>
>>
>>
>>
>> Fop config file here
>>
>>
>>
>> <fop xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
>>
>>                  <strict-configuration>true</strict-configuration>
>>
>>                  <base>C:\preprocessor\filestore\</base>
>>
>>
>>
>>                  <font-base>/Fonts</font-base>
>>
>>
>>
>>                  <cache-file>/fop-cache</cache-file>
>>
>>                  <!--
>>
>> ************************************************************************
>>
>>    Add fonts here
>>
>> ************************************************************************
>>
>> -->
>>
>>                  <renderers>
>>
>>                                  <renderer mime="application/pdf">
>>
>>                                                  <fonts>
>>
>>                                                                  <font
>> embed-url="FRUTL___.TTF" kerning="yes" metrics-url="FrutigerLight.xml">
>>
>>
>> <font-triplet name="Frutiger" style="normal" weight="200"/>
>>
>>
>> </font>
>>
>>                                                                  <font
>> embed-url="FRUTB___.TTF" kerning="yes">
>>
>>
>> <font-triplet name="Frutiger" style="normal" weight="400"/>
>>
>>
>> </font>
>>
>>                                                                  <font
>> embed-url="tfarrow-medium.TTF">
>>
>>
>> <font-triplet name="TFArrow" style="normal" weight="400"/>
>>
>>
>> </font>
>>
>>                                                                  <font
>> embed-url="HELVNBL_.TTF">
>>
>>
>> <font-triplet name="HelveticaNeue" style="normal" weight="900"/>
>>
>>
>> </font>
>>
>>                                                                  <font
>> embed-url="helveticaneue_85hv.ttf">
>>
>>
>> <font-triplet name="HelveticaNeue" style="normal" weight="800"/>
>>
>>
>> </font>
>>
>>                                                                  <font
>> embed-url="HELVNBI_.TTF">
>>
>>
>> <font-triplet name="HelveticaNeue" style="italic" weight="700"/>
>>
>>
>> </font>
>>
>>                                                                  <font
>> embed-url="HELVNM__.TTF">
>>
>>
>> <font-triplet name="HelveticaNeue" style="normal" weight="500"/>
>>
>>
>> </font>
>>
>>                                                                  <font
>> embed-url="HELVNI__.TTF">
>>
>>
>> <font-triplet name="HelveticaNeue" style="italic" weight="400"/>
>>
>>
>> </font>
>>
>>                                                                  <font
>> embed-url="lte50259.ttf">
>>
>>
>> <font-triplet name="HelveticaNeue" style="normal" weight="400"/>
>>
>>
>> <font-triplet name="HelveticaNeue" style="roman" weight="400"/>
>>
>>
>> </font>
>>
>>                                                                  <font
>> embed-url="HELVNL__.TTF">
>>
>>
>> <font-triplet name="HelveticaNeue" style="normal" weight="300"/>
>>
>>
>> </font>
>>
>>                                                                  <font
>> embed-url="HELVNT__.TTF" kerning="yes"
> metrics-url="HelveticaNeueLight.xml">
>>
>> <font-triplet name="HelveticaNeue" style="normal" weight="200"/>
>>
>>
>> </font>
>>
>>                                                                  <font
>> embed-url="HELVNUL_.TTF">
>>
>>
>> <font-triplet name="HelveticaNeue" style="normal" weight="100"/>
>>
>>
>> </font>
>>
>>                                                                  <font
>> embed-url="LTe50872.ttf">
>>
>>
>> <font-triplet name="HelveticaNeueCond" style="normal" weight="400"/>
>>
>>                                                                  </font>
>>
>>                                                                  <font
>> embed-url="LTe50874.ttf">
>>
>>
>> <font-triplet name="HelveticaNeueCond" style="normal" weight="700"/>
>>
>>
>> </font>
>>
>>                                                  </fonts>
>>
>>                                  </renderer>
>>
>>                                  <renderer mime="image/png">
>>
>>
>> <transparent-page-background>true</transparent-page-background>
>>
>>                                    <fonts><auto-detect/></fonts>
>>
>>                                  </renderer>
>>
>>                  </renderers>
>>
>> </fop>
>>
>>
>>
>> Kindest regards
>>
>>
>>
>>
>> Theresa Forster
>>
>> Senior Software Developer
>>
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>


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

failsinadobe.fo (267K) Download Attachment
issue002.pdf (102K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Problem that could lose me my job

Craig Ringer-2
In reply to this post by Theresa Jayne Forster
On 3/02/2012 10:13 PM, Theresa Jayne Forster wrote:

The stacktraces were added to allow me to quickly debug without trapesing through the mega log that log4J is spewing out from the whole system (I know its wrong hell I cringe whenever I see some of the code but it is based on the old system just upgraded for Fop 1.0 as the old system was 0.23 with a handful of custom addons like accepting font-weight=”bold” and z-index=”2” to using a bare 1.0

 

OK, but either way you're still ignoring the exceptions. That was just as wrong before the printStackTrace calls were added as it is now.

UPDATE: Tried on 0.95-1 and 0.95 (the latter needed the Avalon framework
adding manually to the pom) 
Still does not work, any suggestions why I am getting a pdf that works in a
3rd party viewer and not in adobe.


Because you are getting an incomplete, damaged PDF. Some viewers manage to cope with it, others do not. When I open the file in a hex editor (or a decent text editor) I can see that it ends at an `endobj', not with a proper xref dictionary and trailer.

What *should* be happening is that when fop hits whatever error prevents it from finishing generating the PDF it throws an exception. Your app should catch that exception, delete the temporary file, and rethrow the exception or handle it within your app's error handling and reporting framework. Logging and ignoring the exception is incorrect.

You have still not confirmed whether or not fop is throwing an exception when generating this file. Please confirm whether fop actually throws an exception when generating this file.

If fop does not throw an exception, there is a fop bug.

If fop does throw an exception, there is a bug in your code.

--
Craig Ringer
Reply | Threaded
Open this post in threaded view
|

RE: Problem that could lose me my job

Theresa Jayne Forster

Thank you for all your time guys,  I was being a clutz, Unbeknown to me all ERRORS were being pushed into a separate file – (I didn’t put together the log.properties )

 

In the error log I am getting an exception as below. So it is having problems getting the images, so at least I have somewhere to look

 

 

2012-02-03 15:20:41,503 [pool-1-thread-2] ERROR org.apache.fop.apps.FopFactory - Attempt to resolve URI 'C:\InBrand\preprocessor\filestore\img3525450795559698480.jpg' failed:

javax.xml.transform.TransformerException: Error with URL; base 'file:/C:/InBrand/preprocessor/filestore/' href 'C:\InBrand\preprocessor\filestore\img3525450795559698480.jpg'

                at org.apache.fop.apps.FOURIResolver.handleException(FOURIResolver.java:141)

                at org.apache.fop.apps.FOURIResolver.resolve(FOURIResolver.java:272)

                at org.apache.fop.apps.FopFactory.resolveURI(FopFactory.java:753)

                at org.apache.fop.apps.FOUserAgent.resolveURI(FOUserAgent.java:425)

                at org.apache.fop.apps.FOUserAgent.resolveURI(FOUserAgent.java:398)

                at org.apache.fop.apps.FOUserAgent$1.resolveURI(FOUserAgent.java:141)

                at org.apache.xmlgraphics.image.loader.impl.AbstractImageSessionContext.newSource(AbstractImageSessionContext.java:77)

                at org.apache.xmlgraphics.image.loader.impl.AbstractImageSessionContext.needSource(AbstractImageSessionContext.java:280)

                at org.apache.xmlgraphics.image.loader.cache.ImageCache.needImageInfo(ImageCache.java:123)

                at org.apache.xmlgraphics.image.loader.ImageManager.getImageInfo(ImageManager.java:122)

                at org.apache.fop.fo.flow.ExternalGraphic.bind(ExternalGraphic.java:81)

                at org.apache.fop.fo.FObj.processNode(FObj.java:123)

                at org.apache.fop.fo.FOTreeBuilder$MainFOHandler.startElement(FOTreeBuilder.java:282)

                at org.apache.fop.fo.FOTreeBuilder.startElement(FOTreeBuilder.java:171)

                at org.apache.xalan.transformer.TransformerIdentityImpl.startElement(TransformerIdentityImpl.java:1072)

                at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)

                at org.apache.xerces.parsers.AbstractXMLDocumentParser.emptyElement(Unknown Source)

                at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)

                at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)

                at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)

                at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)

                at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)

                at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)

                at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)

                at org.apache.xalan.transformer.TransformerIdentityImpl.transform(TransformerIdentityImpl.java:484)

                at uk.co.inbrand.fopengine.FopEngine.generatePDFromFO(FopEngine.java:197)

                at uk.co.inbrand.fopengine.FopProcessor.run(FopProcessor.java:50)

                at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)

                at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)

                at java.lang.Thread.run(Thread.java:619)

Caused by: java.net.MalformedURLException: unknown protocol: c

                at java.net.URL.<init>(URL.java:574)

                at java.net.URL.<init>(URL.java:464)

                at org.apache.fop.apps.FOURIResolver.resolve(FOURIResolver.java:270)

                ... 28 more

---------

java.net.MalformedURLException: unknown protocol: c

                at java.net.URL.<init>(URL.java:574)

                at java.net.URL.<init>(URL.java:464)

                at org.apache.fop.apps.FOURIResolver.resolve(FOURIResolver.java:270)

                at org.apache.fop.apps.FopFactory.resolveURI(FopFactory.java:753)

                at org.apache.fop.apps.FOUserAgent.resolveURI(FOUserAgent.java:425)

                at org.apache.fop.apps.FOUserAgent.resolveURI(FOUserAgent.java:398)

                at org.apache.fop.apps.FOUserAgent$1.resolveURI(FOUserAgent.java:141)

                at org.apache.xmlgraphics.image.loader.impl.AbstractImageSessionContext.newSource(AbstractImageSessionContext.java:77)

                at org.apache.xmlgraphics.image.loader.impl.AbstractImageSessionContext.needSource(AbstractImageSessionContext.java:280)

                at org.apache.xmlgraphics.image.loader.cache.ImageCache.needImageInfo(ImageCache.java:123)

                at org.apache.xmlgraphics.image.loader.ImageManager.getImageInfo(ImageManager.java:122)

                at org.apache.fop.fo.flow.ExternalGraphic.bind(ExternalGraphic.java:81)

                at org.apache.fop.fo.FObj.processNode(FObj.java:123)

                at org.apache.fop.fo.FOTreeBuilder$MainFOHandler.startElement(FOTreeBuilder.java:282)

                at org.apache.fop.fo.FOTreeBuilder.startElement(FOTreeBuilder.java:171)

                at org.apache.xalan.transformer.TransformerIdentityImpl.startElement(TransformerIdentityImpl.java:1072)

                at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)

                at org.apache.xerces.parsers.AbstractXMLDocumentParser.emptyElement(Unknown Source)

                at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)

                at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)

                at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)

                at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)

                at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)

                at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)

                at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)

                at org.apache.xalan.transformer.TransformerIdentityImpl.transform(TransformerIdentityImpl.java:484)

                at uk.co.inbrand.fopengine.FopEngine.generatePDFromFO(FopEngine.java:197)

                at uk.co.inbrand.fopengine.FopProcessor.run(FopProcessor.java:50)

                at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)

                at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)

                at java.lang.Thread.run(Thread.java:619)

2012-02-03 15:20:41,511 [pool-1-thread-2] ERROR org.apache.fop.apps.FOUserAgent - Image not found. URI: C:\InBrand\preprocessor\filestore\img3525450795559698480.jpg. (See position 1306:199)

2012-02-03 15:20:41,672 [pool-1-thread-2] ERROR org.apache.fop.apps.FOUserAgent - Image not available. URI: . Reason: org.apache.xmlgraphics.image.loader.ImageException: The file format is not supported. No ImagePreloader found for  (See position 1336:137)

2012-02-03 15:20:41,687 [pool-1-thread-2] ERROR org.apache.fop.apps.FOUserAgent - Image not found. URI: . (See position 1341:137)

 

Kindest regards

 


Theresa Forster

Senior Software Developer

Reply | Threaded
Open this post in threaded view
|

Re: Problem that could lose me my job

rsargent
Still looks to me as though your image handling is amiss.  What image loaders have you defined? Are they available in deployment? All assuming the fixed (DOS?) paths are correct.
 

On Feb 7, 2012, at 3:09 AM, "Theresa Jayne Forster" <[hidden email]> wrote:

Thank you for all your time guys,  I was being a clutz, Unbeknown to me all ERRORS were being pushed into a separate file – (I didn’t put together the log.properties )

 

In the error log I am getting an exception as below. So it is having problems getting the images, so at least I have somewhere to look

 

 

2012-02-03 15:20:41,503 [pool-1-thread-2] ERROR org.apache.fop.apps.FopFactory - Attempt to resolve URI 'C:\InBrand\preprocessor\filestore\img3525450795559698480.jpg' failed:

javax.xml.transform.TransformerException: Error with URL; base 'file:/C:/InBrand/preprocessor/filestore/' href 'C:\InBrand\preprocessor\filestore\img3525450795559698480.jpg'

                at org.apache.fop.apps.FOURIResolver.handleException(FOURIResolver.java:141)

                at org.apache.fop.apps.FOURIResolver.resolve(FOURIResolver.java:272)

                at org.apache.fop.apps.FopFactory.resolveURI(FopFactory.java:753)

                at org.apache.fop.apps.FOUserAgent.resolveURI(FOUserAgent.java:425)

                at org.apache.fop.apps.FOUserAgent.resolveURI(FOUserAgent.java:398)

                at org.apache.fop.apps.FOUserAgent$1.resolveURI(FOUserAgent.java:141)

                at org.apache.xmlgraphics.image.loader.impl.AbstractImageSessionContext.newSource(AbstractImageSessionContext.java:77)

                at org.apache.xmlgraphics.image.loader.impl.AbstractImageSessionContext.needSource(AbstractImageSessionContext.java:280)

                at org.apache.xmlgraphics.image.loader.cache.ImageCache.needImageInfo(ImageCache.java:123)

                at org.apache.xmlgraphics.image.loader.ImageManager.getImageInfo(ImageManager.java:122)

                at org.apache.fop.fo.flow.ExternalGraphic.bind(ExternalGraphic.java:81)

                at org.apache.fop.fo.FObj.processNode(FObj.java:123)

                at org.apache.fop.fo.FOTreeBuilder$MainFOHandler.startElement(FOTreeBuilder.java:282)

                at org.apache.fop.fo.FOTreeBuilder.startElement(FOTreeBuilder.java:171)

                at org.apache.xalan.transformer.TransformerIdentityImpl.startElement(TransformerIdentityImpl.java:1072)

                at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)

                at org.apache.xerces.parsers.AbstractXMLDocumentParser.emptyElement(Unknown Source)

                at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)

                at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)

                at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)

                at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)

                at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)

                at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)

                at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)

                at org.apache.xalan.transformer.TransformerIdentityImpl.transform(TransformerIdentityImpl.java:484)

                at uk.co.inbrand.fopengine.FopEngine.generatePDFromFO(FopEngine.java:197)

                at uk.co.inbrand.fopengine.FopProcessor.run(FopProcessor.java:50)

                at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)

                at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)

                at java.lang.Thread.run(Thread.java:619)

Caused by: java.net.MalformedURLException: unknown protocol: c

                at java.net.URL.<init>(URL.java:574)

                at java.net.URL.<init>(URL.java:464)

                at org.apache.fop.apps.FOURIResolver.resolve(FOURIResolver.java:270)

                ... 28 more

---------

java.net.MalformedURLException: unknown protocol: c

                at java.net.URL.<init>(URL.java:574)

                at java.net.URL.<init>(URL.java:464)

                at org.apache.fop.apps.FOURIResolver.resolve(FOURIResolver.java:270)

                at org.apache.fop.apps.FopFactory.resolveURI(FopFactory.java:753)

                at org.apache.fop.apps.FOUserAgent.resolveURI(FOUserAgent.java:425)

                at org.apache.fop.apps.FOUserAgent.resolveURI(FOUserAgent.java:398)

                at org.apache.fop.apps.FOUserAgent$1.resolveURI(FOUserAgent.java:141)

                at org.apache.xmlgraphics.image.loader.impl.AbstractImageSessionContext.newSource(AbstractImageSessionContext.java:77)

                at org.apache.xmlgraphics.image.loader.impl.AbstractImageSessionContext.needSource(AbstractImageSessionContext.java:280)

                at org.apache.xmlgraphics.image.loader.cache.ImageCache.needImageInfo(ImageCache.java:123)

                at org.apache.xmlgraphics.image.loader.ImageManager.getImageInfo(ImageManager.java:122)

                at org.apache.fop.fo.flow.ExternalGraphic.bind(ExternalGraphic.java:81)

                at org.apache.fop.fo.FObj.processNode(FObj.java:123)

                at org.apache.fop.fo.FOTreeBuilder$MainFOHandler.startElement(FOTreeBuilder.java:282)

                at org.apache.fop.fo.FOTreeBuilder.startElement(FOTreeBuilder.java:171)

                at org.apache.xalan.transformer.TransformerIdentityImpl.startElement(TransformerIdentityImpl.java:1072)

                at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)

                at org.apache.xerces.parsers.AbstractXMLDocumentParser.emptyElement(Unknown Source)

                at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)

                at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)

                at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)

                at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)

                at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)

                at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)

                at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)

                at org.apache.xalan.transformer.TransformerIdentityImpl.transform(TransformerIdentityImpl.java:484)

                at uk.co.inbrand.fopengine.FopEngine.generatePDFromFO(FopEngine.java:197)

                at uk.co.inbrand.fopengine.FopProcessor.run(FopProcessor.java:50)

                at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)

                at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)

                at java.lang.Thread.run(Thread.java:619)

2012-02-03 15:20:41,511 [pool-1-thread-2] ERROR org.apache.fop.apps.FOUserAgent - Image not found. URI: C:\InBrand\preprocessor\filestore\img3525450795559698480.jpg. (See position 1306:199)

2012-02-03 15:20:41,672 [pool-1-thread-2] ERROR org.apache.fop.apps.FOUserAgent - Image not available. URI: . Reason: org.apache.xmlgraphics.image.loader.ImageException: The file format is not supported. No ImagePreloader found for  (See position 1336:137)

2012-02-03 15:20:41,687 [pool-1-thread-2] ERROR org.apache.fop.apps.FOUserAgent - Image not found. URI: . (See position 1341:137)

 

Kindest regards

 


Theresa Forster

Senior Software Developer

Reply | Threaded
Open this post in threaded view
|

Re: Problem that could lose me my job

Steve Quirk


On Tue, 7 Feb 2012, Rob Sargent wrote:

> Still looks to me as though your image handling is amiss.  What image loaders have you defined? Are they available in deployment? All
> assuming the fixed (DOS?) paths are correct.

I think it's more straightforward than that.  The URL is invalid.

Theresa, did you try fixing the urls?  "file:/C:/InBrand/preprocessor/filestore/"
should be "file://C:/InBrand/preprocessor/filestore/"  (two slashes).

The message "java.net.MalformedURLException: unknown protocol: c" leads me
to think you also have bare DOS paths in there, they also should be
"file://c:/..."

And for heaven's sake, dump windows.

Steve

>  
>
> On Feb 7, 2012, at 3:09 AM, "Theresa Jayne Forster" <[hidden email]> wrote:
>
>       Thank you for all your time guys,  I was being a clutz, Unbeknown to me all ERRORS were being pushed into a separate file ?
>       (I didn?t put together the log.properties )
>
>        
>
>       In the error log I am getting an exception as below. So it is having problems getting the images, so at least I have
>       somewhere to look
>
>        
>
>        
>
>       2012-02-03 15:20:41,503 [pool-1-thread-2] ERROR org.apache.fop.apps.FopFactory - Attempt to resolve URI
>       'C:\InBrand\preprocessor\filestore\img3525450795559698480.jpg' failed:
>
>       javax.xml.transform.TransformerException: Error with URL; base 'file:/C:/InBrand/preprocessor/filestore/' href
>       'C:\InBrand\preprocessor\filestore\img3525450795559698480.jpg'
>
>                       at org.apache.fop.apps.FOURIResolver.handleException(FOURIResolver.java:141)
>
>                       at org.apache.fop.apps.FOURIResolver.resolve(FOURIResolver.java:272)
>
>                       at org.apache.fop.apps.FopFactory.resolveURI(FopFactory.java:753)
>
>                       at org.apache.fop.apps.FOUserAgent.resolveURI(FOUserAgent.java:425)
>
>                       at org.apache.fop.apps.FOUserAgent.resolveURI(FOUserAgent.java:398)
>
>                       at org.apache.fop.apps.FOUserAgent$1.resolveURI(FOUserAgent.java:141)
>
>                       at
>       org.apache.xmlgraphics.image.loader.impl.AbstractImageSessionContext.newSource(AbstractImageSessionContext.java:77)
>
>                       at
>       org.apache.xmlgraphics.image.loader.impl.AbstractImageSessionContext.needSource(AbstractImageSessionContext.java:280)
>
>                       at org.apache.xmlgraphics.image.loader.cache.ImageCache.needImageInfo(ImageCache.java:123)
>
>                       at org.apache.xmlgraphics.image.loader.ImageManager.getImageInfo(ImageManager.java:122)
>
>                       at org.apache.fop.fo.flow.ExternalGraphic.bind(ExternalGraphic.java:81)
>
>                       at org.apache.fop.fo.FObj.processNode(FObj.java:123)
>
>                       at org.apache.fop.fo.FOTreeBuilder$MainFOHandler.startElement(FOTreeBuilder.java:282)
>
>                       at org.apache.fop.fo.FOTreeBuilder.startElement(FOTreeBuilder.java:171)
>
>                       at org.apache.xalan.transformer.TransformerIdentityImpl.startElement(TransformerIdentityImpl.java:1072)
>
>                       at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
>
>                       at org.apache.xerces.parsers.AbstractXMLDocumentParser.emptyElement(Unknown Source)
>
>                       at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
>
>                       at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown
>       Source)
>
>                       at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
>
>                       at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
>
>                       at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
>
>                       at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
>
>                       at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
>
>                       at org.apache.xalan.transformer.TransformerIdentityImpl.transform(TransformerIdentityImpl.java:484)
>
>                       at uk.co.inbrand.fopengine.FopEngine.generatePDFromFO(FopEngine.java:197)
>
>                       at uk.co.inbrand.fopengine.FopProcessor.run(FopProcessor.java:50)
>
>                       at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
>
>                       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
>
>                       at java.lang.Thread.run(Thread.java:619)
>
>       Caused by: java.net.MalformedURLException: unknown protocol: c
>
>                       at java.net.URL.<init>(URL.java:574)
>
>                       at java.net.URL.<init>(URL.java:464)
>
>                       at org.apache.fop.apps.FOURIResolver.resolve(FOURIResolver.java:270)
>
>                       ... 28 more
>
>       ---------
>
>       java.net.MalformedURLException: unknown protocol: c
>
>                       at java.net.URL.<init>(URL.java:574)
>
>                       at java.net.URL.<init>(URL.java:464)
>
>                       at org.apache.fop.apps.FOURIResolver.resolve(FOURIResolver.java:270)
>
>                       at org.apache.fop.apps.FopFactory.resolveURI(FopFactory.java:753)
>
>                       at org.apache.fop.apps.FOUserAgent.resolveURI(FOUserAgent.java:425)
>
>                       at org.apache.fop.apps.FOUserAgent.resolveURI(FOUserAgent.java:398)
>
>                       at org.apache.fop.apps.FOUserAgent$1.resolveURI(FOUserAgent.java:141)
>
>                       at
>       org.apache.xmlgraphics.image.loader.impl.AbstractImageSessionContext.newSource(AbstractImageSessionContext.java:77)
>
>                       at
>       org.apache.xmlgraphics.image.loader.impl.AbstractImageSessionContext.needSource(AbstractImageSessionContext.java:280)
>
>                       at org.apache.xmlgraphics.image.loader.cache.ImageCache.needImageInfo(ImageCache.java:123)
>
>                       at org.apache.xmlgraphics.image.loader.ImageManager.getImageInfo(ImageManager.java:122)
>
>                       at org.apache.fop.fo.flow.ExternalGraphic.bind(ExternalGraphic.java:81)
>
>                       at org.apache.fop.fo.FObj.processNode(FObj.java:123)
>
>                       at org.apache.fop.fo.FOTreeBuilder$MainFOHandler.startElement(FOTreeBuilder.java:282)
>
>                       at org.apache.fop.fo.FOTreeBuilder.startElement(FOTreeBuilder.java:171)
>
>                       at org.apache.xalan.transformer.TransformerIdentityImpl.startElement(TransformerIdentityImpl.java:1072)
>
>                       at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
>
>                       at org.apache.xerces.parsers.AbstractXMLDocumentParser.emptyElement(Unknown Source)
>
>                       at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
>
>                       at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown
>       Source)
>
>                       at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
>
>                       at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
>
>                       at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
>
>                       at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
>
>                       at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
>
>                       at org.apache.xalan.transformer.TransformerIdentityImpl.transform(TransformerIdentityImpl.java:484)
>
>                       at uk.co.inbrand.fopengine.FopEngine.generatePDFromFO(FopEngine.java:197)
>
>                       at uk.co.inbrand.fopengine.FopProcessor.run(FopProcessor.java:50)
>
>                       at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
>
>                       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
>
>                       at java.lang.Thread.run(Thread.java:619)
>
>       2012-02-03 15:20:41,511 [pool-1-thread-2] ERROR org.apache.fop.apps.FOUserAgent - Image not found. URI:
>       C:\InBrand\preprocessor\filestore\img3525450795559698480.jpg. (See position 1306:199)
>
>       2012-02-03 15:20:41,672 [pool-1-thread-2] ERROR org.apache.fop.apps.FOUserAgent - Image not available. URI: . Reason:
>       org.apache.xmlgraphics.image.loader.ImageException: The file format is not supported. No ImagePreloader found for  (See
>       position 1336:137)
>
>       2012-02-03 15:20:41,687 [pool-1-thread-2] ERROR org.apache.fop.apps.FOUserAgent - Image not found. URI: . (See position
>       1341:137)
>
>        
>
>       Kindest regards
>
>        
>
>
>       Theresa Forster
>
>       Senior Software Developer
>
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: Problem that could lose me my job

Kindaian
In reply to this post by rsargent
Hmmm... why not installing those files in a local webserver?

That way you would have a proper uri (http://localhost/etc...)

And prolly the problem would be sorted...

When the hammer doesn't go to the nail... you get a nail-gun.

Cheers,
LF


On 07/02/2012 14:47, Rob Sargent wrote:
Still looks to me as though your image handling is amiss.  What image loaders have you defined? Are they available in deployment? All assuming the fixed (DOS?) paths are correct.
 

On Feb 7, 2012, at 3:09 AM, "Theresa Jayne Forster" <[hidden email]> wrote:

Thank you for all your time guys,  I was being a clutz, Unbeknown to me all ERRORS were being pushed into a separate file – (I didn’t put together the log.properties )

 

In the error log I am getting an exception as below. So it is having problems getting the images, so at least I have somewhere to look

 

 

2012-02-03 15:20:41,503 [pool-1-thread-2] ERROR org.apache.fop.apps.FopFactory - Attempt to resolve URI 'C:\InBrand\preprocessor\filestore\img3525450795559698480.jpg' failed:

javax.xml.transform.TransformerException: Error with URL; base 'file:/C:/InBrand/preprocessor/filestore/' href 'C:\InBrand\preprocessor\filestore\img3525450795559698480.jpg'

                at org.apache.fop.apps.FOURIResolver.handleException(FOURIResolver.java:141)

                at org.apache.fop.apps.FOURIResolver.resolve(FOURIResolver.java:272)

                at org.apache.fop.apps.FopFactory.resolveURI(FopFactory.java:753)

                at org.apache.fop.apps.FOUserAgent.resolveURI(FOUserAgent.java:425)

                at org.apache.fop.apps.FOUserAgent.resolveURI(FOUserAgent.java:398)

                at org.apache.fop.apps.FOUserAgent$1.resolveURI(FOUserAgent.java:141)

                at org.apache.xmlgraphics.image.loader.impl.AbstractImageSessionContext.newSource(AbstractImageSessionContext.java:77)

                at org.apache.xmlgraphics.image.loader.impl.AbstractImageSessionContext.needSource(AbstractImageSessionContext.java:280)

                at org.apache.xmlgraphics.image.loader.cache.ImageCache.needImageInfo(ImageCache.java:123)

                at org.apache.xmlgraphics.image.loader.ImageManager.getImageInfo(ImageManager.java:122)

                at org.apache.fop.fo.flow.ExternalGraphic.bind(ExternalGraphic.java:81)

                at org.apache.fop.fo.FObj.processNode(FObj.java:123)

                at org.apache.fop.fo.FOTreeBuilder$MainFOHandler.startElement(FOTreeBuilder.java:282)

                at org.apache.fop.fo.FOTreeBuilder.startElement(FOTreeBuilder.java:171)

                at org.apache.xalan.transformer.TransformerIdentityImpl.startElement(TransformerIdentityImpl.java:1072)

                at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)

                at org.apache.xerces.parsers.AbstractXMLDocumentParser.emptyElement(Unknown Source)

                at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)

                at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)

                at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)

                at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)

                at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)

                at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)

                at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)

                at org.apache.xalan.transformer.TransformerIdentityImpl.transform(TransformerIdentityImpl.java:484)

                at uk.co.inbrand.fopengine.FopEngine.generatePDFromFO(FopEngine.java:197)

                at uk.co.inbrand.fopengine.FopProcessor.run(FopProcessor.java:50)

                at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)

                at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)

                at java.lang.Thread.run(Thread.java:619)

Caused by: java.net.MalformedURLException: unknown protocol: c

                at java.net.URL.<init>(URL.java:574)

                at java.net.URL.<init>(URL.java:464)

                at org.apache.fop.apps.FOURIResolver.resolve(FOURIResolver.java:270)

                ... 28 more

---------

java.net.MalformedURLException: unknown protocol: c

                at java.net.URL.<init>(URL.java:574)

                at java.net.URL.<init>(URL.java:464)

                at org.apache.fop.apps.FOURIResolver.resolve(FOURIResolver.java:270)

                at org.apache.fop.apps.FopFactory.resolveURI(FopFactory.java:753)

                at org.apache.fop.apps.FOUserAgent.resolveURI(FOUserAgent.java:425)

                at org.apache.fop.apps.FOUserAgent.resolveURI(FOUserAgent.java:398)

                at org.apache.fop.apps.FOUserAgent$1.resolveURI(FOUserAgent.java:141)

                at org.apache.xmlgraphics.image.loader.impl.AbstractImageSessionContext.newSource(AbstractImageSessionContext.java:77)

                at org.apache.xmlgraphics.image.loader.impl.AbstractImageSessionContext.needSource(AbstractImageSessionContext.java:280)

                at org.apache.xmlgraphics.image.loader.cache.ImageCache.needImageInfo(ImageCache.java:123)

                at org.apache.xmlgraphics.image.loader.ImageManager.getImageInfo(ImageManager.java:122)

                at org.apache.fop.fo.flow.ExternalGraphic.bind(ExternalGraphic.java:81)

                at org.apache.fop.fo.FObj.processNode(FObj.java:123)

                at org.apache.fop.fo.FOTreeBuilder$MainFOHandler.startElement(FOTreeBuilder.java:282)

                at org.apache.fop.fo.FOTreeBuilder.startElement(FOTreeBuilder.java:171)

                at org.apache.xalan.transformer.TransformerIdentityImpl.startElement(TransformerIdentityImpl.java:1072)

                at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)

                at org.apache.xerces.parsers.AbstractXMLDocumentParser.emptyElement(Unknown Source)

                at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)

                at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)

                at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)

                at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)

                at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)

                at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)

                at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)

                at org.apache.xalan.transformer.TransformerIdentityImpl.transform(TransformerIdentityImpl.java:484)

                at uk.co.inbrand.fopengine.FopEngine.generatePDFromFO(FopEngine.java:197)

                at uk.co.inbrand.fopengine.FopProcessor.run(FopProcessor.java:50)

                at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)

                at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)

                at java.lang.Thread.run(Thread.java:619)

2012-02-03 15:20:41,511 [pool-1-thread-2] ERROR org.apache.fop.apps.FOUserAgent - Image not found. URI: C:\InBrand\preprocessor\filestore\img3525450795559698480.jpg. (See position 1306:199)

2012-02-03 15:20:41,672 [pool-1-thread-2] ERROR org.apache.fop.apps.FOUserAgent - Image not available. URI: . Reason: org.apache.xmlgraphics.image.loader.ImageException: The file format is not supported. No ImagePreloader found for  (See position 1336:137)

2012-02-03 15:20:41,687 [pool-1-thread-2] ERROR org.apache.fop.apps.FOUserAgent - Image not found. URI: . (See position 1341:137)

 

Kindest regards

 


Theresa Forster

Senior Software Developer


Reply | Threaded
Open this post in threaded view
|

Re: Problem that could lose me my job

Craig Ringer-2
On 08/02/12 03:23, Luis Ferro wrote:
Hmmm... why not installing those files in a local webserver?

That way you would have a proper uri (http://localhost/etc...)

file:/// is a proper URI, it's just not a URL. Fop only requires resolvable URIs and doesn't really care where they come from.

Using HTTP would add transfer overhead and slow things down for little if any benefit. I don't really see the point, when fixing the URI syntax to conform to correct file URI syntax is all that's required here.

--
Craig Ringer
Reply | Threaded
Open this post in threaded view
|

RE: Problem that could lose me my job

Theresa Jayne Forster

OK I think I have sorted out the image url issue now when I run the pdf it shows the following warnings

2012-02-08 09:37:39,131 [pool-1-thread-1] WARN  uk.co.inbrand.fopengine.FopEngine - Before Instantiation

2012-02-08 09:37:39,156 [pool-1-thread-1] WARN  uk.co.inbrand.fopengine.FopEngine - After Instantiation

2012-02-08 09:37:54,758 [pool-1-thread-2] WARN  org.apache.fop.apps.FOUserAgent - Line 1 of a paragraph overflows the available area by 11339 millipoints. (See position 51:11)

2012-02-08 09:37:54,768 [pool-1-thread-2] WARN  org.apache.fop.apps.FOUserAgent - Content overflows the viewport of an fo:block-container in block-progression direction by 17123 millipoints. (See position 50:90)

2012-02-08 09:37:54,794 [pool-1-thread-2] WARN  org.apache.fop.apps.FOUserAgent - Content overflows the viewport of an fo:block-container in block-progression direction by 5784 millipoints. (See position 637:92)

2012-02-08 09:37:57,192 [pool-1-thread-2] WARN  org.apache.fop.apps.FOUserAgent - Line 1 of a paragraph overflows the available area by 11339 millipoints. (See position 682:11)

2012-02-08 09:37:57,193 [pool-1-thread-2] WARN  org.apache.fop.apps.FOUserAgent - Content overflows the viewport of an fo:block-container in block-progression direction by 17123 millipoints. (See position 681:91)

2012-02-08 09:37:57,487 [pool-1-thread-2] WARN  org.apache.fop.apps.FOUserAgent - Line 1 of a paragraph overflows the available area by 11339 millipoints. (See position 1358:11)

2012-02-08 09:37:57,488 [pool-1-thread-2] WARN  org.apache.fop.apps.FOUserAgent - Content overflows the viewport of an fo:block-container in block-progression direction by 17123 millipoints. (See position 1357:91)

 

But it is still not creating a valid PDF

I am getting image errors in the info log still where it can’t find an importer or convertor. What jars do I need for jpg files?

I have batik and XMLGraphics-Commons-1.4

Is there any other jar I need – like JAI? And if so what are the maven dependencies I need?

 

 

 

 

 

Kindest regards

 


Theresa Forster

Senior Software Developer


From: Craig Ringer [mailto:[hidden email]]
Sent: 08 February 2012 03:56
To: [hidden email]
Cc: Luis Ferro
Subject: Re: Problem that could lose me my job

 

On 08/02/12 03:23, Luis Ferro wrote:

Hmmm... why not installing those files in a local webserver?

That way you would have a proper uri (http://localhost/etc...)

<a href="file:///\\">file:/// is a proper URI, it's just not a URL. Fop only requires resolvable URIs and doesn't really care where they come from.

Using HTTP would add transfer overhead and slow things down for little if any benefit. I don't really see the point, when fixing the URI syntax to conform to correct file URI syntax is all that's required here.

--
Craig Ringer

12