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

Native print shortcut prints outer document, resulting in document being cut off after first page #110

Open
TheV360 opened this issue Sep 21, 2023 · 2 comments
Labels

Comments

@TheV360
Copy link

TheV360 commented Sep 21, 2023

When I did Ctrl+P to print a document after it got rendered by this extension, I noticed that it only showed one page in the preview, cutting off all content after the first page. After panicking about if it was my custom styles causing it, I figured out that the HTML layout of the extension's viewer page has changed since the last time I used it. There's now an iframe at the root of the document, and that is what contains the proper rendered markdown elements. Because it's an iframe, it doesn't participate in fancy CSS Print rules and such, and it gets cut off after it fills a page.

A workaround for now is to right-click the page, select "This Frame" and select "Print Frame" from the context menu.

A solution to this would be to maybe prevent default on the print shortcut and call .print on the iframe document.

@Cimbali Cimbali added the bug label Sep 24, 2023
@Cimbali
Copy link
Owner

Cimbali commented Sep 24, 2023

That’s an annoying unforeseen side-effect. There’s an upstream firefox bug that tracks correcting this, which was opened 8 years ago and has seen on activity so we’ll have to investigate workarounds as you suggest.

@Cimbali
Copy link
Owner

Cimbali commented Sep 24, 2023

Something like

window.addEventListener("beforeprint", (event) => {
  event.preventDefault();
  iframe.focus();
  iframe.print();
});

However it seems print events aren’t cancellable. 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants