使用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;
}

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM