C# 利用Aspose.Words .dll将本地word文档转化成pdf(完美破解版 无水印 无中文乱码)

下载Aspose.Words .dll  http://pan.baidu.com/s/1c8659k

在vs2010中新建窗体应用程序,命名为 wordtopdf

添加Aspose.Words .dll  引用

编写代码

 1 using System;
 2 using System.Collections.Generic;
 3 using System.ComponentModel;
 4 using System.Data;
 5 using System.Drawing;
 6 using System.Text;
 7 using System.Linq;
 8 using System.Windows.Forms;
 9 using System.IO;
10 using Aspose.Words;
11 
12 namespace wordtopdf
13 {
14     public partial class Form1 : Form
15     {
16         public Form1()
17         {
18             InitializeComponent();
19         }
20 
21         private void button1_Click(object sender, EventArgs e)
22         {
23             //读取doc文档
24             Document doc = new Document(@"C:\Users\Administrator\Desktop\123\123.doc");
25             //保存为PDF文件,此处的SaveFormat支持很多种格式,如图片,epub,rtf 等等
26             doc.Save(@"C:\Users\Administrator\Desktop\temp.pdf", SaveFormat.Pdf);
27         }
28     }
29 }


点击生成wordtopdf

其中遇到以下错误

原来是框架(.NET Framework 4 Client Profile)不合适,故换一种框架(点击项目---wordtopdf属性---目标框架---选择.NET Framework 4)再次运行没有错误

 

 运行效果:

 

 

posted @ 2016-09-23 12:16  小雨滴答  阅读(16544)  评论(4编辑  收藏  举报