Sublime Forum

Printing in 3.1

#23

OK I don’t know python but i did manage to write this code which should do what I was thinking. If the dev is interested I can test it out cross platform and what not.

import webbrowser
import os
print ()
f = open('sublimeprintpagethisgetsupdatedoneveryprint.html','w')
 
message = """<html>
<head>
<style>
@media print {
  @page { margin:1cm 0 0 0; }
  body { margin: 1.6cm; }
}

</style>
<title> Put the name of the file here </title>
<script>
window.addEventListener('load', function() {
  window.onload = function() { window.print();
  window.close();
   }
})
</script>
</head>
<body onload='window.print();'><pre> 
The current sublime text
 </pre></body>

</html>"""
 
f.write(message)
f.close()

#Change path to reflect file location
filename = 'file:///'+os.getcwd()+'/' + 'sublimeprintpagethisgetsupdatedoneveryprint.html'
webbrowser.open_new_tab(filename)
0 Likes

#24

Agree. And for that matter how often you needed to print 15 years ago vs. today.

Jokes apart, baked in printing would be handy but for those occasions when I need to print ExportHTML + Chrome does the job beautifully - and actually offers some real benefits: styling, font selection and general post-processing before print. If Sublime had printing baked in I’d probably still use ExportHTML as it would likely be more flexible.

So I can’t see what built in printing actually brings to the table. I’m far more in favour of the necessary time/resources being ploughed into much needed features, expanded API, Sidebar API, code refactoring / intel, performance improvements (esp. large files/long lines), macros that record everything etc. etc… Sublime’s great but in some areas it’s falling behind VSCode, Atom etc., and to remain viable it must keep up with features that users need while offering its own USPs. Just my 2p.

0 Likes

#25

Only few people still use VGA monitors with 640x480 pixels :smile:

These are the people who still print out all their e-mails to have them by hand quickly if needed! :wink:

Save trees, save paper, use wind energy to drive a disk!

I don’t know any pure text editor with satisfying printing features. All of it is a mess. In the very rare cases it is needed ExportHtml package does a perfect Job in exporting the editors content to the browser and immediately open its print dialog to export billions of code to millions of sheets of paper.

It’s amazing that most stupid things cause the most heavy discussions all over the world.

3 Likes