Hi,

Now it work very well on my site and can be run on NginX

step


   1. download : 
   
http://downloads.sourceforge.net/project/wkhtmltopdf/0.12.2.1/wkhtmltox-0.12.2.1_linux-trusty-amd64.deb
   2. install : (from command line)
      1. dpkg -i wkhtmltox-0.12.2.1_linux-trusty-amd64.deb
      2. cp /usr/local/bin/wkhtmltopdf /usr/bin/
   3. in controller

   - def print_from_list__pdf():
      
      1. #### import
         2. import os, re
         3. from subprocess import call
         4. 
         5. #### set source and result path
         6. body_html_path   = os.path.join(request.folder, "static", 
         "template/contact_lists__print_from_list__body.html")
         7. header_html_path = os.path.join(request.folder, "static", 
         "template/contact_lists__print_from_list__header.html")
         8. footer_html_path = os.path.join(request.folder, "static", 
         "template/contact_lists__print_from_list__footer.html")
         9. result_pdf_path  = os.path.join(request.folder, "static", 
         "template/%s.pdf" %print_job__id)
         10. #### print process
         11. # body
         12. html = response.render('contact_lists/print_from_list.html', 
         dict(smart_search=smart_search, user__id=user__id)) 
         13. file(body_html_path, "wb").write(html)
         14. # header
         15. 
         16. html = response.render('print_template/letter_head_cac.html', 
         dict(page_title = 'Contact Lists', user__id = user__id))
         17. file(header_html_path, "wb").write(html)
         18. # footer
         19. html = response.render('print_template/letter_footer_cac.html')
         20. file(footer_html_path, "wb").write(html)  
         21. call('wkhtmltopdf --margin-top 50mm --margin-left 10 
         --margin-right 10 --margin-bottom 30mm  %s --header-html %s 
--footer-html 
         %s  %s' %(body_html_path, header_html_path, footer_html_path, 
         result_pdf_path), shell=True
      4. for Apache you can run call subprocess with no problem but in 
   Nginx you have to run in web2py scheduler
   5. My case I use schedule to run and stream upload to print spooler 
   table, after print user have to open spooler for print.

<https://lh3.googleusercontent.com/-KVYRGdh_M_0/VTcBwRDM5zI/AAAAAAAAAP0/sl43fdl7KnQ/s1600/Screen%2BShot%2B2558-04-22%2Bat%2B9.01.33%2BAM.png>

Hope it help.

Ariya


เมื่อ วันอังคารที่ 21 เมษายน ค.ศ. 2015 20 นาฬิกา 19 นาที 47 วินาที UTC+7, 
Ovidio Marinho เขียนว่า:
>
> Hello Arya,
>
> How did you do this can publish the code?
>
>
>
>
>
>                    [image: http://itjp.net.br] <http://itjp.net.br>
>                      http://itjp.net.b <http://itjp.net.br>r
>           *Ovidio Marinho Falcao Neto*
>                  [email protected] <javascript:>
>                             Brasil
>              
>
> 2015-01-15 10:54 GMT-03:00 Ariya Owam-aram <[email protected] 
> <javascript:>>:
>
>> Hi Bruno,
>>
>> I install wkhtmltopdf and integrate with web2py by using subprocess.call, 
>> it work very well on my macbook (rocket server). But I can't success 
>> running subprocess.call on production server (Ngix). I also test 
>> subprocess.call wkthtmltopdf from web2py's shell (admin) it return non-zero 
>> number as output. (nothing comeout)
>>
>> But suprocess.call wkhtmltopdf is working well in the web2py shell 
>> (python web2py.py -S app -M).
>>
>> Now I don't know where to go next?
>>
>> Can you please tell me what I missing.
>>
>> Thank you in advanced.
>> Ariya 
>>
>> On Thursday, December 6, 2012 at 3:36:50 AM UTC+7, rochacbruno wrote:
>>>
>>> I found this excellent command line tool: 
>>> http://code.google.com/p/wkhtmltopdf/
>>>
>>> It generates the PDF qith a very nice quality and I see it is easy to 
>>> integrate on web2py applications using pysh or subprocess.
>>>
>>> http://code.google.com/p/wkhtmltopdf/
>>>
>>>
>>> *Bruno Cezar Rocha** - @rochacbruno*
>>> [email protected] | Mobile: +55 (11) 99210-8821
>>> www.CursoDePython.com.br | www.rochacbruno.com.br
>>> Blog: microblog app <http://rochacbruno.com.br/microblog-app/>
>>>   Get a signature like this. 
>>> <http://r1.wisestamp.com/r/landing?promo=18&dest=http%3A%2F%2Fwww.wisestamp.com%2Femail-install%3Futm_source%3Dextension%26utm_medium%3Demail%26utm_campaign%3Dpromo_18>
>>>  Click 
>>> here. 
>>> <http://r1.wisestamp.com/r/landing?promo=18&dest=http%3A%2F%2Fwww.wisestamp.com%2Femail-install%3Futm_source%3Dextension%26utm_medium%3Demail%26utm_campaign%3Dpromo_18>
>>>    
>>>
>>>  
>>  -- 
>> Resources:
>> - http://web2py.com
>> - http://web2py.com/book (Documentation)
>> - http://github.com/web2py/web2py (Source code)
>> - https://code.google.com/p/web2py/issues/list (Report Issues)
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "web2py-users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected] <javascript:>.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to