通用PDF转换器
我正在寻找“任何文档转换器”的帮助,其中任何文档文件[DOC,DOCX,PPT,PPTX]将转换为PDF。 DOCX和PPTX易于使用Python库处理,但是Doc和PPT有点棘手。
答案我有7个月前很难处理。尤其是使用Unoconv的人(现在已弃用并更改为Unoserv)。
初始代码示例:
import os
import shutil
src = ".../srcpaths"
dst = ".../dstpaths"
ext = ['ppt', 'pptx', 'doc', 'docx']
for root, subfolders, filenames in os.walk(src):
for filename in filenames:
if os.path.splitext(filename)[1] in ext:
shutil.copy2(os.path.join(root, filename), os.path.join(dst, filename))
def ConvertToPDF(ext):
#some code#
ConvertToPDF('.ppt')
ConvertToPDF('.pptx')
ConvertToPDF('.doc')
ConvertToPDF('.docx')
I am looking for a help with "any document converter", where any document file [doc, docx, ppt, pptx] will be converted to pdf. DOCX and PPTX are easy to handle with python libraries, but DOC and PPT is a bit tricky.
The answers I've got 7 month ago was quite a bit hard to deal with. Especially the one with use of Unoconv (now its deprecated and changed to Unoserv).
Initial code example:
import os
import shutil
src = ".../srcpaths"
dst = ".../dstpaths"
ext = ['ppt', 'pptx', 'doc', 'docx']
for root, subfolders, filenames in os.walk(src):
for filename in filenames:
if os.path.splitext(filename)[1] in ext:
shutil.copy2(os.path.join(root, filename), os.path.join(dst, filename))
def ConvertToPDF(ext):
#some code#
ConvertToPDF('.ppt')
ConvertToPDF('.pptx')
ConvertToPDF('.doc')
ConvertToPDF('.docx')
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
以下是我对解决方案的评论和最后一个答案:
1。 PANDOC:
2。 Unoconv/Unoserver
3。基于云的解决方案:
4。 Google Drive API转换器:
5。 Librelambda
简单解决方案:
通过在CMD子过程中运行该软件。
需求:安装libreoffice。
最大的优势:可以在Windows和Linux上运行(应该为Linux修改),
这是我的Windows Python代码:
如果您可以将其修改为Linux,请随时共享您的解决方案
Below is my review of solutions and an answer at the end:
1. Pandoc:
2. Unoconv/Unoserver
3. Cloud-based solutions:
4. Google Drive API converter:
5. LibreLambda
Simple solution:
Use the software straightly by running it in a cmd subprocess.
Needs: installation of LibreOffice.
Biggest advantage: can run both on Windows and Linux (should be modified for linux)
Here is my Python code for Windows:
If you can modify it to Linux, please feel free to share your solution