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