1 string filePath = string.Empty; 2 Document doc = new Document(); 3 int ran = new Random().Next(100); 4 fileName = DateTime.Now.ToString("yyyyMMddHHmmss") + ran + strExt.Trim('*'); 5 filePath = Path.Combine(path, fileName); 6 7 fileUpload.SaveAs(filePath); 8 doc = new Document(filePath); 9 foreach (Section section in doc) 10 { 11 section.PageSetup.PaperSize = PaperSize.A4; 12 section.PageSetup.Orientation = Aspose.Words.Orientation.Portrait; 13 section.PageSetup.VerticalAlignment = Aspose.Words.PageVerticalAlignment.Top; 14 } 15 16 string imageName = fileName.Replace(strExt.Trim('*'), ""); 17 this.Session["ChangeImage"] = new CLS_ChangeImage { Index = 0, SumCount = doc.PageCount, NumState = 0 }; 18 19 ImageSaveOptions iso = new ImageSaveOptions(SaveFormat.Jpeg); 20 iso.PrettyFormat = true; 21 iso.UseAntiAliasing = true; 22 ci.NumState = 2; 23 this.Session["ChangeImage"] = ci; 24 System.Text.StringBuilder sbImg = new StringBuilder(); 25 string imgSavePath = ConfigurationManager.AppSettings["UploadPath"]; 26 for (int i = 0; i < doc.PageCount; i++) 27 { 28 ci.Index = i + 1; 29 ci.SumCount = doc.PageCount; 30 31 iso.PageIndex = i; 32 string iName = imageName + "_" + i + ".jpg"; 33 34 doc.Save(path + "/" + iName, iso); 35 FileStream file = new FileStream(path + "/" + iName, FileMode.Open); 36 37 AF.UploadFileBinary(file, iName);//吧文件保存到另外一个地方 38 sbImg.Append(iName + "|"); 39 this.Session["ChangeImage"] = ci; 40 //System.Threading.Thread.Sleep(5000); 41 42 }
以上代码转换出来的图片与原文档格式上有所偏差,有什么解决方案吗?
以下是转换前的文档( 第7章到了第二节就换页了
而转换后的的图片却不一样
Aspose 不是有 support forum吗, 去那里问问吧
给个地址吧