vscode.printcode icon indicating copy to clipboard operation
vscode.printcode copied to clipboard

Trouble printing on a Mac

Open atc100 opened this issue 7 years ago • 28 comments

I am running Mac OS 10.11.6, Visual Studio Code 1.20.1. When I run PrintCode, an empty broswer window appears.

atc100 avatar Feb 21 '18 22:02 atc100

What are web browsers using?

Other than Chrome it may not work.

try specifying Chrome with printcode.browserPath on the setting page.

nobuhito avatar Feb 22 '18 01:02 nobuhito

I'm on a mac and have the same problem. It opens in chrome but there is nothing to print.

DaddyOh avatar Mar 09 '18 20:03 DaddyOh

When it is not displayed even in Chrome, There is a possibility that another program is disturbing. In that case, it may be displayed by changing the webServerPort from 3000 to another port (eg 3001) by setting. Also, is DevTools displaying an error? Or, is HTML properly created? Please also check about.

Thank you and best regards,

2018-03-11 11 10 28

nobuhito avatar Mar 11 '18 02:03 nobuhito

On next release, the default port should probably be changed to a not so commonly used one. 3000 is default port for many development servers and quite many code examples from the net use it, so the chance of overlapping is quite high.

janilahti avatar Mar 12 '18 07:03 janilahti

Thanks for the advice. I'd like to release the modified version as soon as possible.

nobuhito avatar Mar 12 '18 07:03 nobuhito

I don't have a Mac but I trust PR #7 will fix this issue.. ..and will help people with other platforms, too. Would you verify this, @atc100 or @DaddyOh .

janilahti avatar Mar 12 '18 19:03 janilahti

I am getting a similar issue: the web browser page is blank. I did see it work once so not sure how this happens. The js console shows the errors:

screenshot

In case the image doesn't come through, it's complaining that it can't find codemirror.js.

PS: I tried with both Safari and Chrome - both opened a window successfully, but had same issue with codemirror.js

Hope this helps - would love to have this capability.

rodbutters avatar May 03 '18 22:05 rodbutters

@rodbutters I have similar issues, where the page just was blank and the console is complaining about codemirror.js. In the dev tools network tab there is a net::ERR_CONTENT_LENGTH_MISMATCH for codemirror.js.

But not all the time. When I reload the page it sometimes displays. Looks like a runtime error, which in my case happens more often than not.

So my temporary solution is to relaod [CMD+R] until the page shows.

webwb avatar May 04 '18 13:05 webwb

@webwb Tried your refresh work-around, but never managed to see code. I believe you that it works because I did see the code one time, but never since.

I would love to take a look and see if I can fix, but up against some tight deadlines right now.

Will watch this space and hope someone else can get to the bottom of this.

rodbutters avatar May 04 '18 19:05 rodbutters

@rodbutters You can try this: Press ⌥⌘+I, opening developing tools, then switch to Elements tab, Element tab, expand the <script> dom element, and then click on the code, then press ⌘+R (refresh the page).

Now the print dialog will immediately pop up. Print dialog

It works on both of my two MacBooks, macOS High Sierra, 10.13.4

yzhang37 avatar May 29 '18 01:05 yzhang37

It seems that 100 ms is somewhat shorter depending on the environment. Would you solve it if it is a little longer? About 500 ms? I do not want to be too long.

https://github.com/nobuhito/vscode.printcode/blob/master/src/extension.js#L54-L56

nobuhito avatar May 29 '18 02:05 nobuhito

Or is this better?

server.listen(port, () => {
  portNumberInUse = port;
  printIt();
});

nobuhito avatar May 29 '18 02:05 nobuhito

I experimented with different values with different systems when developing, and 100 ms seemed to give enough margin, but other systems seem to require more. Even 500 ms shouldn't be too noticeable for users, either. If you decide to keep the delay, we can of course create one more config variable for it.

janilahti avatar May 29 '18 05:05 janilahti

If it improves by changing to 500 ms or 1 sec, I will change the default value. However, I do not want to extend it until 2 sec.

Also, I want to minimize the setting items as much as possible.

nobuhito avatar May 29 '18 06:05 nobuhito

Has there been any progress? I'd love to use this extension on OS X.

DanielSWolf avatar Jul 18 '18 13:07 DanielSWolf

I am having the same problem. Has there been any progress? It's a very important extension.

srgbrito avatar Sep 15 '18 22:09 srgbrito

Same problem with codemirror.js here.

rgreen13 avatar Sep 26 '18 16:09 rgreen13

Hello everyone It may have been fixed in Ver.3.0.0, please update and try again. I am waiting for the result report.

nobuhito avatar Oct 02 '18 09:10 nobuhito

I installed version 3.0, but I'm still getting a blank window on OS X.

DanielSWolf avatar Oct 02 '18 10:10 DanielSWolf

Same here. Still missing codemirror

rgreen13 avatar Oct 02 '18 10:10 rgreen13

It doesn't fix the bug.

srgbrito avatar Oct 02 '18 13:10 srgbrito

Hmm ...

I am thinking of two countermeasures

  • Lazy access
  • Starting and running the web server

Which is better?

nobuhito avatar Oct 02 '18 14:10 nobuhito

Try restarting Chrome(Ver. 69.0.3497.100). I had same problem under Windows 10 using Chrome. Solution was to exit Chrome and then from Visual Code(Ver. 1.28.2) do PrintCode again. This time print dialog box showed up without being empty. Has worked great since restarting Chrome.

true2thepen avatar Oct 22 '18 07:10 true2thepen

I ended up solving this by modifying the source code to pull codemirror from a CDN (https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.41.0/) as opposed to using the local modules. I will generate a pull request for this

rgreen13 avatar Nov 20 '18 18:11 rgreen13

Just wanted to confirm that the problem still exists. I am using Mojave on a 2013 Macbook Pro with Safari. I tried to configure printCode to use Chrome, but then no browser opens at all. Using a different port has no effect.

My solution now is to hit CMD-R as often as it takes to show the print-dialogue.

tomkarp avatar Dec 04 '18 16:12 tomkarp

I have the same issue. I solve this issue by setting printcode.disableTelemetry to true, since accessing Google is very slow from where I live. And by doing this, PrintCode works well with safari.

gaochenyi avatar Jan 04 '19 08:01 gaochenyi

printcode.disableTelemetry did not help me. It prints, but only black-and-white, though with line numbers. No syntax highlighting whatsoever.

mouse07410 avatar Jun 19 '19 01:06 mouse07410

I got Uncaught TypeError: Cannot read property 'propertyKeywords' of undefined when print sass files. any help?

seksitha avatar Apr 10 '20 02:04 seksitha