fraoustin / Sublime2pdf

/!\ inactive /!\ plugin for sublime generate a pdf file for print
11 stars 3 forks source link

Getting a traceback error when running in Sublime Text 2 #3

Open jeffself opened 11 years ago

jeffself commented 11 years ago

Installed the 2pdf plugin. When I have a file open and click Selection->2pdf, I get the following traceback dialog:

Traceback (most recent call last): File "./2pdf.py", line 126, in run File "./2pdf.py", line 168, in _run AttributeError: 'module' object has no attribute 'startfile'

Any suggestions?

jaman commented 11 years ago

I just ran into the same problem myself. Found a quick fix.

on line 168: change:

        os.startfile(outfile)

to:

        if sys.platform.startswith('darwin'):
            subprocess.call(('open', outfile))
        elif os.name == 'nt':
            os.startfile(outfile)
        elif os.name == 'posix':
            subprocess.call(('xdg-open', outfile))

startfile is a windows only feature. You'll also need to add in a require for subprocess as it is not there.

There are a number of ways to fix this issue. I've just chosen the one that should fix it for all platforms. For a discussion: http://stackoverflow.com/questions/434597/open-document-with-default-application-in-python

datone commented 11 years ago

Have to say it's a great plugin for me, but i found an issue(or my issue) when printing Chinese, all i get are messy code in PDF doc. Would you please help how to resolve it. Thanks.