Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: silent print settings #31615

Merged
merged 1 commit into from Oct 28, 2021
Merged

fix: silent print settings #31615

merged 1 commit into from Oct 28, 2021

Conversation

codebytere
Copy link
Member

@codebytere codebytere commented Oct 28, 2021

Backport of #31489.

See that PR for details.

Notes: Fixed an issue which caused print settings to not work properly when printing silently.

@codebytere codebytere requested a review from Oct 28, 2021
@codebytere codebytere requested a review from as a code owner Oct 28, 2021
@electron-cation electron-cation bot added the new-pr 🌱 label Oct 28, 2021
@trop trop bot mentioned this pull request Oct 28, 2021
3 tasks
@trop trop bot added 16-x-y backport semver/patch labels Oct 28, 2021
@electron-cation electron-cation bot removed the new-pr 🌱 label Oct 28, 2021
@jkleinsc jkleinsc merged commit 1adea9e into 16-x-y Oct 28, 2021
14 of 15 checks passed
@jkleinsc jkleinsc deleted the silent-print-16 branch Oct 28, 2021
@release-clerk
Copy link

@release-clerk release-clerk bot commented Oct 28, 2021

Release Notes Persisted

Fixed an issue which caused print settings to not work properly when printing silently.

@Hedwig188
Copy link

@Hedwig188 Hedwig188 commented Nov 2, 2021

I tested the fix in v16.0.0-beta.6. It looks like the header is not being respected, but the rest of the settings are.
It always print the header with the window's title.

Is there any way to workaround this?

Test code:

(async () => {
  const {app, BrowserWindow} = require("electron");

  await app.whenReady()

  const window = new BrowserWindow();
  await window.loadURL("https://www.electronjs.org/");
  window.webContents.print(
    {
      header: "I am header",
      footer: "I am footer",
      deviceName: "Microsoft Print to PDF",
      landscape: true,
      silent: true,
    });
})();

@Hedwig188
Copy link

@Hedwig188 Hedwig188 commented Nov 3, 2021

Looks like setting the document.title using the js before printing would be the workaround.
await window.webContents.executeJavaScript("document.title = 'I am header'");

@sunchanglong
Copy link

@sunchanglong sunchanglong commented Nov 6, 2021

pageSize not work in all electron version. I have test electron version from 8.x to 16.0.0-beta.6
#31705

@sunchanglong
Copy link

@sunchanglong sunchanglong commented Nov 8, 2021

@codebytere , could you please confirm if #31705 is a bug first?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
16-x-y backport semver/patch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants