Today I try thanks very much
On Monday, July 20, 2015 at 8:14:40 AM UTC+2, Ariya Owam-aram wrote:
>
>
> Hi Alessio
>
> If you call from Apache then you can call subprocess directly from
> webserver but in nginx you have to use schedule task. Better to run
> wkhtmltopdf via schedule task in case of generate pdf or process a report.
>
> THIS IS MY CODE:
>
> def schedule_task__pdf_render():
> # import
> import os, re
> from subprocess import call
>
> body_html_path = os.path.join(request.folder, "static",
> "template/paper__body.html")
> header_html_path = os.path.join(request.folder, "static",
> "template/paper__header.html")
> footer_html_path = os.path.join(request.folder, "static",
> "template/paper__footer.html")
> result_pdf_path = os.path.join(request.folder, "static",
> "template/%s.pdf" %print_job__id)
>
>
> # body
> html = response.render('controller_name/my_html_page.html')
> file(body_html_path, "wb").write(html)
>
> # header
> html =
> response.render('controller_print_template/my_page_header.html')
> file(header_html_path, "wb").write(html)
>
> # footer
> html = response.render('controller_print_template/my_page_footer.html')
> file(footer_html_path, "wb").write(html)
>
> call('wkhtmltopdf --javascript-delay 10000 --margin-top 30mm
> --margin-left 20 --margin-right 20 --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)
>
> return
>
>
> NOTE :
> 1. Use --javascript-delay 10000 in case of waiting for javascript complete
> their work, ie. waiting mathjax to complete math formula conversion to html
> page.
> 2. This case I render html from file, not render direct from online html
> page because my html page is not a static page.
> 3. Sample of my_html_page.html
>
> {{
> paper__id = request.vars.paper__id
> paper__row = db.paper[paper__id]
> }}
>
> <div>
> <div class='title-in-english'>
> {{=XML(paper__row.title_in_english)}}
> </div>
> <div class='authours-in-english'>
> {{=XML(paper__row.authours_in_english)}}
> </div>
> <div class='content-body'>
> {{=XML(i.paper_content_body)}}
> </div>
> </div>
>
> Hope it help.
>
> :)
>
>
> เมื่อ วันอาทิตย์ที่ 19 กรกฎาคม ค.ศ. 2015 22 นาฬิกา 10 นาที 19 วินาที
> UTC+7, Alessio Varalta เขียนว่า:
>>
>> Hi I am going to use wkhtmltopdf in a web2py application for generate pdf
>> file. I see only another topic about wkhtmltopdf in this forum and I
>> understand that i have to use calls service but I the line of command is
>> for me incorrect.There is a example online with the call for use
>> wkhtmltopdf with this framework? If I can use call service you can give me
>> how can i write the line of calls or in another case you can give a me a
>> example for use wkhtmltopdf?
>>
>
--
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.