AlJohri / docx2pdf

MIT License
506 stars 96 forks source link

Using with Cygwin? #17

Open hashimaziz1 opened 4 years ago

hashimaziz1 commented 4 years ago

Currently while using the tool from Cygwin I get the error:

Traceback (most recent call last): File "/usr/bin/docx2pdf", line 8, in <module> sys.exit(cli()) File "/usr/lib/python3.7/site-packages/docx2pdf/__init__.py", line 170, in cli convert(args.input, args.output, args.keep_active) File "/usr/lib/python3.7/site-packages/docx2pdf/__init__.py", line 109, in convert "docx2pdf is not implemented for linux as it requires Microsoft Word to be installed" NotImplementedError: docx2pdf is not implemented for linux as it requires Microsoft Word to be installed

Word is installed on Windows. Is there any way to make the tool see that version instead of looking for a Linux one?

micahcochran commented 3 years ago

Yes, you could rewrite the convert function like so:

def convert(input_path, output_path=None, keep_active=False):
    paths = resolve_paths(input_path, output_path)
    if sys.platform == "darwin":
        return macos(paths, keep_active)
    elif sys.platform == "win32":
        return windows(paths, keep_active)
    else:
#        raise NotImplementedError(
#            "docx2pdf is not implemented for linux as it requires Microsoft Word to be installed"
#        )
        return windows(paths, keep_active)

This should remove the Error NotImplementedError.

I've not tested any of this out, so I don't know if it will work. If it does, a different test (in the convert function) will need to be performed to determine the platform. Please let us know if this works or what the next error is.