使用Aspose.Words将Word文档转换为Tiff格式图片文件

Aspose组件的优点是操作Word文档不需要安装Office就可以实现。

 

首先需要引用Aspose.Words.dll,链接地址:链接:https://pan.baidu.com/s/1rJvjp-kMsEterYf_oud28Q   提取码:awiw 

 

代码如下:

public bool WordToTif(string sourcePath,string targetPath)
{
try
{ 
Document doc = new Document(sourcePath); 
ImageSaveOptions iso = new ImageSaveOptions(SaveFormat.Tiff);
iso.TiffCompression = TiffCompression.Ccitt4; //设置压缩方式
iso.PageCount = 1;
iso.Resolution = 200; //设置精度
//iso.PrettyFormat = true;
//iso.UseAntiAliasing = true;
int count = doc.PageCount;

for (int i = 0; i < count; i++)
{
iso.PageIndex = i;
doc.Save(targetPath + "\\000" + i.ToString() + ".Tif", iso); 
}
}
catch(Exception e)
{
Console.WriteLine(e.Message);
Console.ReadKey();
}

return true;
}

 

posted on 2018-11-07 14:13  明君  阅读(1140)  评论(0编辑  收藏  举报

导航