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)