10

On my website, printing has stopped work with Google Chrome (version 81 on Linux, if that matters). The print preview window is stuck with showing "Loading preview...".

While doing this, Chrome prints the following message on the console:

[30378:30378:0424/004907.441044:ERROR:CONSOLE(2990)] "Uncaught TypeError: Cannot read property 'marginTop' of null", source: chrome://print/print_preview.js (2990)

When I open the developer tools and set the CSS media type emulation to "print", the page is shown correctly as it would be printed, and there are no errors in the console.

How can I find out where the problem comes from and how to fix it?

Bob
  • 5,510
  • 9
  • 48
  • 80
  • 1
    Thanks for your question - the thread it created led me to my own answer, since the question has been closed. None of the below worked for me, as of 20Apr2021. Turning off Print Preview technically works, but I lose the speed of the Chrome preview window. So, uninstalling/reinstalling Chrome worked for me. Be sure to save your passwords and any settings first. – MTAdmin Apr 20 '21 at 18:43
  • Not sure if this helps anyone else, but a particular page was causing the Print Preview screen to believe there were 32,079 pages to print. There were 3 at best. Might be related to this issue. – Yoshiyahu May 05 '22 at 16:43
  • 1
    @Yoshiyahu The issue you're describing is caused by having an empty element with both `display: flex;` and `gap: `: https://bugs.chromium.org/p/chromium/issues/detail?id=1161709 – Sly_cardinal Oct 28 '22 at 13:50
  • @Sly_cardinal Yup, that was it. Found it through a painful process of elimination. – Yoshiyahu Nov 01 '22 at 15:58
  • Nothing worked for ., I had to uninstall the printer drivers, this worked for me – Jagadish Meghval Nov 03 '22 at 13:25

4 Answers4

5

Resetting Chrome did not solved the issue in my case, I had to disable the Print Preview by adding a key in Windows registry.

As written in Pupuweb.com

Previously this print preview loading problem was able to resolve by disabling it in chrome://flags/#enable-cloud-printer-handler. However, enable-cloud-printer-handler, however it was removed in Google Chrome Version 84.

So to disable the Print Preview feature I had to add at HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Google\Chrome a DWORD value named DisablePrintPreview with data 1, restart the machine and could start print again.

If you don't have the GPO Templates for Chrome you can create the keys manually or with the following line.

reg add HKLM\SOFTWARE\Policies\Google\Chrome

To add the value in command line, run as administrator the following line.

reg add HKLM\SOFTWARE\Policies\Google\Chrome /v DisablePrintPreview /t REG_DWORD /d 1 /f

Create a registry file ".reg" and add the following, run as administrator.

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Google\Chrome]
@=""
"DisablePrintPreview"=dword:00000001
André M. Faria
  • 2,052
  • 1
  • 13
  • 13
4

I had print preview taking almost exactly 2 minutes to load each time. Web Page and content type (PDF, google doc, html) did not matter. For my machine it was a messed up Preferences file in the Default folder. So if you have the same issue then try this: Open a file folder. Make sure in the VIEW tab window settings "Hidden Items" is checked to enable Goto directory C:\Users<USERNAME>\AppData\Local\Google\Chrome\User Data\Default Delete the file \Preferences

That's what worked for my machine. I did not have this issue on my other computers which are all synced in Chrome to the same google Account. Updates didn't help because they didn't change the default Preference file.

Good luck!

K in LA
  • 41
  • 2
  • Hi and welcome to Stack Overflow! Please take the [tour](https://stackoverflow.com/tour). Thanks for answering but can you also add an explanation on how your code solves the issue? Check the [help center](https://stackoverflow.com/editing-help) for info on how to format your answer. – Tyler2P Dec 04 '20 at 10:16
  • This also resolved the issue on linux. File `~/.config/google-chrome/Default/Preferences` Unknown why this worked. The file is a json. – Antonios Hadjigeorgalis May 23 '21 at 15:16
  • This works, but maybe just removing the "printing" key from the JSON also works and plus you don't lose all your preferences. – Mateus Viccari Nov 03 '21 at 12:57
2

The problem is with an extension for Hewlett-Packard printers which is looking for "classic printers." Delete it and see if your print problems go away. Worked for me.

Dan Yurman
  • 41
  • 1
1

I could finally solve the problem by resetting Chrome. However, I still don't know the root cause of the problem.

Bob
  • 5,510
  • 9
  • 48
  • 80