glutanimate / pdf-glossary

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

NoneType error in xhtml2pdf #5

Open jkim922 opened 6 years ago

jkim922 commented 6 years ago

An error occurred in an add-on. Please post on the add-on forum: https://anki.tenderapp.com/discussions/add-ons

Traceback (most recent call last): File "aqt\exporting.py", line 116, in accept File "C:\Users\Dae\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\Dae\AppData\Roaming\Anki2\addons\pdf_glossary\exporter.py", line 190, in doExport self.writeExportFile(html, file) File "C:\Users\Dae\AppData\Roaming\Anki2\addons\pdf_glossary\exporter.py", line 268, in writeExportFile path=self.media_path # required on Windows File "C:\Users\Dae\AppData\Roaming\Anki2\addons\pdf_glossary\libs\xhtml2pdf\document.py", line 97, in pisaDocument encoding, context=context, xml_output=xml_output) File "C:\Users\Dae\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\Dae\AppData\Roaming\Anki2\addons\pdf_glossary\libs\xhtml2pdf\parser.py", line 708, in pisaParser pisaLoop(document, context) File "C:\Users\Dae\AppData\Roaming\Anki2\addons\pdf_glossary\libs\xhtml2pdf\parser.py", line 648, in pisaLoop pisaLoop(node, context, path, kw) File "C:\Users\Dae\AppData\Roaming\Anki2\addons\pdf_glossary\libs\xhtml2pdf\parser.py", line 593, in pisaLoop pisaLoop(nnode, context, path, kw) File "C:\Users\Dae\AppData\Roaming\Anki2\addons\pdf_glossary\libs\xhtml2pdf\parser.py", line 593, in pisaLoop pisaLoop(nnode, context, path, kw) File "C:\Users\Dae\AppData\Roaming\Anki2\addons\pdf_glossary\libs\xhtml2pdf\parser.py", line 593, in pisaLoop pisaLoop(nnode, context, path, kw) File "C:\Users\Dae\AppData\Roaming\Anki2\addons\pdf_glossary\libs\xhtml2pdf\parser.py", line 593, in pisaLoop pisaLoop(nnode, context, path, kw) File "C:\Users\Dae\AppData\Roaming\Anki2\addons\pdf_glossary\libs\xhtml2pdf\parser.py", line 593, in pisaLoop pisaLoop(nnode, context, path, kw) File "C:\Users\Dae\AppData\Roaming\Anki2\addons\pdf_glossary\libs\xhtml2pdf\parser.py", line 593, in pisaLoop pisaLoop(nnode, context, path, kw) File "C:\Users\Dae\AppData\Roaming\Anki2\addons\pdf_glossary\libs\xhtml2pdf\parser.py", line 593, in pisaLoop pisaLoop(nnode, context, path, kw) File "C:\Users\Dae\AppData\Roaming\Anki2\addons\pdf_glossary\libs\xhtml2pdf\parser.py", line 593, in pisaLoop pisaLoop(nnode, context, path, kw) File "C:\Users\Dae\AppData\Roaming\Anki2\addons\pdf_glossary\libs\xhtml2pdf\parser.py", line 593, in pisaLoop pisaLoop(nnode, context, path, kw) File "C:\Users\Dae\AppData\Roaming\Anki2\addons\pdf_glossary\libs\xhtml2pdf\parser.py", line 477, in pisaLoop attr = pisaGetAttributes(context, node.tagName, node.attributes) File "C:\Users\Dae\AppData\Roaming\Anki2\addons\pdf_glossary\libs\xhtml2pdf\parser.py", line 117, in pisaGetAttributes nv = c.getFile(nv) File "C:\Users\Dae\AppData\Roaming\Anki2\addons\pdf_glossary\libs\xhtml2pdf\context.py", line 848, in getFile return getFile(name, relative or self.pathDirectory) File "C:\Users\Dae\AppData\Roaming\Anki2\addons\pdf_glossary\libs\xhtml2pdf\util.py", line 673, in getFile file = pisaFileObject(*a, **kw) File "C:\Users\Dae\AppData\Roaming\Anki2\addons\pdf_glossary\libs\xhtml2pdf\util.py", line 621, in init if self.mimetype.startswith('text'): AttributeError: 'NoneType' object has no attribute 'startswith'

glutanimate commented 6 years ago

Thanks for the report. Errors in the PDF exporter are very difficult to debug, I'm afraid, as they're not caused by the add-on, but by a third-party library.

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

As for a quick workaround: Exporting to HTML first, and then printing the document to PDF through Chrome's PDF export option should work without a hitch.