fonol / anki-search-inside-add-card

An add-on providing full-text-search and PDF reading functionality to Anki's Add card dialog
https://ankiweb.net/shared/info/1781298089
GNU Affero General Public License v3.0
178 stars 24 forks source link

"NameError: name 'QPrinter' is not defined" After converting webpage to PDF #355

Open MNastri opened 1 year ago

MNastri commented 1 year ago

Describe the bug Got this error after trying to convert a webpage to PDF.

To Reproduce Steps to reproduce the behavior:

  1. Go to 'SIAC' > 'Import' > 'Create New'
  2. Set the 'Source' field
  3. Click 'Source...' > 'Webpage to PDF (URL)'
  4. Set the 'Url' and 'PDF Name (Optional)'
  5. Click 'Import'

Expected behavior The given webpage to be converted to a PDF file

Debug Log

Error An error occurred. Please start Anki while holding down the shift key, which will temporarily disable the add-ons you have installed. If the issue only occurs when add-ons are enabled, please use the Tools > Add-ons menu item to disable some add-ons and restart Anki, repeating until you discover the add-on that is causing the problem. When you've discovered the add-on that is causing the problem, please report the issue to the add-on author. Debug info: Anki 2.1.56 (07fd88dd) Python 3.9.15 Qt 5.15.2 PyQt 5.15.5 Platform: Windows-10-10.0.22621 Flags: frz=True ao=True sv=2 Add-ons, last update check: 2023-01-13 16:20:50

Caught exception: Traceback (most recent call last): File "C:\Users\marce\AppData\Roaming\Anki2\addons21\1781298089\src\utility\misc.py", line 341, in save_pdf printer = QPrinter() NameError: name 'QPrinter' is not defined

Environment:

Anki about info

Anki 2.1.56 (07fd88dd) Python 3.9.15 Qt 5.15.2 PyQt 5.15.5
Platform: Windows-10-10.0.22621
Flags: frz=True ao=True sv=2
Add-ons, last update check: 2023-01-13 16:20:50

===Add-ons (active)===
(add-on provided name [Add-on folder, installed at, version, is config changed])
'' ['slackers_delight', 0, 'None', '']
Auto Ease Factor ['1672712021', 2021-03-21T15:11, 'None', '']
Autosync 21 ['1726633659', 2019-03-08T20:58, 'None', '']
Deck name in title 21 ['699175524', 2019-05-31T22:05, 'None', '']
Highlight Search Results in the Browser ['225180905', 2021-03-10T14:06, 'None', '']
Mini Format Pack ['295889520', 2018-07-24T14:45, 'None', '']
Minimize to tray ['85158043', 2022-04-30T14:57, 'None', '']
Review Heatmap ['1771074083', 2022-06-29T22:43, 'None', '']
Searching PDF Reading  Note-Taking in Add Dialog ['1781298089', 2022-08-15T04:22, 'None', mod]
Syntax Highlighting for Code ['1463041493', 2018-10-06T22:31, 'None', '']
avgEase for Anki  2141 ['1129477042', 2021-06-27T08:58, 'None', '']
load balancer ['1417170896', 2020-08-05T20:58, 'None', '']

===IDs of active AnkiWeb add-ons===
1129477042 1417170896 1463041493 1672712021 1726633659 1771074083 1781298089 225180905 295889520 699175524 85158043

===Add-ons (inactive)===
(add-on provided name [Add-on folder, installed at, version, is config changed])
Incremental Reading v4103 ['935264945', 2019-04-21T09:54, 'None', '']
MorphMan for Anki 21 ['900801631', 2023-01-10T17:01, 'None', '']
Spiralo-Idioide commented 1 year ago

Exact same bug here, for both 2.1.58 and 2.1.60

Wiselunatic commented 1 year ago

image

I also have the same bug. You can open the misc.py document you can see in the image I uploaded and add the line highlighted in gray. You'll have to use the qt5 version of anki.

I hope this gets fixed soon, should be easy for the developer but he'll have to import the appropriate qt6 libs and change up some of the code under the definition of save_pdf(finished) // line 340 to reflect the changes made to qt from versions 5 to 6.

0x0501 commented 1 year ago

Please move on #363 , I think it'll solve this.