Re: [Zope] Re: html2pdf
On Thursday 12 July 2007 18:19, Maurits van Rees wrote: Garry Saddington, on 2007-07-12: I am trying to use html2pdf and htmldoc to generate pdfs on the fly. I can get it to work perfectly if I set all view permissions for anonymous. However, this is not suitable for a member only site. Can anyone point me in the right direction for such use? I am using: (Zope 2.9.0, python 2.4.2, win32) and latest version of html2pdf. I would simply say: set the view permissions to Member and not to Anonymous. Then report back here with any errors you get. In the html2pdf howto at Zope it says 'Only works with anonymous permissions' -- just read it properly!. Probably because the htmldoc process accesses the web page via a URL passed to it by html2pdf. So I guess I will have to pass the rendered page to the script and hence to htmldoc. When I use it now all I get is a nice PDF of the cookiecrumbler login screen and no error messages in the error_log. Thanks for replying, am I on the right lines? Regards Garry ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
RE: [Zope] RE: html2pdf truncating html content
Refinement of problem statement: The DTML file on which html2pdf is called is populated by a python script which builds and returns html by processing a list of objects in a for loop. The html content which is missing from the pdf is generated inside the for loop. As said before though, the information built in the for loop is displayed in the DTML when it is viewed as a webpage. The python is below: data = "" for n in context.objectValues(['RDMA Narrative','RDMA Indicator']) if n.country==selectedCountry] body="" ##TITLE PAGEbody+="h1%s/h1\n" % selectedCountrybody+="!-- PAGE BREAK --\n" ##BODYfor d in data: body+="%s\n" % (d.title) if d.meta_type == 'RDMA Indicator': if hasattr(d,'xltohtml'): body+=d.xltohtml() elif d.meta_type == 'RDMA Narrative': body+="h3%s/h3" % d.narrativeType body+=d.narrativeText body+="!-- PAGE BREAK --\n" return body From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Smith, BarrettSent: Monday, July 17, 2006 9:14 AMTo: zope@zope.orgSubject: [Zope] RE: html2pdf truncating html content I'm using html2pdf and it seems to be truncating the content. The html on which html2pdf is: htmlheadtitleNarrative Report/title/headbodyh1PNG/h1!-- PAGE BREAK --h2Narrative: PNG- Challenge Situation/h2!-- PAGE BREAK --h2Narrative: PNG- Key Accomplishments/h2!-- PAGE BREAK --h2Narrative: PNG- Program Performance/h2 !-- PAGE BREAK -- h2Narrative: PNG- Success Stories/h2 !-- PAGE BREAK -- h2Table 1-2 PNG/h2 !-- PAGE BREAK -- h2Table 1-4 PNG/h2 !-- PAGE BREAK -- h2Narrative: PNG- Annex II/h2 !-- PAGE BREAK -- h2Narrative: PNG- Annex III/h2 !-- PAGE BREAK -- /body /html The html which html2pdf is writing to the pdf though is:htmlheadtitleNarrative Report/title/headbodyh1PNG/h1!-- PAGE BREAK --/body/htmlI'm at a loss to explain the truncation. Can anyone offer some suggestions? ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] RE: html2pdf truncating html content
Just a wag (wild assed guess)... in your BODY loop, if d.title is null could you be embedding a 'null' char in the text string, which may cause html2pdf to choke? Jonathan - Original Message - From: Smith, Barrett To: zope@zope.org Sent: Monday, July 17, 2006 9:30 AM Subject: RE: [Zope] RE: html2pdf truncating html content Refinement of problem statement: The DTML file on which html2pdf is called is populated by a python script which builds and returns html by processing a list of objects in a for loop. The html content which is missing from the pdf is generated inside the for loop. As said before though, the information built in the for loop is displayed in the DTML when it is viewed as a webpage. The python is below: data = "" for n in context.objectValues(['RDMA Narrative','RDMA Indicator']) if n.country==selectedCountry] body="" ##TITLE PAGEbody+="h1%s/h1\n" % selectedCountrybody+="!-- PAGE BREAK --\n" ##BODYfor d in data: body+="%s\n" % (d.title) if d.meta_type == 'RDMA Indicator': if hasattr(d,'xltohtml'): body+=d.xltohtml() elif d.meta_type == 'RDMA Narrative': body+="h3%s/h3" % d.narrativeType body+=d.narrativeText body+="!-- PAGE BREAK --\n" return body From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Smith, BarrettSent: Monday, July 17, 2006 9:14 AMTo: zope@zope.orgSubject: [Zope] RE: html2pdf truncating html content I'm using html2pdf and it seems to be truncating the content. The html on which html2pdf is: htmlheadtitleNarrative Report/title/headbodyh1PNG/h1!-- PAGE BREAK --h2Narrative: PNG- Challenge Situation/h2!-- PAGE BREAK --h2Narrative: PNG- Key Accomplishments/h2!-- PAGE BREAK --h2Narrative: PNG- Program Performance/h2 !-- PAGE BREAK -- h2Narrative: PNG- Success Stories/h2 !-- PAGE BREAK -- h2Table 1-2 PNG/h2 !-- PAGE BREAK -- h2Table 1-4 PNG/h2 !-- PAGE BREAK -- h2Narrative: PNG- Annex II/h2 !-- PAGE BREAK -- h2Narrative: PNG- Annex III/h2 !-- PAGE BREAK -- /body /html The html which html2pdf is writing to the pdf though is:htmlheadtitleNarrative Report/title/headbodyh1PNG/h1!-- PAGE BREAK --/body/htmlI'm at a loss to explain the truncation. Can anyone offer some suggestions? ___Zope maillist - Zope@zope.orghttp://mail.zope.org/mailman/listinfo/zope** No cross posts or HTML encoding! **(Related lists - http://mail.zope.org/mailman/listinfo/zope-announcehttp://mail.zope.org/mailman/listinfo/zope-dev ) ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] RE: html2pdf truncating html content
some more wags: 1) remove the html comments from the generated html code (ie. get rid of the !-- PAGE BREAK -- tags) 2) remove the body loop and hard code in a 1 liner insteadeg. body +='some new text' and see what happens 3) where are the html and /html tags added into the html code you pass to html2pdf? (they weren't in the python code you posted) Jonathan - Original Message - From: Smith, Barrett To: Jonathan ; zope@zope.org Sent: Monday, July 17, 2006 10:39 AM Subject: RE: [Zope] RE: html2pdf truncating html content Thanks, Jonathan, but no joy. Testing for the value of of d.title before writing it doesn't change the output and even a hardcoded body+="text goes here" just inside the for loop doesn't get printed. Barrett From: Jonathan [mailto:[EMAIL PROTECTED] Sent: Monday, July 17, 2006 10:25 AMTo: Smith, Barrett; zope@zope.orgSubject: Re: [Zope] RE: html2pdf truncating html content Just a wag (wild assed guess)... in your BODY loop, if d.title is null could you be embedding a 'null' char in the text string, which may cause html2pdf to choke? Jonathan - Original Message - From: Smith, Barrett To: zope@zope.org Sent: Monday, July 17, 2006 9:30 AM Subject: RE: [Zope] RE: html2pdf truncating html content Refinement of problem statement: The DTML file on which html2pdf is called is populated by a python script which builds and returns html by processing a list of objects in a for loop. The html content which is missing from the pdf is generated inside the for loop. As said before though, the information built in the for loop is displayed in the DTML when it is viewed as a webpage. The python is below: data = "" for n in context.objectValues(['RDMA Narrative','RDMA Indicator']) if n.country==selectedCountry] body="" ##TITLE PAGEbody+="h1%s/h1\n" % selectedCountrybody+="!-- PAGE BREAK --\n" ##BODYfor d in data: body+="%s\n" % (d.title) if d.meta_type == 'RDMA Indicator': if hasattr(d,'xltohtml'): body+=d.xltohtml() elif d.meta_type == 'RDMA Narrative': body+="h3%s/h3" % d.narrativeType body+=d.narrativeText body+="!-- PAGE BREAK --\n" return body From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Smith, BarrettSent: Monday, July 17, 2006 9:14 AMTo: zope@zope.orgSubject: [Zope] RE: html2pdf truncating html content I'm using html2pdf and it seems to be truncating the content. The html on which html2pdf is: htmlheadtitleNarrative Report/title/headbodyh1PNG/h1!-- PAGE BREAK --h2Narrative: PNG- Challenge Situation/h2!-- PAGE BREAK --h2Narrative: PNG- Key Accomplishments/h2!-- PAGE BREAK --h2Narrative: PNG- Program Performance/h2 !-- PAGE BREAK -- h2Narrative: PNG- Success Stories/h2 !-- PAGE BREAK -- h2Table 1-2 PNG/h2 !-- PAGE BREAK -- h2Table 1-4 PNG/h2 !-- PAGE BREAK -- h2Narrative: PNG- Annex II/h2 !-- PAGE BREAK -- h2Narrative: PNG- Annex III/h2 !-- PAGE BREAK -- /body /html The html which html2pdf is writing to the pdf though is:htmlheadtitleNarrative Report/title/headbodyh1PNG/h1!-- PAGE BREAK --/body/htmlI'm at a loss to explain the truncation. Can anyone offer some suggestions? ___Zope maillist - Zope@zope.orghttp://mail.zope.org/mailman/listinfo/zope** No cross posts or HTML encoding! **(Related lists - http://mail.zope.org/mailman/listinfo/zope-announcehttp://mail.zope.org/mailman/listinfo/zope-dev ) ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
RE: [Zope] RE: html2pdf truncating html content
Thanks, Jonathan, but no joy. Testing for the value of of d.title before writing it doesn't change the output and even a hardcoded body+="text goes here" just inside the for loop doesn't get printed. Barrett From: Jonathan [mailto:[EMAIL PROTECTED] Sent: Monday, July 17, 2006 10:25 AMTo: Smith, Barrett; zope@zope.orgSubject: Re: [Zope] RE: html2pdf truncating html content Just a wag (wild assed guess)... in your BODY loop, if d.title is null could you be embedding a 'null' char in the text string, which may cause html2pdf to choke? Jonathan - Original Message - From: Smith, Barrett To: zope@zope.org Sent: Monday, July 17, 2006 9:30 AM Subject: RE: [Zope] RE: html2pdf truncating html content Refinement of problem statement: The DTML file on which html2pdf is called is populated by a python script which builds and returns html by processing a list of objects in a for loop. The html content which is missing from the pdf is generated inside the for loop. As said before though, the information built in the for loop is displayed in the DTML when it is viewed as a webpage. The python is below: data = "" for n in context.objectValues(['RDMA Narrative','RDMA Indicator']) if n.country==selectedCountry] body="" ##TITLE PAGEbody+="h1%s/h1\n" % selectedCountrybody+="!-- PAGE BREAK --\n" ##BODYfor d in data: body+="%s\n" % (d.title) if d.meta_type == 'RDMA Indicator': if hasattr(d,'xltohtml'): body+=d.xltohtml() elif d.meta_type == 'RDMA Narrative': body+="h3%s/h3" % d.narrativeType body+=d.narrativeText body+="!-- PAGE BREAK --\n" return body From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Smith, BarrettSent: Monday, July 17, 2006 9:14 AMTo: zope@zope.orgSubject: [Zope] RE: html2pdf truncating html content I'm using html2pdf and it seems to be truncating the content. The html on which html2pdf is: htmlheadtitleNarrative Report/title/headbodyh1PNG/h1!-- PAGE BREAK --h2Narrative: PNG- Challenge Situation/h2!-- PAGE BREAK --h2Narrative: PNG- Key Accomplishments/h2!-- PAGE BREAK --h2Narrative: PNG- Program Performance/h2 !-- PAGE BREAK -- h2Narrative: PNG- Success Stories/h2 !-- PAGE BREAK -- h2Table 1-2 PNG/h2 !-- PAGE BREAK -- h2Table 1-4 PNG/h2 !-- PAGE BREAK -- h2Narrative: PNG- Annex II/h2 !-- PAGE BREAK -- h2Narrative: PNG- Annex III/h2 !-- PAGE BREAK -- /body /html The html which html2pdf is writing to the pdf though is:htmlheadtitleNarrative Report/title/headbodyh1PNG/h1!-- PAGE BREAK --/body/htmlI'm at a loss to explain the truncation. Can anyone offer some suggestions? ___Zope maillist - Zope@zope.orghttp://mail.zope.org/mailman/listinfo/zope** No cross posts or HTML encoding! **(Related lists - http://mail.zope.org/mailman/listinfo/zope-announcehttp://mail.zope.org/mailman/listinfo/zope-dev ) ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
RE: [Zope] RE: html2pdf truncating html content
Found the problem: context was changing. When called from html2pdf, the parent object was different from when the dtml was called raw. From: Jonathan [mailto:[EMAIL PROTECTED] Sent: Monday, July 17, 2006 10:52 AMTo: Smith, Barrett; zope@zope.orgSubject: Re: [Zope] RE: html2pdf truncating html content some more wags: 1) remove the html comments from the generated html code (ie. get rid of the !-- PAGE BREAK -- tags) 2) remove the body loop and hard code in a 1 liner insteadeg. body +='some new text' and see what happens 3) where are the html and /html tags added into the html code you pass to html2pdf? (they weren't in the python code you posted) Jonathan - Original Message - From: Smith, Barrett To: Jonathan ; zope@zope.org Sent: Monday, July 17, 2006 10:39 AM Subject: RE: [Zope] RE: html2pdf truncating html content Thanks, Jonathan, but no joy. Testing for the value of of d.title before writing it doesn't change the output and even a hardcoded body+="text goes here" just inside the for loop doesn't get printed. Barrett From: Jonathan [mailto:[EMAIL PROTECTED] Sent: Monday, July 17, 2006 10:25 AMTo: Smith, Barrett; zope@zope.orgSubject: Re: [Zope] RE: html2pdf truncating html content Just a wag (wild assed guess)... in your BODY loop, if d.title is null could you be embedding a 'null' char in the text string, which may cause html2pdf to choke? Jonathan - Original Message - From: Smith, Barrett To: zope@zope.org Sent: Monday, July 17, 2006 9:30 AM Subject: RE: [Zope] RE: html2pdf truncating html content Refinement of problem statement: The DTML file on which html2pdf is called is populated by a python script which builds and returns html by processing a list of objects in a for loop. The html content which is missing from the pdf is generated inside the for loop. As said before though, the information built in the for loop is displayed in the DTML when it is viewed as a webpage. The python is below: data = "" for n in context.objectValues(['RDMA Narrative','RDMA Indicator']) if n.country==selectedCountry] body="" ##TITLE PAGEbody+="h1%s/h1\n" % selectedCountrybody+="!-- PAGE BREAK --\n" ##BODYfor d in data: body+="%s\n" % (d.title) if d.meta_type == 'RDMA Indicator': if hasattr(d,'xltohtml'): body+=d.xltohtml() elif d.meta_type == 'RDMA Narrative': body+="h3%s/h3" % d.narrativeType body+=d.narrativeText body+="!-- PAGE BREAK --\n" return body From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Smith, BarrettSent: Monday, July 17, 2006 9:14 AMTo: zope@zope.orgSubject: [Zope] RE: html2pdf truncating html content I'm using html2pdf and it seems to be truncating the content. The html on which html2pdf is: htmlheadtitleNarrative Report/title/headbodyh1PNG/h1!-- PAGE BREAK --h2Narrative: PNG- Challenge Situation/h2!-- PAGE BREAK --h2Narrative: PNG- Key Accomplishments/h2!-- PAGE BREAK --h2Narrative: PNG- Program Performance/h2 !-- PAGE BREAK -- h2Narrative: PNG- Success Stories/h2 !-- PAGE BREAK -- h2Table 1-2 PNG/h2 !-- PAGE BREAK -- h2Table 1-4 PNG/h2 !-- PAGE BREAK -- h2Narrative: PNG- Annex II/h2 !-- PAGE BREAK -- h2Narrative: PNG- Annex III/h2 !-- PAGE BREAK -- /body /html The html which html2pdf is writing to the pdf though is:htmlheadtitleNarrative Report/title/headbodyh1PNG/h1!-- PAGE BREAK --/body/htmlI'm at a loss to explain the truncation. Can anyone offer some suggestions? ___Zope maillist - Zope@zope.orghttp://mail.zope.org/mailman/listinfo/zope** No cross posts or HTML encoding! **(Related lists - http://mail.zope.org/mailman/listinfo/zope-announcehttp://mail.zope.org/mailman/listinfo/zope-dev ) ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )