raise self.ParseError('Declaration group closing \'}\' not found', src, ctxsrc)

95 views
Skip to first unread message

Canncri

unread,
Jul 6, 2011, 11:27:32 AM7/6/11
to Pisa XHTML2PDF Support
hello All,
I recently needed to convert web pages to a pdf file , I am using
pisa-3.0.33, convert the URL is:http://www.ccohs.ca/products/
canlabel/,
but the exception has been reported,please help me.thanks a lot.

File "C:\Python27\lib\site-packages\pisa-3.0.33-py2.7.egg\sx
\pisa3\pisa_document.py", line 128, in pisaDocument
c = pisaStory(src, path, link_callback, debug, default_css, xhtml,
encoding, c=c, xml_output=xml_output)
File "C:\Python27\lib\site-packages\pisa-3.0.33-py2.7.egg\sx
\pisa3\pisa_document.py", line 73, in pisaStory
pisaParser(src, c, default_css, xhtml, encoding, xml_output)
File "C:\Python27\lib\site-packages\pisa-3.0.33-py2.7.egg\sx
\pisa3\pisa_parser.py", line 626, in pisaParser
c.parseCSS()
File "C:\Python27\lib\site-packages\pisa-3.0.33-py2.7.egg\sx
\pisa3\pisa_context.py", line 545, in parseCSS
self.css = self.cssParser.parse(self.cssText)
File "C:\Python27\lib\site-packages\pisa-3.0.33-py2.7.egg\sx\w3c
\cssParser.py", line 358, in parse
src, stylesheet = self._parseStylesheet(src)
File "C:\Python27\lib\site-packages\pisa-3.0.33-py2.7.egg\sx\w3c
\cssParser.py", line 453, in _parseStylesheet
src, atResults = self._parseAtKeyword(src)
File "C:\Python27\lib\site-packages\pisa-3.0.33-py2.7.egg\sx\w3c
\cssParser.py", line 573, in _parseAtKeyword
src, result = self._parseAtImports(src)
File "C:\Python27\lib\site-packages\pisa-3.0.33-py2.7.egg\sx\w3c
\cssParser.py", line 523, in _parseAtImports
stylesheet = self.cssBuilder.atImport(import_, mediums, self)
File "C:\Python27\lib\site-packages\pisa-3.0.33-py2.7.egg\sx\w3c
\css.py", line 664, in atImport
return cssParser.parseExternal(import_)
File "C:\Python27\lib\site-packages\pisa-3.0.33-py2.7.egg\sx
\pisa3\pisa_context.py", line 409, in parseExternal
result = self.parse(cssFile.getData())
File "C:\Python27\lib\site-packages\pisa-3.0.33-py2.7.egg\sx\w3c
\cssParser.py", line 358, in parse
src, stylesheet = self._parseStylesheet(src)
File "C:\Python27\lib\site-packages\pisa-3.0.33-py2.7.egg\sx\w3c
\cssParser.py", line 458, in _parseStylesheet
src, ruleset = self._parseRuleset(src)
File "C:\Python27\lib\site-packages\pisa-3.0.33-py2.7.egg\sx\w3c
\cssParser.py", line 737, in _parseRuleset
src, properties = self._parseDeclarationGroup(src.lstrip())
File "C:\Python27\lib\site-packages\pisa-3.0.33-py2.7.egg\sx\w3c
\cssParser.py", line 922, in _parseDeclarationGroup
raise self.ParseError('Declaration group closing \'}\' not found',
src, ctxsrc)
sx.w3c.cssParser.CSSParseError: Declaration group closing '}' not
found:: (u'{\nbackground-color:#669900;\npadding:5px 5px;', u';
\nmargin-top: 15px;\n')


Hangzhao Deng

unread,
Jul 21, 2011, 12:26:20 PM7/21/11
to xhtm...@googlegroups.com
I ran into the same problem and I just started to learn python a week ago. Could anyone help me with it? How do you guys convert a URL to a pdf file? I am on Windows 7, and installed pisa-3.0.33 as well. I think I had Reportlab Toolkit and html5lib 0.11.1 installed. When I convert http://www.google.com/ I got a pdf file with some words of the page but without any image. And when I tried some other more complex pages I got a bunch of errors as wanghenxingw got. Can anyone post some codes that can convert URL to pdf successfully?  Or how do I check if I have all the required programs installed? Thanks a lot!



--
You received this message because you are subscribed to the Google Groups "Pisa XHTML2PDF Support" group.
To post to this group, send email to xhtm...@googlegroups.com.
To unsubscribe from this group, send email to xhtml2pdf+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/xhtml2pdf?hl=en.


Tribaal

unread,
Jul 21, 2011, 12:57:20 PM7/21/11
to xhtm...@googlegroups.com
Hi all,

I feel like I should point out a couple of things:

1. While converting a webpage (one from the internet) seems to be a
common use case, it is absolutely not the intended usage of this
library. There are other libraries doing a much better job for this
(wkhtmltopdf comes to mind [1]). The intent of xhtml2pdf is to let
webdesigners create pdfs with tools and technologies they are used to
(like generate pdf reports, invoices etc...).

2. pisa 3.* is completely unsupported and abandonned, and the only
work being done is on xhtml2pdf [2]. There have been *major* changes
(like a complete refactoring, and inclusion of much code from
contributors), so while I feel your frustration, I would suggest you
try with this version instead (lots of "silent catches" have been
removed, so it should produce better/more useful error output).

3. There is no paid support or any commercial organisation behind
xhtml2pdf. If you need a bug fixed or a feature done, the best way is
still to look at the code yourself, and send a pull request in (I will
merge anything that looks reasonable - I don't have a roadmap).

Hope you all understand my point, and don't see this as a barrier to
using this lib - I think it's great at what it does :)

Cheers, and thanks

- Chris (the current maintainer)

[1]: http://code.google.com/p/wkhtmltopdf/
[2]: https://github.com/chrisglass/xhtml2pdf/

Hangzhao Deng

unread,
Jul 24, 2011, 10:33:38 AM7/24/11
to xhtm...@googlegroups.com

Thank you so much for your help! 
Reply all
Reply to author
Forward
0 new messages