glutanimate / pdf-glossary

PDF Glossary Export Add-on for Anki
GNU Affero General Public License v3.0
28 stars 2 forks source link

UnicodeEncodeError in xhtml2pdf URI decode #1

Open Questionman opened 6 years ago

Questionman commented 6 years ago

I tried to make PDF glossary but it printed out this message : (p.s. making HTML glossary did work and the error below seemed to related with Encoding(unicode, UTF-8...)

Traceback (most recent call last): File "aqt\exporting.py", line 116, in accept File "C:\Users\diti9\AppData\Roaming\Anki2\addons\pdf_glossary\exporter.py", line 274, in exportInto GlossaryExporter.exportInto(self, path) File "anki\exporting.py", line 19, in exportInto File "C:\Users\diti9\AppData\Roaming\Anki2\addons\pdf_glossary\exporter.py", line 190, in doExport self.writeExportFile(html, file) File "C:\Users\diti9\AppData\Roaming\Anki2\addons\pdf_glossary\exporter.py", line 268, in writeExportFile path=self.media_path # required on Windows File "C:\Users\diti9\AppData\Roaming\Anki2\addons\pdf_glossary\libs\xhtml2pdf\document.py", line 97, in pisaDocument encoding, context=context, xml_output=xml_output) File "C:\Users\diti9\AppData\Roaming\Anki2\addons\pdf_glossary\libs\xhtml2pdf\document.py", line 59, in pisaStory pisaParser(src, context, default_css, xhtml, encoding, xml_output) File "C:\Users\diti9\AppData\Roaming\Anki2\addons\pdf_glossary\libs\xhtml2pdf\parser.py", line 708, in pisaParser pisaLoop(document, context) File "C:\Users\diti9\AppData\Roaming\Anki2\addons\pdf_glossary\libs\xhtml2pdf\parser.py", line 648, in pisaLoop pisaLoop(node, context, path, kw) File "C:\Users\diti9\AppData\Roaming\Anki2\addons\pdf_glossary\libs\xhtml2pdf\parser.py", line 593, in pisaLoop pisaLoop(nnode, context, path, kw) File "C:\Users\diti9\AppData\Roaming\Anki2\addons\pdf_glossary\libs\xhtml2pdf\parser.py", line 593, in pisaLoop pisaLoop(nnode, context, path, kw) File "C:\Users\diti9\AppData\Roaming\Anki2\addons\pdf_glossary\libs\xhtml2pdf\parser.py", line 593, in pisaLoop pisaLoop(nnode, context, path, kw) File "C:\Users\diti9\AppData\Roaming\Anki2\addons\pdf_glossary\libs\xhtml2pdf\parser.py", line 593, in pisaLoop pisaLoop(nnode, context, path, kw) File "C:\Users\diti9\AppData\Roaming\Anki2\addons\pdf_glossary\libs\xhtml2pdf\parser.py", line 593, in pisaLoop pisaLoop(nnode, context, path, kw) File "C:\Users\diti9\AppData\Roaming\Anki2\addons\pdf_glossary\libs\xhtml2pdf\parser.py", line 593, in pisaLoop pisaLoop(nnode, context, path, kw) File "C:\Users\diti9\AppData\Roaming\Anki2\addons\pdf_glossary\libs\xhtml2pdf\parser.py", line 593, in pisaLoop pisaLoop(nnode, context, path, kw) File "C:\Users\diti9\AppData\Roaming\Anki2\addons\pdf_glossary\libs\xhtml2pdf\parser.py", line 477, in pisaLoop attr = pisaGetAttributes(context, node.tagName, node.attributes) File "C:\Users\diti9\AppData\Roaming\Anki2\addons\pdf_glossary\libs\xhtml2pdf\parser.py", line 117, in pisaGetAttributes nv = c.getFile(nv) File "C:\Users\diti9\AppData\Roaming\Anki2\addons\pdf_glossary\libs\xhtml2pdf\context.py", line 848, in getFile return getFile(name, relative or self.pathDirectory) File "C:\Users\diti9\AppData\Roaming\Anki2\addons\pdf_glossary\libs\xhtml2pdf\util.py", line 673, in getFile file = pisaFileObject(*a, **kw) File "C:\Users\diti9\AppData\Roaming\Anki2\addons\pdf_glossary\libs\xhtml2pdf\util.py", line 533, in init uri = uri.decode("utf-8") File "encodings\utf_8.py", line 16, in decode UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-1: ordinal not in range(128)

glutanimate commented 6 years ago

Sorry for the belated response. Thanks for the report!

Errors in the PDF exporter are very difficult to debug, unfortunately, as they're usually not caused by the add-on, but by the third-party library we use for generating the PDF (xhtml2pdf).

Are you still facing this bug? I'm not sure what caused the error in this case, but if you do it would help if you could attach an apkg export of the affected deck here.

Glad to hear that the HTML export is working fine. It's much more robust, so it's always a great choice to fall back on when issues like these appear in the PDF export module.