Sublime Forum

Printing from Sublime Text 2?

#13

[quote=“ntenney”]

This issue is a major concern for a very vocal minority of forum users.[/quote]

really?

sublimetext.userecho.com/topic/25170-printing/

0 Likes

#14

[quote=“sinoxer”]

really?

sublimetext.userecho.com/topic/25170-printing/[/quote]

Yes really. I had never heard of userecho until you posted that link, and, correct me if I’m wrong, but userecho is not the official forums. Also, did you bother to read the posts on that topic? A vocal group of people complaining about printing, some people posting and saying it’s not a big deal, some others giving work arounds, and the critics dismissing the work arounds. Pretty much exactly what I said.

0 Likes

#15

[quote=“ntenney”]

really?

sublimetext.userecho.com/topic/25170-printing/

Yes really. I had never heard of userecho until you posted that link, and, correct me if I’m wrong, but userecho is not the official forums. Also, did you bother to read the posts on that topic? A vocal group of people complaining about printing, some people posting and saying it’s not a big deal, some others giving work arounds, and the critics dismissing the work arounds. Pretty much exactly what I said.[/quote]

Your incredibly lame retorics doesn’t change the fact that 1065 upvotes exists. Well, 1064 now that you voted it down.

0 Likes

#16

OK, you’ve just outed yourself as Arjan. I thought that might be the case when I read one of your other threads, but I wasn’t sure. At this point, I’m only posting on this thread so that someone scanning through the forums later won’t read this thread and think this is yet another “unanswered post”. It seems like you have a personal ax to grind against Sublime Text and Jon. That’s the only reason I can think of that keeps you coming back and trolling the forums this persistently.

So, let me answer the personal attack you leveled at me. I never said that there were no upvotes. I never said that no one wants this feature. I said that it is a vocal minority. Let’s do the math. There are 13880 members on the OFFICIAL forum for Sublime Text. 1065 is less than 50% of the registered users on the official forums (in fact, it is less than 10%), therefore it is a minority. Heck yeah, I downvoted it. I didn’t even know userecho existed, and now I’m making my position known by voting. Just like you probably made your position known by upvoting it.

Also, you should learn the meaning of words before you try to use them (or spell them for that manner). In fact, we’ve both been using rhetoric to get our point across. Unless of course, you are going for the alternate meaning and implying that I’ve been dishonest or unreasonable. In which case, I challenge you to find an instance where I’ve been dishonest in any of our conversations. Reasonable is a more subjective measure, but I believe that I’ve been reasonable in my posts.

0 Likes

#17

To bring things back on topic. The question of printing has been answered many times here, but let’s go over it again…

I think the key reasons that Jon has left printing down the priority pile:

  1. Done well, printing support across multiple platforms is non-trivial work.
  2. Relatively few users need this function, and only occasionally. For the overwhelming use-case, there’s a perfectly workable solution via a plugin (see below). Most of the editor is used all the time by most users, Jon is a sole-developer; I’m guessing he wants to focus on functions that he thinks will bring maximum benefit to the editor and market impact - for most users.

A simple solution is to use the Export HTML plugin together with your browser. Apart from simple, it’s also pretty darned flexible, because once your printable code is in HTML/CSS you can do lots with it in before printing (ie. on the fly styling of fonts, colours, spacing, pagination, etc.). That’s programmer friendly; after all, the primary audience for sublime. As many, I’ve been doing it this way for a while and it’s both simple and flexible. Most text editors’ inbuilt print facilities are nowhere near as flexible, though they’ll save you a couple of mouseclicks. I prefer the flexibility and see the extra couple of clicks as a non-issue.

For the above reason I really don’t understand why people are so hung up on printing. Maybe I’m missing something.

0 Likes

#18

I am old-fashioned and write documentation in text files. I print technical docs about two or three times a day for review (I can’t handle long on-screen reading sessions)

So I suppose I am a minority user, but using a plugin or copy-paste to another editor seems a bit silly for such a fundamental feature.

I wonder if there’s enough functionality exposed to write a plugin to do direct printing?

0 Likes

#19

Give Export HTML plugin a try, I pretty sure is good enough for 99% of people (the remaining must use another editor).

You can use a keybinding for printing.
This means that:
-You only have to hit your keybinding to launch your browser and open the printing setup window.
-Choose your printer settings and click OK.
-Close the browser.

So compared to another editor with builtin printing feature, you only have one more step (closing the browser), not a big deal when using two or three times a day.

0 Likes

#20

I must be the 1% :smiley:

Because when I do “Export HTML | Show Export menu | Browser print: Color”, my html editor starts up (NVu)

Without having looked at the source code… I suppose the plugin requires “htm(l)” file types to be associated with a browser, which is a no-go for me. Is there a way to say which process to start?

Note: I used github.com/facelessuser/ExportHtml - maybe there is an alternative?

0 Likes

#21

[quote=“qgates”]A simple solution is to use the Export HTML plugin together with your browser. Apart from simple, it’s also pretty darned flexible, because once your printable code is in HTML/CSS you can do lots with it in before printing (ie. on the fly styling of fonts, colours, spacing, pagination, etc.).
For the above reason I really don’t understand why people are so hung up on printing. Maybe I’m missing something.[/quote]

I completely agree.
Futhermore, adding that I seldom print my code (or anything) …this is really a non-issue to me.

0 Likes

#22

[quote=“TonyW”]

I must be the 1% :smiley:

Because when I do “Export HTML | Show Export menu | Browser print: Color”, my html editor starts up (NVu)

Without having looked at the source code… I suppose the plugin requires “htm(l)” file types to be associated with a browser, which is a no-go for me. Is there a way to say which process to start?

Note: I used github.com/facelessuser/ExportHtml - maybe there is an alternative?[/quote]

Looking at the ExportHtml source code that you linked to, the last few lines of “ExportHtml.py” have the following code:

        if inputs"view_open"]:
            self.view.window().open_file(the_html.name)
        else:
            # Open in web browser; check return code, if failed try webbrowser
            status = desktop.open(the_html.name, status=True)
            if not status:
                webbrowser.open(the_html.name, new=2)

So it looks like the plugin is trying to open the html file with the default application (desktop.open), but the fallback code is what you want (webbrowser.open). A simple edit of the code should give you the preferred behaviour. If editing the code is out of the question for you, then maybe you could create a new issue with the developer asking him for a setting to control this behaviour (github.com/facelessuser/ExportHtml/issues)?

0 Likes

#23

[quote=“jbjornson”]

I must be the 1% :smiley:

Because when I do “Export HTML | Show Export menu | Browser print: Color”, my html editor starts up (NVu)

Without having looked at the source code… I suppose the plugin requires “htm(l)” file types to be associated with a browser, which is a no-go for me. Is there a way to say which process to start?

Note: I used github.com/facelessuser/ExportHtml - maybe there is an alternative?

Looking at the ExportHtml source code that you linked to, the last few lines of “ExportHtml.py” have the following code:

        if inputs"view_open"]:
            self.view.window().open_file(the_html.name)
        else:
            # Open in web browser; check return code, if failed try webbrowser
            status = desktop.open(the_html.name, status=True)
            if not status:
                webbrowser.open(the_html.name, new=2)

So it looks like the plugin is trying to open the html file with the default application (desktop.open), but the fallback code is what you want (webbrowser.open). A simple edit of the code should give you the preferred behaviour. If editing the code is out of the question for you, then maybe you could create a new issue with the developer asking him for a setting to control this behaviour (github.com/facelessuser/ExportHtml/issues)?[/quote]

Thanks for the suggestions. After some looking around, I figured out how to edit the source and made sure only webbrowser.open is called. Unfortunately, that too opens NVu (or whatever the default application is)

0 Likes

#24

How about trying this instead?

webbrowser.open('file://' +the_html.name, new=2)
0 Likes

#25

…or maybe this:

webbrowser.get("firefox").open(the_html.name, new=2)

from http://www.daniweb.com/software-development/python/threads/285581/how-do-i-call-the-default-browser-from-a-python-program.

Check here for more browser types other than firefox: http://docs.python.org/2/library/webbrowser.html

0 Likes

#26

[quote=“jbjornson”]…or maybe this:

webbrowser.get("firefox").open(the_html.name, new=2)

from http://www.daniweb.com/software-development/python/threads/285581/how-do-i-call-the-default-browser-from-a-python-program.

Check here for more browser types other than firefox: http://docs.python.org/2/library/webbrowser.html[/quote]

Chrome (my only browser) is not on that list. Chrome support was added in Python 3.3.x apparently - but still no go.

I think I’ll give up for now, and I guess this proves the point about printing as a native feature…

0 Likes

#27

One last try…the correct documentation link is: http://docs.python.org/3/library/webbrowser.html. Try one of the following: ‘google-chrome’, ‘chrome’, ‘chromium’, ‘chromium-browser’

0 Likes

#28

None of those works - the associated application still starts. Since Python has four (!) different chrome names, I guess this is shaky business, and my bleeding edge chrome beta isn’t found under those names?

0 Likes

#29

I suppose you are on a Windows box.
webbrowser module is next to useless for anything except the default system browser.
It search the browser name in the system path, which is not a good idea on Windows.

You can check which browser was found in the console:

import webbrowser webbrowser._browsers

Something like that must work, but not very useful:

webbrowser.BackgroundBrowser('C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe').open('http://www.myurl.com')

Open an issue for the Export HTML plugin, facelessuser is a nice and brilliant guy.

0 Likes

#30

I’m one of “those guys” that considers integrated printing essential to their work. I really don’t understand the virulence and contempt with which the people with the opposite views seem to regard this feature request.

I’ve been programming for 20 something years, and an essential part of the way I work is to print out and annotate my own code, and to share it with others for comment and revision. I understand that not everyone works that way, but because it is so important to the way I work, my primary editor will have that feature.

I have tried the other printing options, and they are just not “there.” Print to HTML trashes programming indentation, particularly when there is a mix of spaces and tabs in the file. So I come to this forum simply to state that integrated printing is an essential feature for me, and to express my wish that it be added to Sublime 3. The developer of Sublime can do with this what he will, but I’m not going to buy the editor unless it has this feature.

If you don’t care about this feature, fine. But it’s important to me, because it’s part of the way that I work and code.

I really, really like Sublime: it is elegant, lightweight, and has personality. But the lack of integrated printing keeps me using editors that are otherwise clunkier (Notepad++, MultiEdit, SlickEdit).

0 Likes

#31

I am programming for moreless 28 years, rarely I print code, but its a important feature, even Notepad has print option. Sublime Text is the best code editing tool, I bought it to support developers, they should implement this feature to support users :smile:

0 Likes

#32

I wrote this plugin for my own. I hope it helps you all. Regards!

[code]

Coded by: Johan Maximus

This plugin for SublimeText3 prints the content of the current window over Windows platforms

Installation: place this “print.py” file into you user packages folder. Eg.: sublimeFolder/Data/Packages/User/print.py

After that, bind the command “print” to a hot key you feel comfortable with. Go to “Preferences”, “Key Bindings - User” and write the next few lines:

{ “keys”: “ctrl+alt+p”], “command”: “print” }

]

import sublime, sublime_plugin

class PrintCommand(sublime_plugin.TextCommand):
def run(self, edit):
# Reference wherever you want in your computer
path = “C:\Users\Maxi\Documents\printFile.txt”
# Select all in the current window
content = self.view.substr(sublime.Region(0, self.view.size()))
# It opens the file “printFile” for writing
text_file = open(path, “w”)
# Writes our content
text_file.write(content)
# Close the file
text_file.close()
# The sad part. It opens the file we created, containing what we want to print, with your default OS text editor (notepad in my case) and sends the print command to it.
os.startfile(path, “print”)
# Notepad closes after printing. That’s all…[/code]

0 Likes