pombreda / xhtml2pdf

Automatically exported from code.google.com/p/xhtml2pdf
GNU General Public License v2.0
0 stars 0 forks source link

CSS: Exception raised when using rgba() in a background #60

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I use the following declarations in a CSS file to set a semi-transparent 
background for certain div's using rgba() in a background property.

div.error {
        background: #FFCEBD;
        background: rgba(255, 206, 189, 0.85) !important; /* #FFCEBD */
        border: 1px solid #F04000;
}

When pisa encounters this the following Exception is raised.

Traceback:
File 
"/home/evan/python-envs/fbplatform/lib/python2.5/site-packages/django/core/handl
ers/base.py" in get_response
  92.                 response = callback(request, *callback_args, **callback_kwargs)
File 
"/home/evan/python-envs/fbplatform/lib/python2.5/site-packages/django/contrib/au
th/decorators.py" in __call__
  78.             return self.view_func(request, *args, **kwargs)
File "/home/evan/projects/fbplatform/fatboxsite/order/views.py" in pdf
  69.     return render_to_pdf('order/pdf.html', request, context, filename='order-%d.pdf' % order.id, inline=True)
File "/home/evan/projects/fbplatform/fatboxsite/utils/pdf.py" in render_to_pdf
  20.     pdf = pisa.pisaDocument(StringIO(html.encode("UTF-8")), dest=buffer, link_callback=fetch_resources)
File 
"/home/evan/python-envs/fbplatform/lib/python2.5/site-packages/sx/pisa3/pisa_doc
ument.py" in pisaDocument
  117.         c = pisaStory(src, path, link_callback, debug, default_css, xhtml, encoding, c=c, xml_output=xml_output)
File 
"/home/evan/python-envs/fbplatform/lib/python2.5/site-packages/sx/pisa3/pisa_doc
ument.py" in pisaStory
  62.     pisaParser(src, c, default_css, xhtml, encoding, xml_output)
File 
"/home/evan/python-envs/fbplatform/lib/python2.5/site-packages/sx/pisa3/pisa_par
ser.py" in pisaParser
  616.     c.parseCSS()        
File 
"/home/evan/python-envs/fbplatform/lib/python2.5/site-packages/sx/pisa3/pisa_con
text.py" in parseCSS
  535.         self.css = self.cssParser.parse(self.cssText)
File 
"/home/evan/python-envs/fbplatform/lib/python2.5/site-packages/sx/w3c/cssParser.
py" in parse
  358.                 src, stylesheet = self._parseStylesheet(src)
File 
"/home/evan/python-envs/fbplatform/lib/python2.5/site-packages/sx/w3c/cssParser.
py" in _parseStylesheet
  453.                 src, atResults = self._parseAtKeyword(src)
File 
"/home/evan/python-envs/fbplatform/lib/python2.5/site-packages/sx/w3c/cssParser.
py" in _parseAtKeyword
  573.             src, result = self._parseAtImports(src)
File 
"/home/evan/python-envs/fbplatform/lib/python2.5/site-packages/sx/w3c/cssParser.
py" in _parseAtImports
  523.             stylesheet = self.cssBuilder.atImport(import_, mediums, self)
File 
"/home/evan/python-envs/fbplatform/lib/python2.5/site-packages/sx/w3c/css.py" 
in atImport
  664.             return cssParser.parseExternal(import_)
File 
"/home/evan/python-envs/fbplatform/lib/python2.5/site-packages/sx/pisa3/pisa_con
text.py" in parseExternal
  399.         result = self.parse(cssFile.getData())
File 
"/home/evan/python-envs/fbplatform/lib/python2.5/site-packages/sx/w3c/cssParser.
py" in parse
  358.                 src, stylesheet = self._parseStylesheet(src)
File 
"/home/evan/python-envs/fbplatform/lib/python2.5/site-packages/sx/w3c/cssParser.
py" in _parseStylesheet
  458.                 src, ruleset = self._parseRuleset(src)
File 
"/home/evan/python-envs/fbplatform/lib/python2.5/site-packages/sx/w3c/cssParser.
py" in _parseRuleset
  738.         result = self.cssBuilder.ruleset(selectors, properties)
File 
"/home/evan/python-envs/fbplatform/lib/python2.5/site-packages/sx/w3c/css.py" 
in ruleset
  630.         declarations = self.specialRules(declarations)
File 
"/home/evan/python-envs/fbplatform/lib/python2.5/site-packages/sx/w3c/css.py" 
in specialRules
  621.         return cssSpecial.parseSpecialRules(declarations)
File 
"/home/evan/python-envs/fbplatform/lib/python2.5/site-packages/sx/w3c/cssSpecial
.py" in parseSpecialRules
  214.                     if ("." in part) or ("data:" in part):

Exception Type: TypeError at 
/clients/order/20e3a08a8263fc48ad84b88b3441bdec/pdf/
Exception Value: argument of type 'CSSTerminalFunction' is not iterable

Original issue reported on code.google.com by evan.bor...@gmail.com on 20 Apr 2010 at 2:21

GoogleCodeExporter commented 9 years ago
Some time ago Pisa AKA XHTML2PDF has been rereleased under the completely free 
Apache License. Since I personally don't have the time and resources to 
continue the project like before I would kindly ask you to fork the project on 
GitHub and add your patches etc. Maybe someone likes to create a new unified 
version and publish it on PyPI. If you need more help on this get in contact 
with me or write to the XHTML2PDF mailing list. Thank you all very much for 
your effort!

Project on GitHub:
http://github.com/holtwick/xhtml2pdf

Original comment by dirk.holtwick on 23 Aug 2010 at 5:27