zoukankan      html  css  js  c++  java
  • C# 利用Aspose.Words .dll将本地word文档转化成pdf

    原文:https://www.cnblogs.com/qiwu1314/p/5899545.html?utm_source=itdadao&utm_medium=referral

    下载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:UsersAdministratorDesktop123123.doc");
    25             //保存为PDF文件,此处的SaveFormat支持很多种格式,如图片,epub,rtf 等等
    26             doc.Save(@"C:UsersAdministratorDesktop	emp.pdf", SaveFormat.Pdf);
    27         }
    28     }
    29 }
    复制代码


    点击生成wordtopdf

    其中遇到以下错误

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

     

     运行效果:

     

  • 相关阅读:
    rancher 2.X 搭建小型web集群+mysql主从复制
    harbor 仓库搭建
    k8s 集群搭建
    oracle sql命令
    IIS实现反向代理
    高并发的大型网站架构设计
    .net core集成vue
    使用TFS玩转Docker自动化部署
    动态创建IIS站点
    网站架构设计(草稿)
  • 原文地址:https://www.cnblogs.com/zhang1f/p/12468810.html
Copyright © 2011-2022 走看看