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

Is it possible to call window.print() from VSCode extension? #320

Closed
greybax opened this issue Jun 18, 2020 · 6 comments
Closed

Is it possible to call window.print() from VSCode extension? #320

greybax opened this issue Jun 18, 2020 · 6 comments

Comments

@greybax
Copy link

greybax commented Jun 18, 2020

I have standalone app which has "Print" html button. And I'm rendering this page also into my VSCode extension. But when I click on print button doesn't happend into VSCode.

Also I've tried to emulate print html mechanism into VSCode DevConsole, but getting error:
image

Is it possible somehow to print html page which is rendering into webview of my VSCode extension?

P.S. I've seen this issue: WebView optionally add "allow-modals" to iframe sandbox options #67109
but not sure is it possible somehow to create an adapter for print the webview page into VSCode extension

@mjbvz
Copy link
Contributor

mjbvz commented Jun 19, 2020

No, we don't support printing from webviews and do not have plans to add support.

You could try using a native module to control printing

@mjbvz mjbvz closed this as completed Jun 19, 2020
@greybax
Copy link
Author

greybax commented Jun 19, 2020

@mjbvz thanks for your answer. Could you please specify what is "native module"? Do you mean this node module https://github.com/tojocky/node-printer or something else?

@mjbvz
Copy link
Contributor

mjbvz commented Jun 19, 2020

yes

@ggrossetie
Copy link

No, we don't support printing from webviews and do not have plans to add support.
You could try using a native module to control printing

I think it would be extremely useful to print a webview to PDF.
As far as I know it's not possible to do that using a native module because it's a browser feature, right?

With project like Paged.js (based on W3C specifications) it's possible to produce high-quality PDF documents using web technologies (and especially the print to PDF feature provided by browsers).

A typical use case, would be to generate a printable web page from a lightweight markup language such as AsciiDoc or Markdown and use the print to PDF feature to produce a PDF.

I guess it's still possible to run an headless browser outside of VS Code (using Puppeteer) to generate a PDF but it seems extremely heavy as a workaround.

@mjbvz Could you please give us some insights about this restriction?

Thanks!

@mjbvz
Copy link
Contributor

mjbvz commented Oct 31, 2020

Nothing to add besides printing is not a use case we feel is important enough to support or maintain. Your extension can use whatever tools it needs to print, but it's not something we are going to put into core

@ggrossetie
Copy link

I think it's unfortunate but I guess it's what it's.
Let me know if you change your mind 😉

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

No branches or pull requests

3 participants