[reportlab-users] Re: reST and PDF using Reportlab

David Abrahams reportlab-users@reportlab.com
Sun, 29 Jun 2003 03:50:54 -0400


--=-=-=

Dinu Gherman <gherman@darwin.in-berlin.de> writes:

> David Abrahams:
>
>> See modulename/dreamcatcher/rlpdf/* in the CVS.
>
> I just made a CVS download/install of docutils, but there is really
> nothing dreamcatcher-like in it, although this page says quite the
> contrary: http://docutils.sourceforge.net/#the-sandbox .
>
> So, I've dowloaded your stuff seperately from here:
> http://docutils.sourceforge.net/sandbox/dreamcatcher/

Wrong place.  There's no stuff of mine in there.

http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/docutils/modulename/dreamcatcher/rlpdf/

Shows where the material is.

  cvs -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/docutils login 
  cvs -z3 -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/docutils co modulename 

To get it.

>> Be sure to run modulename/dreamcatcher/tools/pdf.py with
>> --output-encoding=unicode_internal or you'll be endlessly frustrated.
>
> Even when doing so, I'm still frustrated, because you seem to need
> patched versions of these modules:
>
>    reportlab/lib/rparsexml.py
>    reportlab/pdfgen/canvas.py
>    reportlab/platypus/para.py
>
> Could you elaborate on why that is the case, please?

Perhaps because you're using the wrong code?  The only patches I have
against reportlab's recent CVS are against rparsexml.py and
c:/src/reportlab/reportlab/platypus/tables.py, enclosed here, FWIW.
The differences in rparsexml.py are my personal diagnostic tools and
shouldn't have any impact on semantics.


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment; filename=rparsexml.diff

Index: rparsexml.py
===================================================================
RCS file: /cvsroot/reportlab/reportlab/lib/rparsexml.py,v
retrieving revision 1.2
diff -c -r1.2 rparsexml.py
*** rparsexml.py	4 Nov 2002 00:11:48 -0000	1.2
--- rparsexml.py	29 Jun 2003 07:41:32 -0000
***************
*** 46,52 ****
  
  import string
  try:
!     #raise ImportError, "dummy error"
      simpleparse = 0
      import pyRXP
      if pyRXP.version>='0.5':
--- 46,52 ----
  
  import string
  try:
!     # raise ImportError, "dummy error"
      simpleparse = 0
      import pyRXP
      if pyRXP.version>='0.5':
***************
*** 61,66 ****
--- 61,68 ----
                              srcName='string input')
          def parsexml(xmlText, oneOutermostTag=0,eoCB=None):
              pyRXP_parser.eoCB = eoCB
+             #print '======= parsing:'
+             #print repr(xmlText)
              p = pyRXP_parser.parse(xmlText)
              return oneOutermostTag and p or ('',None,[p],None)
      else:
***************
*** 74,79 ****
--- 76,82 ----
              p = pyRXP.parse(xmlText,srcName='string input',flags=flags,warnCB=warnCB,eoCB=eoCB)
              return oneOutermostTag and p or ('',None,[p],None)
  except ImportError:
+     print 'failed to import pyRXP, falling back to simpleparse'
      simpleparse = 1
  
  NONAME = ""
***************
*** 98,104 ****
      """official interface: discard unused cursor info"""
      if RequirePyRXP:
          raise ImportError, "pyRXP not found, fallback parser disabled"
!     (result, cursor) = parsexml0(xmltext)
      if oneOutermostTag:
          return result[2][0]
      else:
--- 101,113 ----
      """official interface: discard unused cursor info"""
      if RequirePyRXP:
          raise ImportError, "pyRXP not found, fallback parser disabled"
!     viv = parsexml0(xmltext)
!     if len(viv) != 2:
!         print '--------'
!         print viv
!         print '--------'
!     (result, cursor) = viv
!     
      if oneOutermostTag:
          return result[2][0]
      else:
***************
*** 359,365 ****
                  #if verbose:
                  #    #print "skipping", repr(remainder)
                  #    #print "--- recursively parsing starting at", xmltext[nextopenbracket:nextopenbracket+20]
!                 (parsetree, cursor) = parsexml0(xmltext, startingat=nextopenbracket, toplevel=None)
                  if parsetree:
                      L.append(parsetree)
          # maybe should check for trailing garbage?
--- 368,381 ----
                  #if verbose:
                  #    #print "skipping", repr(remainder)
                  #    #print "--- recursively parsing starting at", xmltext[nextopenbracket:nextopenbracket+20]
! 
!                 viv = parsexml0(xmltext, startingat=nextopenbracket,
!                                 toplevel=None)
!                 if len(viv) != 2:
!                     print '--------'
!                     print viv
!                     print '--------'
!                 (parsetree, cursor) = viv
                  if parsetree:
                      L.append(parsetree)
          # maybe should check for trailing garbage?

--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment; filename=tables.diff

*** tables.py.~1.65.~	Tue Apr 22 13:32:02 2003
--- tables.py	Thu Jun 19 17:25:36 2003
***************
*** 113,118 ****
--- 113,120 ----
          #print "colWidths", colWidths
          self.hAlign = 'CENTER'
          self.vAlign = 'MIDDLE'
+         self._cellvalues = [] # dwa 2003/6/19 - this gets used without
+                               # initialization in error reporting
          if type(data) not in _SeqTypes:
              raise ValueError, "%s invalid data type" % self.identity()
          self._nrows = nrows = len(data)

--=-=-=


BTW, I've sort of given up on usinig Reportlab to generate PDF from
ReST, at least for the time being, since Platypus is missing the
architectural infrastructure for correct formatting of footnotes and
flexible table representation.  Englebert Gruber has been quite
responsive to issues in his ReST->TeX conversion, and there are
numerous tools which go TeX->PDF very nicely.

HTH,
-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com

--=-=-=--