[Zope] [ZGotW] Issue #4 (Closed)

Zope Guru of the Week ZGotW@palladion.com
Fri, 18 Feb 2000 07:55:57 US/Pacific


The current issue of "Zope Guru of the Week" has closed:

===================================================================
Issue #4 -- Best way to output from ZOPE to MS Word
===================================================================

       Status:  Closed 

    Zen Level:  Disciple (3/8)

     Keywords:  DTML 

 Submitted by:  Brian Hickman bkkr@worldnet.att.net
-------------------------------------------------------------------
My clients require a printed document, along with a version
in MS Word format.  What is the best way to send a document
created in ZOPE to MS Word?

*Editor: I'd like to broaden this to include alternative
strategies for exporting formatted documents from Zope, as well
as more classic "report writing."*

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

  Reviewed by:  Tres Seaver tseaver@palladion.com
-------------------------------------------------------------------
Summary

 - David Brown suggests two possibilities:

   * construct a Word document on theserver-side using an
     ExternalMethod and the COM interface to Word;  maybe even
     print the document from within the EM.

    *Ed.: Note that this requires that you run your Zope server
     on Win32;  you would probably need to use the unsupported
     "COMObject":http://www.zope.org/Products/COMObject Product.
     It will also require figuring out where on the hard-drive
     the temporary document should live, and how to stream that
     document out as part of the response.  Has anyone actually
     done this?*

   * Generate a RichTextFormat stream, which Word can read
     "natively".

     *Ed.: this is not for the faint of heart.  Here are 
           a couple of RTF links:*

     o Microsoft's "spec":http://msdn.microsoft.com/library/specs/rtfspec.htm
       (version 1.6)

     o "RTF Tools":ftp://ftp.primate.wisc.edu/pub/RTF

     o An RTF-to-HTML "translator":http://www.sunpack.com/RTF/

     *This solution may not quite meet the spec, either, if the
      requirement, "document in MS Word format" is not
      sufficiently elastic as to encompass RTF.*

 - Shalabh recommends using WebDAV from Word2000, which
   lets you open, edit, and print Zope documents using WebFolders.

   *Ed.:  I am assuming from his enthusiasm ("Simple, Sweet
          and Straightforward") that Shalabh is actually using
          this technique.  I haven't managed to make it work yet,
          but I haven't tried very hard, either;  I wiped
          Office2000 from the <strike>soles of my shoes</strike>
          HDD after an unhappy install.  This looks like a good
          candidate for a HowTo.*

 - Lalo Martins notes that Word can read HTML:  "just format it
   in a way that looks good in Word (you'll have to use
   trial-and-error for that)."

   *Ed.: anyone have a sample stylesheet or document which
         would help here?  Word does UGLY things when it
         generates HTML -- I presume that reading it is
         somewhat simpler.  This solution also ignores the
         poster's stated requirement for generating a "document
         in MS Word format" -- I don't much care for it as
         a requirement (it specifies a technical solution, not
         a business need), but it **is** part of the problem.*

   WRT the broader, "report-writing" question, Lalo reports
   success using the 
   "PDFDocument"://http://www.zope.org/Members/gaaros/ZpdfDocument
   product to generate PDF files from within Zope (I'm guessing
   that this is the right URL -- it looks good, anyway).

 *Editor's plea:  when possible, **please** include relevant
  links when you post a reply, whether here or on the mailing
  list;  the usefulness of your reply goes **way** up when it
  links the resources needed to use it.*

Conclusion

  First, many thanks to Brian, David, Shalabh, and Lalo!

  All of the proposed solutions have merit, given their
  respective tradeoffs.  PDFDocument may be the best overall
  "reporting" solution, giving the precise control over layout
  which HTML simply can't;  RTF generation looks like the
  "sanest" approach to the problem of "extruding" a Word
  document; reading documents in Word through WebDAV is cool,
  but may not play nice with DTML:  either WebDAV hands out
  the rendered HTML (in which case Word can read but not edit
  it) or WebDAV hands out the DTML source (not useful for
  printing, but essential for editing.)

  This issue points up a couple of opportunities for product
  development:

  * hacking PDFDocument to produce RTF as an option

  * a framework for building "canned" reports using
    Zope's dynamic features, e.g., ZCatalog, ZSQL, etc.

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