2017-03-14 2 views
0
import pypandoc 
output = pypandoc.convert_file('file.html', 'docx',outputfile="file1.docx") 
assert output == "" 

새로운 docx 파일을 생성하지만 스타일은 무시하고 있습니다.어떻게 html을 docx라는 단어로 변환 할 수 있습니까?

스타일 중 하나를 사용하여 새 docx 파일을 생성하는 방법을 알려줄 수 있습니까?

미리 답변 해 주셔서 감사합니다.

+1

확인하기 http://stackoverflow.com/questions/1035183/how-can-i-create-a-word-document-using-python 및 http://python-docx.readthedocs.io/en/latest /user/styles-using.html – Shailesh

답변

1

Windows에서 가장 쉬운 방법은 pywin32 플러그인을 사용하는 MS Word를 사용하는 것입니다. 예제 코드로 Here is good 답.

사용 pypandoc :해서 extra_args에 대한

output = pypandoc.convert(source='/path/to/file.html', format='html', to='docx', outputfile='/path/to/output.docx', extra_args=['-RTS']) 

읽기 this.