zoukankan      html  css  js  c++  java
  • C# 实现Word 转成图片 利用 Aspose.Words.dll

    Word转成图片,办法有很多。今天给大家介绍一下,使用Aspose.Words.dll实现

    首先在项目中添加对Aspose.Words.dll的引用。代码如下:

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;
    using Aspose.Words;
    using Aspose.Words.Saving;
    using System.IO;
    
    namespace NewConvertBook
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }
    
            private void button1_Click(object sender, EventArgs e)
            {
                //读取doc文档
                Document doc = new Document(@"C:UsersAdministratorDesktop	emp测试 .doc");
    
                //保存为PDF文件,此处的SaveFormat支持很多种格式,如图片,epub,rtf 等等
                ImageSaveOptions imageOptions = new ImageSaveOptions(SaveFormat.Png);
                imageOptions.PrettyFormat = true;
                imageOptions.Resolution = 150;//设置图片质量(越大越清晰)
    
                for (int i = 0; i < doc.PageCount; i++) 
                {
                    imageOptions.PageIndex = i;
                    doc.Save("temp" + i.ToString() + ".png", imageOptions);
                }
    
            }
        }
    }

    可以支持jpeg(SaveFormat.Jpeg),png(SaveFormat.Png),bmp(SaveFormat.Bmp) 三种格式的图片。

  • 相关阅读:
    bzoj4282 慎二的随机数列
    bzoj2839 集合计数
    bzoj1735 [Usaco2005 jan]Muddy Fields 泥泞的牧场
    bzoj3732 Network
    Kruskal重构树
    bzoj1568 [JSOI2008]Blue Mary开公司
    bzoj4576 [Usaco2016 Open]262144
    p2522 [HAOI2011]Problem b
    bzoj2463 谁能赢呢
    p4301 [CQOI2013]新Nim游戏
  • 原文地址:https://www.cnblogs.com/ywtk/p/3289239.html
Copyright © 2011-2022 走看看