The functionality I'm after is where Sublime Text opens the browser to the print preview of the file currently edited.
This is the following:
- Have a txt file (in sublime).
- Select File > Print
- Observe that the default browser opens up to the print preview page (tested in firefox and safari)
The urls seem to point to the file being in a temp directory and generated as a html file.
file:///private/var/folders/05/q2p__63n3zx9k3yzcb8f9n0c0000gn/T/tmpbfkdzvmq.html
Note html generation isn't necessary for my use case, remaining as txt is fine.
The answer can be for either swift or objective-c. I'm after how to open the browser to print preview.
CodePudding user response:
I believe the answer involves using Apple Events as mentioned by @Willeke. These is the information I found that assisted me:
- https://applescriptlibrary.files.wordpress.com/2013/11/apple-events-programming-guide.pdf
- http://webcache.googleusercontent.com/search?q=cache:B5zOBQgWUoMJ:mirror.informatimago.com/next/developer.apple.com/technotes/tn2002/tn2082.html &cd=1&hl=en&ct=clnk&gl=ae
- https://discussions.apple.com/thread/7743420
In pseudo AppleScript code, it would be something like this:
tell default browser
launch
print document
endtell