[Yanel-dev] PDF Resource is not working any more

Kinsella, Paul Paul.Kinsella at dkib.com
Thu Apr 12 14:53:57 CEST 2007


Paloma,
 
What I did to resolve this problem was to set the configuration at runtime as follows:
 
   Configuration.put("version", "FOP 0.20.5");
   Configuration.put("stream-filter-list", "flate");
   Configuration.put("stream-filter-list", "ascii-85");
   List<String> streamFilterList = new ArrayList<String>();
   streamFilterList.add("flate");
   streamFilterList.add("ascii-85");
   Configuration.put("stream-filter-list", streamFilterList, Configuration.PDF);
 
Hope this helps.
Paul
 
 
Original Post:
 
Paloma Gomez paloma.gomez at wyona.com <mailto:yanel-development%40wyona.com?Subject=%5BYanel-dev%5D%20PDF%20Resource%20is%20not%20working%20any%20more&In-Reply-To=> 
Tue Mar 27 10:59:53 CEST 2007 

*	Previous message: [Yanel-dev] [Bug 5254] YarepUser needs to be seriazable in order to work within cluster <http://wyona.com/pipermail/yanel-development/2007-March/000579.html> 
*	Next message: [Yanel-dev] [Bug 5251] Implement xinclude <http://wyona.com/pipermail/yanel-development/2007-March/000582.html> 
*	Messages sorted by: [ date ] <http://wyona.com/pipermail/yanel-development/2007-March/date.html#580>  [ thread ] <http://wyona.com/pipermail/yanel-development/2007-March/thread.html#580>  [ subject ] <http://wyona.com/pipermail/yanel-development/2007-March/subject.html#580>  [ author ] <http://wyona.com/pipermail/yanel-development/2007-March/author.html#580>  

________________________________

Hi all,

A few days ago I realized that the pdf resource is not working. I have 
tried to find out what's wrong with it but I haven't succeeded so far. 
This is what I know:

*The changes made to this resource has been related to replacing Path to 
String (See below for a diff between the original and the current version)
*The file is actually created, but I get the following error message 
when I try to open it

"The file was damaged and could not be repaired"

*The problem seems to lie in the transformation since the resulting file 
contents are:

---------------------------------------
%PDF-1.3
%ª«¬­
4 0 obj
<< /Type /Info
/Producer (null) >>
endobj
5 0 obj
<< /Length 94 /Filter /Flat
----------------------------------------------------
*However, if I run fop 0.20.5 from the command line the transformation 
works:
--------------------------------------------
%PDF-1.3
%ª«¬­
4 0 obj
<< /Type /Info
/Producer (FOP 0.20.5) >>
endobj
5 0 obj
<< /Length 120 /Filter [ /ASCII85Decode /FlateDecode ]
 >>
stream


[....]
----------------------------------------------

Therefore I guess the problem is the java code performing the 
transformation. However, since that part of the code has not been 
changed significantly I can't see why it shouldn't work. Any hints? 
Anyway,  I'll keep on looking into it and let you know about my findings.

Regards,
Paloma


--------------------------------------------------------------------------------------------------------------------------------------------------------

@@ -65,7 +65,7 @@
      */
     public View getView(String viewId) {
         View defaultView = new View();
-        defaultView.setMimeType("application/pdf");
+        defaultView.setMimeType(getMimeType(viewId));

         try {
             Repository repo = getRealm().getRepository();
@@ -76,11 +76,11 @@
             driver.setRenderer(Driver.RENDER_PDF);
             driver.setOutputStream(baos);

-            Transformer transformer = 
TransformerFactory.newInstance().newTrans 
former(getXSLTStreamSource(path,repo));
+            Transformer transformer = 
TransformerFactory.newInstance().newTrans 
former(getXSLTStreamSource(getPath(),repo));

             org.xml.sax.XMLReader xmlReader = 
org.xml.sax.helpers.XMLReaderFact ory.createXMLReader();
             xmlReader.setEntityResolver(new 
org.apache.xml.resolver.tools.Catal ogResolver());
-            Source src = new SAXSource(xmlReader, new 
org.xml.sax.InputSource(r epo.getInputStream(path)));
+            Source src = new SAXSource(xmlReader, new 
org.xml.sax.InputSource(r epo.getInputStream(new Path(getPath()))));

             Result res = new SAXResult(driver.getContentHandler());

@@ -109,16 +109,16 @@
      *
      */
     public long getSize() throws Exception {
-        return getRealm().getRepository().getSize(path);
+        return getRealm().getRepository().getSize(new Path(getPath()));
     }

   /**
   *
   */
- private StreamSource getXSLTStreamSource(Path path, Repository repo) 
throws Re positoryException {
-     Path xsltPath = getXSLTPath(path);
+ private StreamSource getXSLTStreamSource(String path, Repository repo) 
throws RepositoryException {
+     String xsltPath = getXSLTPath(path);
      if(xsltPath != null) {
-         return new StreamSource(repo.getInputStream(xsltPath));
+         return new StreamSource(repo.getInputStream(new Path(xsltPath)));
      } else {
          File xsltFile = org.wyona.commons.io.FileUtil.file(
                  rtd.getConfigFile().getParentFile().getAbsolutePath(), 
"xslt" + File.separator + "xml2fo.xsl");
@@ -130,12 +130,17 @@
  /**
   *
   */
- private Path getXSLTPath(Path path) {
+ private String getXSLTPath(String path) {
      String xsltPath = getRTI().getProperty("xslt");
-     if (xsltPath != null) return new Path(xsltPath);
+     if (xsltPath != null) return xsltPath;
      log.info("No XSLT Path within: " + path);
      return null;
  }
-
-
+
+    /**
+     *
+     */
+    public String getMimeType(String viewId) {
+        return "application/pdf";
+    }
 }



________________________________


*	Previous message: [Yanel-dev] [Bug 5254] YarepUser needs to be seriazable in order to work within cluster <http://wyona.com/pipermail/yanel-development/2007-March/000579.html> 
*	Next message: [Yanel-dev] [Bug 5251] Implement xinclude <http://wyona.com/pipermail/yanel-development/2007-March/000582.html> 
*	Messages sorted by: [ date ] <http://wyona.com/pipermail/yanel-development/2007-March/date.html#580>  [ thread ] <http://wyona.com/pipermail/yanel-development/2007-March/thread.html#580>  [ subject ] <http://wyona.com/pipermail/yanel-development/2007-March/subject.html#580>  [ author ] <http://wyona.com/pipermail/yanel-development/2007-March/author.html#580>  

________________________________

More information about the Yanel-development mailing list <http://wyona.com/cgi-bin/mailman/listinfo/yanel-development> 



--
This e-mail is confidential and the information contained in it may be privileged.  It should not be read, copied or used by anyone other than the intended recipient.  If you have received it in error, please contact the sender immediately by telephoning +44 (0)20 7623 8000 or by return email, and delete the e-mail and do not disclose its contents to any person.  We believe, but do not warrant, that this e-mail and any attachments are virus free, but you must take full responsibility for virus checking.  Please refer to http://www.dresdnerkleinwort.com/disc/email/ and read our e-mail disclaimer statement and monitoring policy.

Dresdner Kleinwort is the trading name of the investment banking division of Dresdner Bank AG, and operates through Dresdner Bank AG, Dresdner Kleinwort Limited, Dresdner Kleinwort Securities Limited and their affiliated or associated companies.  Dresdner Bank AG is a company incorporated in Germany with limited liability and registered in England (registered no. FC007638, place of business 30 Gresham Street, London EC2V 7PG), and is authorised by the German Federal Financial Supervisory Authority and by the Financial Services Authority ('FSA') and regulated by the FSA for the conduct of designated business in the UK.  Dresdner Kleinwort Limited is a company incorporated in England (registered no. 551334, registered office 30 Gresham Street, London EC2V 7PG), and is authorised and regulated by the FSA.  Dresdner Kleinwort Securities Limited is a company incorporated in England (registered no. 1767419, registered office 30 Gresham Street, London EC2V 7PG), and is authorised and regulated by the FSA.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://wyona.com/pipermail/yanel-development/attachments/20070412/29faf4e4/attachment-0001.htm


More information about the Yanel-development mailing list