Sublime Forum

Printing from sublime

#2

This isnā€™t supported yet, and while itā€™s on the todo list, itā€™s currently a low priority.

0 Likes

#3

go green!

0 Likes

#4

Any more updates on the print functionality? Iā€™m certainly in favor of going green, but it would be very handy to be able to print from Sublime. I occasionally need to print chunks of code for code reviews at work (sorry, but thatā€™s required in my current environment!) and Iā€™d like to be able to do so without having to use a different editor.

Otherwise, still enjoying Sublime immensely!

1 Like

#5

Itā€™s still a low priority, at least until more people chime in saying this is something they need.

1 Like

#6

I would use it a lot too, for now it doesnā€™t have to give me a syntax coloring or anything fancy like numbered lines but it has to keep the font/size of itā€¦

0 Likes

#7

This is me, chiming in. :smile: Printing would be swell.

You canā€™t really make the claim that Sublime Text is for ā€œproseā€ without the ability to print, nowā€¦ :confused:

0 Likes

#8

you could print via bitbucket.org/sublimator/htmlexport/wiki/Home :wink:

1 Like

#9

Nice to have, but definitely not an issue for me. Just open it up in another editor that does printing well and sucks at everything else and there it comes out of the printer :wink:

0 Likes

#10

Iā€™ve just started using Sublime and I will definitely buy a copy when Printing is implemented. This only feature (imho) missing!

0 Likes

#11

chime Printing is valuable for me as well. At the moment Iā€™m exporting to Textpad to print.

btw Sublime is a superb editor and has taken over Textpad as my day to day editor. I bit the bullet and bought it today to show my thanks.

0 Likes

#12

Chalk me up as a user who would love to print with syntax highlighting as well. Sometimes a piece of code rework/review works best when you have it printed.

0 Likes

#13

Hmm, Iā€™ve just started using Sublime and I will consider buying a copy when Printing is implemented.
$60 for a text editor that canā€™t print? Really?

0 Likes

#14

I seriously cannot recall the last time I printed code. It becomes out of date so quick. I understand that for a code review this might be the traditional way to do it. Then again, using a projector and being able to annotate changes on the fly adds a lot of value in addition to saving some trees. Not to mention, that you will be able to demonstrate your super fast editing skills in front of your manager/peers.

IMO Sublime is first and foremost an editor. I want mad editing features. Sure, having printing available would be nice, but there are so many alternative programs/approaches. What alternatives are there for multiple select the way Sublime does it? $60 and no printing? I prefer to think of it the other way around. These other editors are $??? and have no multi-select?

I think it is a question of priorities. What would we like to be worked on next? Maybe we can utilize a voting mechanism much like other sites do to highlight needed functionality? This forum doesnā€™t seem condusive to that.

John.

0 Likes

#15

I agree with jgoalby completely. Sublime should stay lean and not fall into a feature creep spiral. Thereā€™s a lot of room for improvement/polishing in its main area: text editing. I donā€™t see it as an all-purpose word processor.

1 Like

#16

I bought a copy of sublime a few months back, and just wanted to chime in here - printing, especially ā€œpretty printingā€, is a high priority for me as a user - even if it just rendered to a PDF that I could print via a PDF viewer. As it stands, the lack of a print in Sublime means I have to use different editor even though I prefer Sublime.

0 Likes

#17

Agree 100%.

I understood Sublime to be a text editor, not a code editor. Thereā€™s a lot more kinds of text than code, including articles, fiction, grocery lists, notes, applications, half-written textsā€¦

Sublime is elegant and fast, and Iā€™d prefer to buy and use it. But until it can print, Iā€™ll stick with Notepad++ (which is free, and can print).

0 Likes

#18

I agree, this is definitely my issue, I use text editors to write everything from meeting notes to planning projects not just writing code. Printing unfortunately is a requirement. Between this and the strange ā€œblank screen on resumeā€ Iā€™m just not using sublime as much as my previous editor textpad. It would be great to see some progress on these issues.

Cheers

jdb

0 Likes

#19

chime

:smile:

0 Likes

#20

+1. Got bitten by this today ā€“ please add simple b/w fixed face printing!

0 Likes

#21

So this is more proof of concept than pretty functionality, but itā€™s possible to write a plugin that sends the current view to a .pdf, then you can print it off from Reader or Foxit or Preview or whatever you use.

Thereā€™s an open source PDF toolkit by Reportlab that you can download from here:

http://www.reportlab.com/software/opensource/rl-toolkit/download/

Install it with ā€œpython setup.py installā€ and additionally throw the /reportlab directory in your /User directory. Then put this plugin in the /User directory as well:

import time, os
import sublime, sublime_plugin
from reportlab.pdfgen import canvas
from reportlab.lib.units import inch
from reportlab.lib.pagesizes import A4


class PrintToPdfCommand(sublime_plugin.TextCommand):
    def run(self, edit):
        if len(self.view.file_name()) > 0:
            page = self.view.substr(sublime.Region(0, self.view.size()))
            top_margin = A4[1] + .25*inch
            bottom_margin = inch
            left_margin = .25*inch
            started = time.time()
            pdfname = self.view.file_name() + ".pdf"
            canv = canvas.Canvas(pdfname, invariant=1)

            canv.setFont("Courier", 8)
            tx = canv.beginText(left_margin, top_margin - 0.5*inch)
            sublime.status_message("Processing PDF...")
            tx.textLines(page, trim=0)
            
            for line in page:
                y = tx.getY()
                if y < bottom_margin + 0.5*inch:
                    canv.drawText(tx)
                    canv.showPage()
                    canv.setFont("Courier", 8)
                    tx = canv.beginText(left_margin, top_margin - 0.5*inch)

            if tx:
                canv.drawText(tx)
                canv.showPage()

            canv.save()
            print "%s successfully created." % (pdfname)
            sublime.status_message("PDF successfully processed.")


            finished = time.time()
            elapsed = finished - started
            pages = canv.getPageNumber()-1
            speed =  pages / elapsed
            fileSize = os.stat(pdfname)[6] / 1024
            print "%d pages in %0.2f seconds = %0.2f pages per second, file size %d kb" % (
                        pages, elapsed, speed, fileSize)


        def is_enabled(self):
            return self.view.file_name() and len(self.view.file_name()) > 0

Keybinding

    { "keys": "ctrl+alt+p"], "command": "print_to_pdf" }

This works for me, but itā€™s not very pretty and multiple pages will break the formatting for now. If someone wants to improve it, go for it. Just a start for someone desperate for printing capabilitiesā€¦

0 Likes