/// <summary> /// Convert the documents into images /// </summary> /// <param name="sourcePath"></param> /// <param name="targetPath">Path were the documents were generated</param> /// <param name="currentPage"></param> /// <param name="originalDocumentName"></param> /// <returns></returns> public int Process(string sourcePath, string targetPath, int currentPage, string originalDocumentName, int qualitySet) { var qSet = new QualitySet(); var doc = new Aspose.Words.Document(sourcePath); var targetFileName = targetPath.PathSplit(); var targetFileExt = targetFileName[targetFileName.Length - 1].Split('.'); var options = new Aspose.Words.Saving.ImageSaveOptions(SaveFormat.Jpeg) { PageCount = 1, PageIndex = currentPage - 1, Resolution = qSet.Get(qualitySet).Resolution, JpegQuality = qSet.Get(qualitySet).Quality }; var targetImage = targetPath.Replace("." + targetFileExt[targetFileExt.Length - 1], string.Empty) + currentPage + ConfigurationManager.AppSettings["ImageExtension"]; doc.Save(targetImage, options); return doc.PageCount; }
/// <summary> /// /// </summary> /// <param name="sourcePath"></param> /// <param name="targetPath"></param> /// <param name="currentPage"></param> /// <param name="originalDocumentName"></param> /// <returns></returns> public int Process(string sourcePath, string targetPath, int currentPage, string originalDocumentName, int qualitySet) { var qSet = new QualitySet(); var targetFileName = targetPath.PathSplit(); var targetFileExt = targetFileName[targetFileName.Length - 1].Split('.'); var diagram = new Diagram(sourcePath); var options = new Aspose.Diagram.Saving.ImageSaveOptions(SaveFileFormat.JPEG) { PageIndex = currentPage - 1, Resolution = qSet.Get(qualitySet).Resolution, JpegQuality = qSet.Get(qualitySet).Quality }; var targetImage = targetPath.Replace("." + targetFileExt[targetFileExt.Length - 1], string.Empty) + currentPage + ConfigurationManager.AppSettings["ImageExtension"]; diagram.Save(targetImage + "X", options); AddHeader(targetImage + "X", diagram.Pages[currentPage - 1].Name); return diagram.Pages.Count; }
/// <summary> /// /// </summary> /// <param name="sourcePath"></param> /// <param name="targetPath"></param> /// <param name="currentPage"></param> /// <param name="originalDocumentName"></param> /// <returns></returns> public int Process(string sourcePath, string targetPath, int currentPage, string originalDocumentName, int qualitySet) { var msg = MailMessage.Load(sourcePath, MailMessageLoadOptions.DefaultMsg); var targetFileName = targetPath.PathSplit(); var targetFileExt = targetFileName[targetFileName.Length - 1].Split('.'); var ms = new MemoryStream(); msg.Save(ms, MailMessageSaveType.MHtmlFromat); var loadOptions = new LoadOptions { LoadFormat = (LoadFormat)Aspose.Cells.LoadFormat.MHtml }; var document = new Aspose.Words.Document(ms, loadOptions); var qSet = new QualitySet(); var options = new Aspose.Words.Saving.ImageSaveOptions(SaveFormat.Jpeg) { PageCount = 1, PageIndex = currentPage - 1, Resolution = qSet.Get(qualitySet).VerticalResolution, JpegQuality = qSet.Get(qualitySet).Quality }; var targetImage = targetPath.Replace("." + targetFileExt[targetFileExt.Length - 1], string.Empty) + currentPage + ConfigurationManager.AppSettings["ImageExtension"]; document.Save(targetImage, options); return document.PageCount; }
/// <summary> /// /// </summary> /// <param name="sourcePath"></param> /// <param name="targetPath"></param> /// <param name="currentPage"></param> /// <returns></returns> public int Process(string sourcePath, string targetPath, int currentPage, string originalDocumentName, int qualitySet) { var qSet = new QualitySet(); var res = float.Parse(qSet.Get(qualitySet).Resolution.ToString()); var pageCount = 0; using (var pres = new Aspose.Slides.Presentation(sourcePath)) { pageCount = pres.Slides.Count; var slide = pres.Slides[currentPage - 1]; var bmp = slide.GetThumbnail(2f, 2f); var targetImage = System.IO.Path.GetDirectoryName(targetPath) + System.IO.Path.DirectorySeparatorChar + System.IO.Path.GetFileNameWithoutExtension(targetPath) + currentPage + ConfigurationManager.AppSettings["ImageExtension"]; var jgpEncoder = GetEncoder(ImageFormat.Jpeg); var qEncoder = Encoder.Quality; var parameters = new EncoderParameters(1); var qEncoderParameter = new EncoderParameter(qEncoder, long.Parse(qSet.Get(qualitySet).Quality.ToString())); bmp.SetResolution(res, res); parameters.Param[0] = qEncoderParameter; bmp.Save(targetImage, jgpEncoder, parameters); } return pageCount; }