Skip to content

Linux: webContents.print() returns "Invalid printer settings" in Electron 43, works in Electron 42 #52266

Closed

Description

@8lurry

Preflight Checklist

Electron Version

43.0.0

What operating system(s) are you using?

Ubuntu

Operating System Version

Ubuntu 24.06 (x11)

What arch are you using?

x64

Last Known Working Electron version

42.6.0

Does the issue also appear in Chromium / Google Chrome?

No

Expected Behavior

win.webContents.print with a non empty options object (for example, {silent: true, deviceName: "MyPrinter"}) is supposed to print the content seamlessly.

Actual Behavior

win.webContents.print with an empty options ({}) object, opens the print dialog alright but when I put options like silent or deviceName the function returns with an error saying Invalid printer settings.

Testcase Gist URL

No response

Additional Information

No response

Activity

  1. added theissue type on Jul 6, 2026
  2. moved this to 👀 Unsorted Items in 44-x-yon Jul 6, 2026
  3. moved this to 👀 Unsorted Items in 43-x-yon Jul 6, 2026
  4. nikwen commented on Jul 6, 2026

    @nikwen
    Member

    Thanks for reporting!

    Would you be able to download Electron Fiddle, use it to create a small sample app that allows maintainers to reproduce this issue, and upload it as a GitHub gist from Fiddle?

  5. added
    blocked/need-repro
    on Jul 6, 2026
  6. electron-issue-triage commented on Jul 6, 2026

    @electron-issue-triage

    Hello @8lurry. Thanks for reporting this and helping to make Electron better!

    Would it be possible for you to make a standalone testcase with only the code necessary to reproduce the issue? For example, Electron Fiddle is a great tool for making small test cases and makes it easy to publish your test case to a gist that Electron maintainers can use.

    Stand-alone test cases make fixing issues go more smoothly: it ensure everyone's looking at the same issue, it removes all unnecessary variables from the equation, and it can also provide the basis for automated regression tests.

    Now adding the blocked/need-repro Needs a test case to reproduce the bug label for this reason. After you make a test case, please link to it in a followup comment. This issue will be closed in 10 days if the above is not addressed.

  7. removed this from 44-x-yon Jul 8, 2026
  8. davidjgraph commented on Jul 15, 2026

    @davidjgraph

    Root cause and repro from draw.io desktop, where all printing broke after moving to 43 (jgraph/drawio-desktop#2476, jgraph/drawio-desktop#2484).

    webContents.print(opts) fails with "Invalid printer settings" for any non-empty opts. print({}) works. Not Linux specific, we see it on Windows, macOS and Linux. Broken in 43.0.0 through 43.1.1 and on main as of 44.0.0-alpha.3. 42.x is fine.

    Cause: Chromium moved UpdatePrintSettings() out of PrintViewManagerBase into the preview-only PrintViewManager. PrintViewManagerElectron now overrides it and rejects every request:

    https://github.com/electron/electron/blob/v43.1.1/shell/browser/printing/print_view_manager_electron.cc#L119-L123

    void PrintViewManagerElectron::UpdatePrintSettings(
        base::DictValue job_settings,
        UpdatePrintSettingsCallback callback) {
      std::move(callback).Run(nullptr);
    }

    In 42.x there is no override, so the working base class implementation handled it. Any print call that carries settings now fails before the system dialog opens.

    Minimal repro:

    const { app, BrowserWindow } = require('electron')
    
    app.whenReady().then(() => {
      const win = new BrowserWindow()
      win.loadURL('data:text/html,<h1>print test</h1>')
      win.webContents.once('did-finish-load', () => {
        win.webContents.print({ printBackground: true }, (ok, err) => {
          console.log(ok, err) // false 'Invalid printer settings' on 43, dialog opens on 42
        })
      })
    })

    Our workaround is to retry with print({}) when that error comes back, but then pageSize, scaleFactor and margins are all ignored. We have reverted to 42.7.0 for now. Happy to test a fix.

  9. removed
    blocked/need-repro
    on Jul 15, 2026
  10. moved this from 👀 Unsorted Items to 🛑 Blocks Stable in 43-x-yon Jul 15, 2026
  11. self-assigned this
    on Jul 15, 2026
  12. added
    has-repro-comment
    on Jul 16, 2026
  13. moved this from 🛑 Blocks Stable to 🛠️ Fixed for Next Release in 43-x-yon Jul 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions