greenrd     01/01/16 07:50:34

  Modified:    .        changes.xml
               src/org/apache/cocoon/formatter FO2PDFFormatter.java
               src/org/apache/cocoon Engine.java Utils.java
               xdocs    faq.xml
               samples  index.xml
  Log:
  PDF and IE PROBLEM SOLVED! WOOHOO!!
  
  Revision  Changes    Path
  1.177     +7 -6      xml-cocoon/changes.xml
  
  Index: changes.xml
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/changes.xml,v
  retrieving revision 1.176
  retrieving revision 1.177
  diff -u -r1.176 -r1.177
  --- changes.xml       2001/01/16 12:09:50     1.176
  +++ changes.xml       2001/01/16 15:50:26     1.177
  @@ -4,7 +4,7 @@
   
   <!--
     History of Cocoon changes   
  -  $Id: changes.xml,v 1.176 2001/01/16 12:09:50 greenrd Exp $ 
  +  $Id: changes.xml,v 1.177 2001/01/16 15:50:26 greenrd Exp $ 
   -->
   
   <changes title="History of Changes">
  @@ -18,6 +18,12 @@
     </devs>
   
    <release version="@version@" date="@date@">
  +  <action dev="RDG" type="fix">
  +   At long last, FIXED the Internet Explorer PDF bug! In fact there were at 
least 3 bugs involved here,
  +   and YOU STILL NEED TO USE THE ?dummy=test.pdf WORKAROUND - see the FAQ 
for more details. 
  +   But, generated PDF files
  +   now show up perfectly in all versions of Internet Explorer - as far as we 
know!
  +  </action>
     <action dev="DB" type="add">
      Added experimental support for xsp:variable declaration and method 
calling to util taglib.
      This is designed to automatically pass through required environment 
variables such
  @@ -41,11 +47,6 @@
     <action dev="RDG" type="fix" due-to="Jamie Mascherino"
      due-to-email="[EMAIL PROTECTED]">
      Fixes to Weblogic installation instructions.
  -  </action>
  -  <action dev="RDG" type="fix" due-to="Sylvain Wallez" 
  -   due-to-email="[EMAIL PROTECTED]">
  -   WARNING! - BROKEN - BROKEN!!!
  -   Added workaround for FOP/PDF problem on Internet Explorer. 
     </action>
     <action dev="RDG" type="add">
      Added very brief notes on ESQL to documentation
  
  
  
  1.8       +2 -7      
xml-cocoon/src/org/apache/cocoon/formatter/FO2PDFFormatter.java
  
  Index: FO2PDFFormatter.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon/src/org/apache/cocoon/formatter/FO2PDFFormatter.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- FO2PDFFormatter.java      2001/01/10 23:44:32     1.7
  +++ FO2PDFFormatter.java      2001/01/16 15:50:28     1.8
  @@ -1,4 +1,4 @@
  -/*-- $Id: FO2PDFFormatter.java,v 1.7 2001/01/10 23:44:32 greenrd Exp $ -- 
  +/*-- $Id: FO2PDFFormatter.java,v 1.8 2001/01/16 15:50:28 greenrd Exp $ -- 
   
    ============================================================================
                      The Apache Software License, Version 1.1
  @@ -65,7 +65,7 @@
    *
    * @author <a href="mailto:[EMAIL PROTECTED]">Stefano Mazzocchi</a>
    * @author <a href="mailto:[EMAIL PROTECTED]">Robin Green</a>
  - * @version $Revision: 1.7 $ $Date: 2001/01/10 23:44:32 $
  + * @version $Revision: 1.8 $ $Date: 2001/01/16 15:50:28 $
    */
   
   public class FO2PDFFormatter extends AbstractFormatter implements Actor {
  @@ -128,11 +128,6 @@
   
       public void format(Document document, Writer writer, Dictionary 
parameters) throws Exception {
   
  -            // Big thanks to Sylvain Wallez for this workaround for IE!!
  -            // It should not affect Netscape's plugin integration, 
apparently.
  -            HttpServletResponse response = (HttpServletResponse) 
parameters.get ("response");
  -            response.setHeader ("Content-Disposition", "attachment; 
filename=untitled.pdf");
  - 
            Driver driver = new Driver();
            driver.setRenderer("org.apache.fop.render.pdf.PDFRenderer", 
FOP_VERSION);
            
driver.addElementMapping("org.apache.fop.fo.StandardElementMapping");
  
  
  
  1.45      +24 -24    xml-cocoon/src/org/apache/cocoon/Engine.java
  
  Index: Engine.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/Engine.java,v
  retrieving revision 1.44
  retrieving revision 1.45
  diff -u -r1.44 -r1.45
  --- Engine.java       2000/12/12 16:26:42     1.44
  +++ Engine.java       2001/01/16 15:50:29     1.45
  @@ -1,4 +1,4 @@
  -/*-- $Id: Engine.java,v 1.44 2000/12/12 16:26:42 greenrd Exp $ --
  +/*-- $Id: Engine.java,v 1.45 2001/01/16 15:50:29 greenrd Exp $ --
   
    ============================================================================
                      The Apache Software License, Version 1.1
  @@ -77,7 +77,7 @@
    *
    * @author <a href="mailto:[EMAIL PROTECTED]">Stefano Mazzocchi</a>
    * @author <a href="mailto:[EMAIL PROTECTED]">Robin Green</a>
  - * @version $Revision: 1.44 $ $Date: 2000/12/12 16:26:42 $
  + * @version $Revision: 1.45 $ $Date: 2001/01/16 15:50:29 $
    */
   
   public class Engine implements Defaults {
  @@ -302,6 +302,8 @@
   
           String encodedRequest = Utils.encode( request );
   
  +        String encoding = null;
  +
           try {
               if ( CACHE ) {
                   // ask if the cache contains the page requested and if it's
  @@ -393,7 +395,7 @@
                           page.setContent(writer.toString());
   
                           // set content type together with encoding if 
appropriate
  -                        String encoding = formatter.getEncoding();
  +                        encoding = formatter.getEncoding();
                           if (encoding != null) {
                               page.setContentType(formatter.getMIMEType() + "; 
charset=" + encoding);
                           } else {
  @@ -433,6 +435,11 @@
                   // set the response content type
                   response.setContentType(page.getContentType());
   
  +                ByteArrayOutputStream outBuf = new ByteArrayOutputStream ();
  +                boolean isHead = "HEAD".equals (request.getMethod ());
  +                byte[] content = Utils.getBytes (page.getContent (), 
encoding);
  +                int contentLength = content.length;
  +
                   // set the Last-Modified header if this option is enabled in 
cocoon.properties
                   // and the request has been cached
                   if (LASTMODIFIED) {
  @@ -442,36 +449,29 @@
                      }
                   }
   
  -                /* will fix later
  -                if (!VERBOSE && page.isText()) {
  -                    if (encoding == null) {
  -                        
response.setContentLength(page.getContent().getBytes().length);
  -                    } else {
  -                        
response.setContentLength(page.getContent().getBytes(encoding).length);
  -                    }
  -                }
  -                */
  +                outBuf.write (content);
   
  -                // get the output writer
  -                PrintWriter out = response.getWriter();
  -
  -                // send the page
  -                out.println(page.getContent());
  -
  -                // if verbose mode is on the the output type allows it
  +                // if verbose mode is on, the output type allows it
                   // and the HTTP request isn't a HEAD
                   // print some processing info as a comment
                   if (VERBOSE && (page.isText()) && 
!"HEAD".equals(request.getMethod())) {
                       time = System.currentTimeMillis() - time;
  -                    out.println("<!-- This page was served "
  +                    String comment = "<!-- This page was served "
                           + (wasInCache ? "from cache " : "")
                           + "in " + time + " milliseconds by "
  -                        + Cocoon.version() + " -->");
  -                    //out.println("<!-- free memory: " + 
Runtime.getRuntime().freeMemory() + " -->");
  +                        + Cocoon.version() + " -->";
  +                    byte[] commentBytes = Utils.getBytes (comment, encoding);
  +                    outBuf.write (commentBytes);
  +                    contentLength += commentBytes.length;
  +                }
  +                response.setContentLength (contentLength);
  + 
  +                if (!isHead) {
  +                     OutputStream realOut = response.getOutputStream();
  +                     realOut.write (outBuf.toByteArray ());
  +                     realOut.flush ();
                   }
   
  -                // send all content so that client doesn't wait while 
caching.
  -                out.flush();
                   if (PROFILE) profiler.finishEvent (requestMarker, 
OUTPUTTING);
               }
   
  
  
  
  1.22      +7 -2      xml-cocoon/src/org/apache/cocoon/Utils.java
  
  Index: Utils.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/Utils.java,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- Utils.java        2000/12/22 11:51:08     1.21
  +++ Utils.java        2001/01/16 15:50:30     1.22
  @@ -1,4 +1,4 @@
  -/*-- $Id: Utils.java,v 1.21 2000/12/22 11:51:08 greenrd Exp $ --
  +/*-- $Id: Utils.java,v 1.22 2001/01/16 15:50:30 greenrd Exp $ --
   
    ============================================================================
                      The Apache Software License, Version 1.1
  @@ -66,11 +66,16 @@
    *
    * @author <a href="mailto:[EMAIL PROTECTED]">Stefano Mazzocchi</a>
    * @author <a href="mailto:[EMAIL PROTECTED]">Robin Green</a>
  - * @version $Revision: 1.21 $ $Date: 2000/12/22 11:51:08 $
  + * @version $Revision: 1.22 $ $Date: 2001/01/16 15:50:30 $
    */
   
   public final class Utils {
   
  +    public static byte[] getBytes (String s, String encoding)
  +    throws UnsupportedEncodingException {
  +        return (encoding == null) ? s.getBytes () : s.getBytes (encoding);
  +    }
  +                                                                             
                     
       /**
        * This method returns a vector of PI nodes based on the PI target name.
        */
  
  
  
  1.43      +16 -20    xml-cocoon/xdocs/faq.xml
  
  Index: faq.xml
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/xdocs/faq.xml,v
  retrieving revision 1.42
  retrieving revision 1.43
  diff -u -r1.42 -r1.43
  --- faq.xml   2001/01/15 20:26:42     1.42
  +++ faq.xml   2001/01/16 15:50:32     1.43
  @@ -579,17 +579,22 @@
   
     <question>Why is Internet Explorer not showing PDF or VRML 
samples?</question>
     <answer>
  -   <p>This is a long-time problem with Internet Explorer which doesn't look 
for
  -   the MIME type sent by the HTTP response, but instead just looks at the
  -   file extension at the end of the URL to determine what program should
  -   open it (unlike other
  -   browsers which are smarter and follow the Internet standards 
  -   correctly).
  -   There is a trick that forces IE to look at the MIME type -
  -   adding a <code>?</code> at the end of your URI. Cocoon should
  -   ignore this, but IE won't, and will react to the MIME type and 
  -   trigger the correct plugin/application for that content.</p>
  +   <p>There are at least <strong>three distinct bugs</strong> involved 
here.</p>
   
  +   <p>The first is a HTTP glitch in Cocoon which triggers a second bug in 
IE. This has been
  +    fixed in Cocoon 1.8.1, so first make sure you are using Cocoon 1.8.1 or 
higher.</p>
  +
  +   <p>The third is a long-time problem with Internet Explorer which doesn't 
look 
  +    for the MIME type sent by the HTTP response, but instead just looks at 
the
  +    file extension at the end of the URL to determine what program should
  +    open it (unlike other browsers which are smarter and follow the Internet 
standards 
  +    correctly).
  +    There is a trick that forces IE to look at the MIME type -
  +    adding <code>?dummy=test.pdf</code> (or some similar parameter ending in 
.pdf)
  +    at the end of your URI. Cocoon should
  +    ignore this, but IE won't, and will react to the MIME type and 
  +    trigger the correct plugin/application for that content.</p>
  +
      <p>Russ Whyte has also developed a 
       <link 
href="http://archive.covalent.net/xml/cocoon-users/2000/09/0618.xml";>
       simple servlet workaround</link> which should work for any browser;
  @@ -601,22 +606,13 @@
       Note that this is <em>not</em> a bug in Cocoon and is completely outside
       our control.</p>
   
  -   <note>There are bugs in MS Internet Explorer 5.x and/or Acrobat Reader
  -    which even ignore the question mark. See the
  +   <note>See also the (rather unhelpful)
       <link 
href="http://support.microsoft.com/support/kb/articles/Q177/3/21.ASP";>
       Microsoft Knowledge Base</link> and 
       <link href="http://www.adobe.com/support/techdocs/3d76.htm";>
       Adobe Support Knowledgebase (1)</link>, 
       <link href="http://www.adobe.com/support/techdocs/98fe.htm";>(2)</link>.
      </note>
  -  </answer>
  - </faq>
  -
  - <faq id="faq-ieopensave">
  -  <question>Why is Internet Explorer bringing up an Open/Save dialog when I 
view PDF pages?</question>
  -  <answer>
  -   <p>This is a workaround for a bug in Internet Explorer (see previous 
question). We think you'll agree
  -    it's preferable to just an empty page!</p>
     </answer>
    </faq>
   
  
  
  
  1.19      +5 -10     xml-cocoon/samples/index.xml
  
  Index: index.xml
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/samples/index.xml,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- index.xml 2001/01/10 21:25:12     1.18
  +++ index.xml 2001/01/16 15:50:33     1.19
  @@ -101,36 +101,31 @@
      This page shows how you can use Cocoon to generate dynamic content using
      XML processing instructions to trigger ECMAScript logic execution.
     </sample>-->
  -
  -  <sample name="Special Producer" url="dummy.xml?producer=dummy">
  -   This page shows how you can use Cocoon to generate dynamic content using
  -   XML processing instructions to trigger ECMAScript logic execution.
  -  </sample>
    </group>
   
    <!-- 
  -      Stupid IE has a bug in the handling of MIME-types and we fool it adding
  -      a '?' after the url. Tell me, isn't this totally nonsense? I mean, 
  +      Stupid IE has a bug in the handling of MIME-types and we fool it by 
adding
  +      a "?dummy=test.pdf" after the url. Tell me, isn't this totally 
nonsense? I mean, 
         Cocoon is simply ignoring that query so, while this
         is the worse hack I've ever seen, this is the only way we make IE
         do what it's supposed to do. Microsoft, listen up: patch the damn 
thing! 
     -->
         
    <group name="Formatting Object Rendering">
  -  <sample name="Simple FO Example" url="fo/test-fo.xml?">
  +  <sample name="Simple FO Example" url="fo/test-fo.xml?dummy=test.pdf">
      This page shows some potentials of the XSL Formatting Object 
specifications
      tranformed into PDF (we suggest you to install Adobe Acrobat Reader as 
your
      browser plugin for smoother integration)
     </sample>
   
  -  <sample name="More complex FO + SVG Example" url="fo/test2-fo.xml?">
  +  <sample name="More complex FO + SVG Example" 
url="fo/test2-fo.xml?dummy=test.pdf">
      This page shows higher potentials of the XSL Formatting Object 
specifications
      when mixed with other graphic outline specification such as SVG (Scalable
      Vector Graphics). Both are interpreted by FOP and rendered into PDF as
      area and vector graphics.
     </sample>
   
  -  <sample name="Novel FO formatting" url="fo/darkness-novel.xml?">
  +  <sample name="Novel FO formatting" 
url="fo/darkness-novel.xml?dummy=test.pdf">
      In this example, part of Joseph Conrad's "The Heart of Darkness" novel
      is taken from its orginal style-free XML format and rendered into PDF
      using an XML->FO stylesheet.
  
  
  

Reply via email to