问题
import pypandoc
output = pypandoc.convert_file('file.html', 'docx', outputfile="file1.docx")
assert output == ""
It is generating new docx file but ignoring styles.
Can any one tell me how to generate new docx file with styles?
Thanks in advance for your answers.
回答1:
In Windows the easiest way will be to use MS Word using pywin32 plugin. Here is good answer with example code.
Using pypandoc:
output = pypandoc.convert(source='/path/to/file.html', format='html', to='docx', outputfile='/path/to/output.docx', extra_args=['-RTS'])
Read this for extra_args.
来源:https://stackoverflow.com/questions/42779184/how-can-i-convert-html-to-word-docx-in-python