Printing support


#19

There is an npm package for printing on any OS: node-printer. I tried to get it to work and had trouble building it. I should try it again. I think I had setup problems with GYP.


#20

I got https://github.com/tojocky/node-printer to install, what next? Some kind of package that puts a menu item under File, then reades the active tab?


#21

I can write a package to use that. If you want black-and white text I could have it working in a few hours. Color highlighted would take a few days. I’ll try to get to the B/W version tomorrow.

Edit: of course if can write a package that would be even better. (grin)


#22

For what it’s worth, since window.print appears to work in atom shell, you can do this:

_ = require 'lodash'

atom.commands.add 'atom-workspace', 'editor:print', ->
	iframe = document.createElement('iframe')

	iframe.style.visibility = 'hidden'
	iframe.style.position = 'fixed'
	iframe.style.right = 0
	iframe.style.bottom = 0

	document.body.appendChild(iframe)

	editor = atom.workspace.getActiveTextEditor()
	text = editor.getText()
	html = "<pre>#{_.escape text}</pre>"

	iframe.contentWindow.document.write(html)

	close = ->
		document.body.removeChild(iframe)

	iframe.contentWindow.onbeforeunload = close
	iframe.contentWindow.onafterprint = close
	iframe.contentWindow.print()

No need for node modules. This doesn’t include syntax highlighting, which is a bit more involved.


#23

Only because it needs more work, right? I wonder if one could just clone the texteditor DOM fragment.


#24

Lines are only in the DOM when they’re visible. The best option is probably to rebuild the HTML from tokenized source.

I made a simple package but I haven’t published it yet, try it out https://github.com/postcasio/atom-printer

It builds the HTML and puts it in a shadow root with the current syntax theme.


Print functionality?
#25

No problem, just programmatically scroll through the editor and clone the lines into the iframe in any order.

Aweome. Looking forward to using it.


#26

I’m shocked and saddened! this is 2015?


#27

30 years ago we had to print out stuff. Now print is dead. Actually 30 years ago the ghostbuster pronounced print as dead. He was just a bit ahead of his time.

I haven’t printed anything in a year or two.


#28

I keep trying to get my daughter to take my LaserJet something-or-other from 1999 away so I don’t have to keep it in my office anymore :laughing:


#29

for someone like me, with a handicap…printing is a boon under certain situations.

I cannot implement this is atom…but I would really appreciate it if someone did develop this printing capability


#30

Did you try the package @postcasio mentioned above?


#31

I can’t find atom-printer in the package search.

https://atom.io/packages/search?q=atom-printer (not found)

Am I looking in the wrong place?


#32

It was never released. The source of the package is still available though.


#33

Well,
so what should we do?

For me Atom is a Sublime kller but I still have to copy and past to TextEdit to print stuff. That is awkward. :-/


#34

Someone can take up the baton and make the package work. Or someone could create a new package that offers the functionality.


#35

+1 for printing support as a feature request. When I can open up vi/vim and run :!lpr, it’s really hard to justify switching to Atom as my text editor. There’s more to a text editor than coding and revision control, after all.

John


#36

Yes–someone could contribute this as an add-on package, but I’d like to see it built into the editor or at least a package provided and supported by the Atom team itself. That way it stays supported when user X goes on vacation or loses interest.

Edit: The relevant GitHub issue seems to be

and is blocked pending improvements under Windows.


#37

I chatted with members of the team and they don’t have the staff to support all the packages/features everyone wants. That is why they designed atom to be extensible in the first place. If enough users want a feature then it will be supported in the long run. So far there doesn’t seem to be much interest in printing

Who supports VIM? I would expect Atom to pick up wide support as the user base grows and it is growing like crazy right now.


#38

I fixed the code of the atom-printer package: https://github.com/palant/atom-printer. It works, but I am not really impressed with the results:

  • Syntax highlighting meant for a dark theme looks bad on paper, it needs a separate theme setting for printing only.
  • Themes rely on particular elements to be present in the document. Without them, the font isn’t right - and I’m fairly certain that there are other subtle issues as well.
  • Printing a large document by generating an HTML document for it all at once is bound to cause extended hangs.
  • The title of the document is bogus, this could probably be alleviated by adding a <title> tag to the frame.
  • Per-print configuration is important, e.g. to support optional line numbers - yet I don’t think that extending the Print dialog is currently possible.

All in all, printing support isn’t really easy.


Ability to print