Hi Akash,
Your example controller code seems good and shouldwork. The issue is that
PISA is a bit sensitive and only supports a reduced subset of CSS. The
error suggests PISA does not know how to handle "Alpha(Opacity=0)". You
will need to somehow strip out the unsupported CSS from the html before it
is rendered by REPORTPISA. Note that images are also problematic (you will
need PIL installed if you want anything other than JPG and even then they
are rendered in separate paragraphs), so you might need to play with this
too.
Cheers
Russell
On Saturday, July 7, 2012 5:40:29 PM UTC+12, Akash Kakkar wrote:
>
> *
> *
>
> I am from a non coding background so python, web2py is very new to me. I
> am trying to send html content using json and then use that in controller
> to generate pdf. If I am able to send json data and then use it in
> controller function, i should be able to get the pdf. More details below. I
> am missing out on correct json syntax , encoding and decoding.
>
> My app needs to export textarea content (using RTE redactor) to pdf. I get
> html content from textarea (redactor), can you please advice me on how to
> use pyfpdf to generate a pdf file on button click.
>
> I don't know how to get the html content (images and text) on button click
> in view to generate pdf using appreport.
>
> I was able to use app-report to generate a pdf (using PISA, PYPDF does not
> work) from an existing html file (without css) if html file has css it
> throws an error,
>
> ***<class 'sx.w3c.cssParser.CSSParseError'> Terminal function expression
> expected closing ')':: (u'Alpha(Opacity', u'=0); }\n\n\n\n.ui-state-')***
>
> This might be due to a mistake in the controller code:
>
> def myreport():
> html = response.render('myreport.html', dict())
> return plugin_appreport.REPORTPISA(html = html)
>
> ------------------------------
>
> Another thing I tried was passing the html from my view to the controller
> using ajax post (in Javascript). Redactor is the textarea RTE I am using
> and alert gives me the desired html result.
>
> View:
>
> function getContent() {
> var t= jQuery('#redactor_content').getCode();
> alert(t);
> jQuery.ajax({
> type: "POST",
> url: "http://127.0.0.1:8000/Test50/default/myreport2",
> data: "{g : 'jQuery('#redactor_content').getCode()'}"
>
> });
> }
>
> Controller:
>
> def myreport2():
> g = request.get_vars
> html = response.render(g)
> return plugin_appreport.REPORTPISA(html = html)
>
> Due to my less knowledge in coding , I am not able to figure out and
> correct my mistake. I will be thankful if anybody can help me with this
> problem.
>
> Regards, Akash
>