这个问题主要针对 Windows + LibreOffice + Python 3。
我已经安装了 LibreOffice (6.3.4.2),并且
pip install unoconv(pip install unotools 是pip install uno另一个不相关的库),但在之后我仍然收到此错误import uno:
ModuleNotFoundError:没有名为“uno”的模块
更一般地说,作为 UNO 使用的示例,如何使用 LibreOffice UNO 打开 .docx 文档并将其导出为 PDF?
几天来我对此进行了广泛的搜索,但我还没有找到可在 Windows 上运行的可重现的示例代码:
无头使用soffice.exe,请参阅我的问题+答案Headless LibreOffice 在 Windows 上导出到 PDF 非常慢(比 Linux 慢 6 倍)以及答案的注释:它“可以”使用,soffice.exe --headless ...但更接近 COM 交互(组件对象模型) )对于许多应用程序都是有用的,因此这个问题在这里
相关论坛帖子,以及LibreOffice:使用Python脚本编程,但是uno应该如何安装在Windows上,使用Python,没有详细说明;还有关于 LibreOffice 到 Python 宏编写的详细教程,尤其是 Calc
我也尝试过这个(不成功):Getting python to import uno / pyuno: …
我使用PDFFocus.net dll将PDF文件转换为word文件。但是对于我的系统,我需要.docx文件。我尝试了不同的方法。有一些可用的库。但是那些不是免费的。这是我的pdf到doc转换代码。
Using System;
Using System.Collections.Generic;
Using System.Linq;
Using System.Text;
Using System.Threading.Tasks;
Using iTextSharp.text;
Using iTextSharp.text.pdf;
namespace ConsoleApplication
{
class Program
{
static void main(String[] args)
{
SautinSoft.PdfFocus f=new SautinSoft.PdfFocus();
f.OpenPdf(@"E:\input.pdf");
t.ToWord(@"E:\input.doc");
}
}
}
Run Code Online (Sandbox Code Playgroud)
这项工作成功。然后,我尝试使用以下代码将.doc转换为.docx。但这给了我错误。
//Open a Document.
Document doc=new Document("input.doc");
//Save Document.
doc.save("output.docx");
Run Code Online (Sandbox Code Playgroud)
谁能帮我。
我想问一下是否可以使用R将文本文件(例如word文档或文本文档)转换为PDF?我想使用此代码将其转换为 .rmd,然后转换为 PDF
require(rmarkdown)
my_text <- readLines("C:/.../track.txt")
cat(my_text, sep=" \n", file = "my_text.Rmd")
render("my_text.Rmd", pdf_document())
Run Code Online (Sandbox Code Playgroud)
但它不起作用显示此错误:
> Error: Failed to compile my_text.tex.
In addition: Warning message:
running command '"pdflatex" -halt-on-error -interaction=batchmode "my_text.tex"' had status 127
Run Code Online (Sandbox Code Playgroud)
还有其他解决方案吗?