使用破解版的 Aspose,正版授权的比较贵,玩不起,而且需求量没有那么大,文末附上 Aspose.Word.dll
的下载地址
要从Word转为PDF,除了Aspose,还需要安装SkiaSharp
及 System.Text.Encoding.CodePages
, 如下:
<PackageReference Include="SkiaSharp" Version="1.60.3" />
<PackageReference Include="System.Text.Encoding.CodePages" Version="4.5.0" />
版本最好是一致,亲测版本太新会报错,应该是与Aspose.Word.dll
版本相对应。转换Demo如下:
var wordPath = @"D:\1.docx";
var pdfPath= @"D:\1.pdf";
Document doc = new Document(wordPath);
doc.Save(pdfPath, SaveFormat.Pdf);
同时系统需要安装 Visual C ++ Redistributable for Visual Studio 2015,以支持 SkiaSharp 的运行