/// <summary> /// Render document in image representation with watermark /// </summary> /// <param name="DocumentName">file/document name</param> /// <param name="WatermarkText">watermark text</param> /// <param name="WatermarkColor"> System.Drawing.Color</param> /// <param name="position">Watermark Position is optional parameter. Default value is WatermarkPosition.Diagonal</param> /// <param name="WatermarkWidth"> width of watermark as integer. it is optional Parameter default value is 100</param> /// <param name="DocumentPassword">Password Parameter is optional</param> public static void RenderDocumentAsImages(String DocumentName, String WatermarkText, Color WatermarkColor, WatermarkPosition position = WatermarkPosition.Diagonal, int WatermarkWidth = 100, String DocumentPassword = null) { //ExStart:RenderAsImageWithWaterMark //Get Configurations ViewerConfig config = Utilities.GetConfigurations(); // Create image handler ViewerImageHandler imageHandler = new ViewerImageHandler(config); // Guid implies that unique document name string guid = DocumentName; //Initialize ImageOptions Object ImageOptions options = new ImageOptions(); // Set password if document is password protected. if (!String.IsNullOrEmpty(DocumentPassword)) { options.Password = DocumentPassword; } // Call AddWatermark and pass the reference of ImageOptions object as 1st parameter Utilities.PageTransformations.AddWatermark(ref options, WatermarkText, WatermarkColor, position, WatermarkWidth); //Get document pages in image form List <PageImage> Images = imageHandler.GetPages(guid, options); foreach (PageImage image in Images) { //Save each image at disk Utilities.SaveAsImage(image.PageNumber + "_" + DocumentName, image.Stream); } //ExEnd:RenderAsImageWithWaterMark }
/// <summary> /// Render simple document in image representation /// </summary> /// <param name="DocumentName">File name</param> /// <param name="DocumentPassword">Optional</param> public static void RenderDocumentAsImages(String DocumentName, String DocumentPassword = null) { //ExStart:RenderAsImage //Get Configurations ViewerConfig config = Utilities.GetConfigurations(); // Create image handler ViewerImageHandler imageHandler = new ViewerImageHandler(config); // Guid implies that unique document name string guid = DocumentName; //Initialize ImageOptions Object ImageOptions options = new ImageOptions(); // Set password if document is password protected. if (!String.IsNullOrEmpty(DocumentPassword)) { options.Password = DocumentPassword; } //Get document pages in image form List <PageImage> Images = imageHandler.GetPages(guid, options); foreach (PageImage image in Images) { //Save each image at disk Utilities.SaveAsImage(image.PageNumber + "_" + DocumentName, image.Stream); } //ExEnd:RenderAsImage }
/// <summary> /// Get attached file's image representation /// </summary> /// <param name="DocumentName">Input document name</param> public static void GetEmailAttachmentImageRepresentation(String DocumentName) { try { //ExStart:GetEmailAttachmentImageRepresentation // Setup GroupDocs.Viewer config ViewerConfig config = Utilities.GetConfigurations(); // Init viewer image handler ViewerImageHandler handler = new ViewerImageHandler(config); DocumentInfoContainer info = handler.GetDocumentInfo(DocumentName); // Iterate over the attachments collection foreach (AttachmentBase attachment in info.Attachments) { Console.WriteLine("Attach name: {0}, size: {1}", attachment.Name, attachment.FileType); // Get attachment document image representation List <PageImage> pages = handler.GetPages(attachment); foreach (PageImage page in pages) { Console.WriteLine(" Page: {0}, size: {1}", page.PageNumber, page.Stream.Length); } } //ExEnd:GetEmailAttachmentImageRepresentation } catch (System.Exception exp) { Console.WriteLine(exp.Message); } }
// GET api/<controller> public HttpResponseMessage Get(int?width, string file, int page, int?height = null) { ViewerImageHandler handler = Utils.CreateViewerImageHandler(); ImageOptions o = new ImageOptions(); List <int> pageNumberstoRender = new List <int>(); pageNumberstoRender.Add(page); o.PageNumbersToRender = pageNumberstoRender; o.PageNumber = page; o.CountPagesToRender = 1; if (width.HasValue) { o.Width = Convert.ToInt32(width); } if (height.HasValue) { o.Height = Convert.ToInt32(height); } Stream stream = null; List <PageImage> list = Utils.LoadPageImageList(handler, file, o); foreach (PageImage pageImage in list.Where(x => x.PageNumber == page)) { stream = pageImage.Stream; } ; var result = new HttpResponseMessage(HttpStatusCode.OK); Image image = Image.FromStream(stream); MemoryStream memoryStream = new MemoryStream(); image.Save(memoryStream, ImageFormat.Jpeg); result.Content = new ByteArrayContent(memoryStream.ToArray()); result.Content.Headers.ContentType = new MediaTypeHeaderValue("image/jpeg"); return(result); }
/// <summary> /// Render a document in image representation whom located at web/remote location. /// </summary> /// <param name="DocumentURL">URL of the document</param> /// <param name="DocumentPassword">Password Parameter is optional</param> public static void RenderDocumentAsImages(Uri DocumentURL, String DocumentPassword = null) { //ExStart:RenderRemoteDocAsImages //Get Configurations ViewerConfig config = Utilities.GetConfigurations(); // Create image handler ViewerImageHandler imageHandler = new ViewerImageHandler(config); //Initialize ImageOptions Object ImageOptions options = new ImageOptions(); // Set password if document is password protected. if (!String.IsNullOrEmpty(DocumentPassword)) { options.Password = DocumentPassword; } //Get document pages in image form List <PageImage> Images = imageHandler.GetPages(DocumentURL, options); foreach (PageImage image in Images) { //Save each image at disk Utilities.SaveAsImage(image.PageNumber + "_" + Path.GetFileName(DocumentURL.LocalPath), image.Stream); } //ExEnd:RenderRemoteDocAsImages }
public static void Add_Watermark_For_Image() { Console.WriteLine("***** {0} *****", "Add Watermark to Image page representation"); /* ********************* SAMPLE ********************* */ // Setup GroupDocs.Viewer config ViewerConfig config = new ViewerConfig(); config.StoragePath = @"C:\storage"; // Create image handler ViewerImageHandler imageHandler = new ViewerImageHandler(config); string guid = "word.doc"; ImageOptions options = new ImageOptions(); // Set watermark properties Watermark watermark = new Watermark("This is watermark text"); watermark.Color = System.Drawing.Color.Blue; watermark.Position = WatermarkPosition.Diagonal; watermark.Width = 100; options.Watermark = watermark; // Get document pages image representation with watermark List<PageImage> pages = imageHandler.GetPages(guid, options); }
public ActionResult Get(int?width, int?height, string file, int page) { if (Utils.IsValidUrl(file)) { file = Utils.DownloadToStorage(file); } ViewerImageHandler handler = Utils.CreateViewerImageHandler(); ImageOptions o = new ImageOptions(); List <int> pageNumberstoRender = new List <int>(); pageNumberstoRender.Add(page); o.PageNumbersToRender = pageNumberstoRender; o.PageNumber = page; o.CountPagesToRender = 1; if (width.HasValue) { o.Width = Convert.ToInt32(width); } if (height.HasValue) { o.Height = Convert.ToInt32(height); } Stream stream = null; List <PageImage> list = Utils.LoadPageImageList(handler, file, o); foreach (PageImage pageImage in list.Where(x => x.PageNumber == page)) { stream = pageImage.Stream; } ; return(new FileStreamResult(stream, "image/png")); }
public ActionResult Get(int?width, int?height, string file, string attachment, int page) { ViewerImageHandler handler = Utils.CreateViewerImageHandler(); ImageOptions o = new ImageOptions(); List <int> pageNumberstoRender = new List <int>(); pageNumberstoRender.Add(page); o.PageNumbersToRender = pageNumberstoRender; o.PageNumber = page; o.CountPagesToRender = 1; if (width.HasValue) { o.Width = Convert.ToInt32(width); } if (height.HasValue) { o.Height = Convert.ToInt32(height); } Stream stream = null; DocumentInfoContainer info = handler.GetDocumentInfo(file); // Iterate over the attachments collection foreach (AttachmentBase attachmentBase in info.Attachments.Where(x => x.Name == attachment)) { List <PageImage> pages = handler.GetPages(attachmentBase); foreach (PageImage attachmentPage in pages.Where(x => x.PageNumber == page)) { stream = attachmentPage.Stream; } ; } return(new FileStreamResult(stream, "image/png")); }
public static void InImageRepresentation() { // Setup GroupDocs.Viewer config ViewerConfig config = new ViewerConfig(); config.StoragePath = @"C:\storage"; // Create image handler ViewerImageHandler imageHandler = new ViewerImageHandler(config); string guid = "document.xlsx"; // Set image options to show grid lines ImageOptions options = new ImageOptions(); options.CellsOptions.ShowHiddenSheets = true; DocumentInfoContainer container = imageHandler.GetDocumentInfo(new DocumentInfoOptions(guid)); foreach (PageData page in container.Pages) Console.WriteLine("Page number: {0}, Page Name: {1}, IsVisible: {2}", page.Number, page.Name, page.IsVisible); List<PageImage> pages = imageHandler.GetPages(guid, options); foreach (PageImage page in pages) { Console.WriteLine("Page number: {0}", page.PageNumber); // Page image stream Stream imageContent = page.Stream; } }
protected void Page_Load(object sender, EventArgs e) { var htmlConfig = new ViewerConfig { StoragePath = _storagePath, UseCache = true }; _htmlHandler = new ViewerHtmlHandler(htmlConfig); var imageConfig = new ViewerConfig { StoragePath = _storagePath, UseCache = true, UsePdf = true }; _imageHandler = new ViewerImageHandler(imageConfig); HttpContext.Current.Session["imageHandler"] = _imageHandler; HttpContext.Current.Session["htmlHandler"] = _htmlHandler; // _streams.Add("Stream1.pdf", HttpWebRequest.Create("http://unfccc.int/resource/docs/convkp/kpeng.pdf").GetResponse().GetResponseStream()); //_streams.Add("StreamExample_2.doc", HttpWebRequest.Create("http://www.acm.org/sigs/publications/pubform.doc").GetResponse().GetResponseStream()); }
protected void Page_Load(object sender, EventArgs e) { var file = GetValueFromQueryString("file"); int page = Convert.ToInt32(GetValueFromQueryString("page")); int?width = Convert.ToInt32(GetValueFromQueryString("width")); int?height = Convert.ToInt32(GetValueFromQueryString("width")); if (Utils.IsValidUrl(file)) { file = Utils.DownloadToStorage(file); } string watermarkText = GetValueFromQueryString("watermarkText"); int? watermarkColor = Convert.ToInt32(GetValueFromQueryString("watermarkColor")); WatermarkPosition watermarkPosition = (WatermarkPosition)Enum.Parse(typeof(WatermarkPosition), GetValueFromQueryString("watermarkPosition"), true); string widthFromQuery = GetValueFromQueryString("watermarkWidth"); int? watermarkWidth = GetValueFromQueryString("watermarkWidth") == "null" ? null : (int?)Convert.ToInt32(GetValueFromQueryString("watermarkWidth")); byte watermarkOpacity = Convert.ToByte(GetValueFromQueryString("watermarkOpacity")); ViewerImageHandler handler = Utils.CreateViewerImageHandler(); ImageOptions o = new ImageOptions(); List <int> pageNumberstoRender = new List <int>(); pageNumberstoRender.Add(page); o.PageNumbersToRender = pageNumberstoRender; o.PageNumber = page; o.CountPagesToRender = 1; if (width.HasValue) { o.Width = Convert.ToInt32(width); } if (height.HasValue) { o.Height = Convert.ToInt32(height); } if (watermarkText != "") { o.Watermark = Utils.GetWatermark(watermarkText, watermarkColor, watermarkPosition, watermarkWidth, watermarkOpacity); } Stream stream = null; List <PageImage> list = Utils.LoadPageImageList(handler, file, o); foreach (PageImage pageImage in list.Where(x => x.PageNumber == page)) { stream = pageImage.Stream; } ; var result = new HttpResponseMessage(HttpStatusCode.OK); System.Drawing.Image image = System.Drawing.Image.FromStream(stream); MemoryStream memoryStream = new MemoryStream(); image.Save(memoryStream, ImageFormat.Jpeg); HttpContext.Current.Response.ContentType = "image/jpeg"; memoryStream.WriteTo(HttpContext.Current.Response.OutputStream); HttpContext.Current.Response.Flush(); HttpContext.Current.Response.End(); }
static void Main(string[] args) { SetLicense(); string executionDirectory = Path.GetDirectoryName( System.Reflection.Assembly.GetExecutingAssembly().Location); ViewerConfig viewerConfig = new ViewerConfig(); viewerConfig.StoragePath = executionDirectory; viewerConfig.UsePdf = true; ViewerImageHandler viewerImageHandler = new ViewerImageHandler(viewerConfig); string guid = "Resources\\sample.pdf"; DocumentInfoOptions documentInfoOptions = new DocumentInfoOptions(guid); DocumentInfoContainer documentInfoContainer = viewerImageHandler.GetDocumentInfo(documentInfoOptions); foreach (PageData pageData in documentInfoContainer.Pages) { Console.WriteLine("Page number: " + pageData.Number); for (int i = 0; i < pageData.Rows.Count; i++) { RowData rowData = pageData.Rows[i]; Console.WriteLine("Row: " + (i + 1)); Console.WriteLine("Text: " + rowData.Text); Console.WriteLine("Text width: " + rowData.LineWidth); Console.WriteLine("Text height: " + rowData.LineHeight); Console.WriteLine("Distance from left: " + rowData.LineLeft); Console.WriteLine("Distance from top: " + rowData.LineTop); string[] words = rowData.Text.Split(' '); for (int j = 0; j < words.Length; j++) { int coordinateIndex = j == 0 ? 0 : j + 1; Console.WriteLine(string.Empty); Console.WriteLine("Word: '" + words[j] + "'"); Console.WriteLine("Word distance from left: " + rowData.TextCoordinates[coordinateIndex]); Console.WriteLine("Word width: " + rowData.TextCoordinates[coordinateIndex + 1]); Console.WriteLine(string.Empty); } } Console.WriteLine(string.Empty); } Console.ReadKey(); }
public static List <PageImage> LoadPageImageList(ViewerImageHandler handler, String filename, ImageOptions options) { try { return(handler.GetPages(filename, options)); } catch (Exception x) { throw x; } }
public ViewerController() { _config = new ViewerConfig { StoragePath = _storagePath, TempPath = _tempPath, UseCache = true }; _htmlHandler = new ViewerHtmlHandler(_config); _imageHandler = new ViewerImageHandler(_config); }
public ViewerController() { _config = new ViewerConfig { StoragePath = _storagePath, TempPath = _tempPath, UseCache = true }; _htmlHandler = new ViewerHtmlHandler(_config); _imageHandler = new ViewerImageHandler(_config); }
/// <summary> /// document in image representation and reorder a page /// </summary> /// <param name="DocumentName">file/document name</param> /// <param name="CurrentPageNumber">Page existing order number</param> /// <param name="NewPageNumber">Page new order number</param> /// <param name="DocumentPassword">Password Parameter is optional</param> public static List <ImageInfo> RenderDocumentAsImages(String DocumentName, int CurrentPageNumber, int NewPageNumber, String DocumentPassword = null) { //ExStart:RenderAsImageAndReorderPage //Get Configurations ViewerConfig config = Utilities.GetConfigurations(); // Cast ViewerHtmlHandler class object to its base class(ViewerHandler). ViewerHandler <PageImage> handler = new ViewerImageHandler(config); // Guid implies that unique document name string guid = DocumentName; //Initialize ImageOptions Object and setting Reorder Transformation ImageOptions options = new ImageOptions { Transformations = Transformation.Reorder }; // Set password if document is password protected. if (!String.IsNullOrEmpty(DocumentPassword)) { options.Password = DocumentPassword; } //Call ReorderPage and pass the reference of ViewerHandler's class parameter by reference. Utilities.PageTransformations.ReorderPage(ref handler, guid, CurrentPageNumber, NewPageNumber); //down cast the handler(ViewerHandler) to viewerHtmlHandler ViewerImageHandler imageHandler = (ViewerImageHandler)handler; //Get document pages in image form List <PageImage> Images = imageHandler.GetPages(guid, options); List <ImageInfo> contents = new List <ImageInfo>(); foreach (PageImage image in Images) { string imgname = image.PageNumber + "_" + Path.GetFileNameWithoutExtension(DocumentName); imgname = Regex.Replace(imgname, @"\s+", "_"); Utilities.SaveAsImage(Path.GetDirectoryName(DocumentName), imgname, image.Stream); ImageInfo imageInfo = new ImageInfo(); imageInfo.ImageUrl = @"/Uploads/images/" + imgname + ".jpg?" + Guid.NewGuid().ToString(); imageInfo.PageNmber = image.PageNumber; imageInfo.HtmlContent = @"<div class='image_page'><img src='" + imageInfo.ImageUrl + "' /></div>"; contents.Add(imageInfo); } return(contents); //ExEnd:RenderAsImageAndReorderPage }
/// <summary> /// Rotate page in Image mode /// </summary> public static void Reorder_Pages_In_Image_Mode() { Console.WriteLine("***** {0} *****", "Reorder pages in Image mode"); /* ********************* SAMPLE ********************* */ /* ******************** Reorder 1st and 2nd pages *********************** */ // Setup GroupDocs.Viewer config ViewerConfig config = new ViewerConfig(); config.StoragePath = @"C:\storage"; // Create image handler ViewerImageHandler imageHandler = new ViewerImageHandler(config); string guid = "word.doc"; int pageNumber = 1; int newPosition = 2; // Perform page reorder ReorderPageOptions options = new ReorderPageOptions(guid, pageNumber, newPosition); imageHandler.ReorderPage(options); /* ******************** Retrieve all document pages including transformation *********************** */ // Set image options to include reorder transformations ImageOptions imageOptions = new ImageOptions { Transformations = Transformation.Reorder }; // Get image representation of all document pages, including reorder transformations List<PageImage> pages = imageHandler.GetPages(guid, imageOptions); /* ******************** Retrieve all document pages excluding transformation *********************** */ // Set image options NOT to include ANY transformations ImageOptions noTransformationsOptions = new ImageOptions { Transformations = Transformation.None // This is by default }; // Get image representation of all document pages, without transformations List<PageImage> pagesWithoutTransformations = imageHandler.GetPages(guid, noTransformationsOptions); // Get image representation of all document pages, without transformations List<PageImage> pagesWithoutTransformations2 = imageHandler.GetPages(guid); }
/// <summary> /// Render a document as it is (original form) /// </summary> /// <param name="DocumentName"></param> public static void RenderDocumentAsOriginal(String DocumentName) { //ExStart:RenderOriginal // Create image handler ViewerImageHandler imageHandler = new ViewerImageHandler(Utilities.GetConfigurations()); // Guid implies that unique document name string guid = DocumentName; // Get original file FileContainer container = imageHandler.GetFile(guid); //Save each image at disk Utilities.SaveAsImage(DocumentName, container.Stream); //ExEnd:RenderOriginal }
/// <summary> /// Render document in image representation with watermark /// </summary> /// <param name="DocumentName">file/document name</param> /// <param name="WatermarkText">watermark text</param> /// <param name="WatermarkColor"> System.Drawing.Color</param> /// <param name="position">Watermark Position is optional parameter. Default value is WatermarkPosition.Diagonal</param> /// <param name="WatermarkWidth"> width of watermark as integer. it is optional Parameter default value is 100</param> /// <param name="DocumentPassword">Password Parameter is optional</param> public static List <ImageInfo> RenderDocumentAsImages(String DocumentName, String WatermarkText, Color WatermarkColor, int WatermarkWidth = 100, String DocumentPassword = null) { //ExStart:RenderAsImageWithWaterMark //Get Configurations ViewerConfig config = Utilities.GetConfigurations(); // Create image handler ViewerImageHandler imageHandler = new ViewerImageHandler(config); // Guid implies that unique document name string guid = DocumentName; //Initialize ImageOptions Object ImageOptions options = new ImageOptions(); // Set password if document is password protected. if (!String.IsNullOrEmpty(DocumentPassword)) { options.Password = DocumentPassword; } // Call AddWatermark and pass the reference of ImageOptions object as 1st parameter Utilities.PageTransformations.AddWatermark(ref options, WatermarkText, WatermarkColor, WatermarkPosition.Diagonal, WatermarkWidth); //Get document pages in image form List <PageImage> Images = imageHandler.GetPages(guid, options); List <ImageInfo> contents = new List <ImageInfo>(); foreach (PageImage image in Images) { string imgname = image.PageNumber + "_" + Path.GetFileNameWithoutExtension(DocumentName); imgname = Regex.Replace(imgname, @"\s+", "_"); Utilities.SaveAsImage(Path.GetDirectoryName(DocumentName), imgname, image.Stream); ImageInfo imageInfo = new ImageInfo(); imageInfo.ImageUrl = @"/Uploads/images/" + imgname + ".jpg?" + Guid.NewGuid().ToString(); imageInfo.PageNmber = image.PageNumber; imageInfo.HtmlContent = @"<div class='image_page'><img src='" + imageInfo.ImageUrl + "' /></div>"; contents.Add(imageInfo); } return(contents); //ExEnd:RenderAsImageWithWaterMark }
public static void Run() { //Initialize viewer config ViewerConfig viewerConfig = new ViewerConfig(); viewerConfig.StoragePath = "c:\\storage"; //Initialize viewer handler ViewerImageHandler viewerImageHandler = new ViewerImageHandler(viewerConfig); //Set encoding Encoding encoding = Encoding.GetEncoding("shift-jis"); //Set image options ImageOptions imageOptions = new ImageOptions(); imageOptions.WordsOptions.Encoding = encoding; imageOptions.CellsOptions.Encoding = encoding; imageOptions.EmailOptions.Encoding = encoding; //Get words document pages with encoding string wordsDocumentGuid = "document.txt"; List<PageImage> wordsDocumentPages = viewerImageHandler.GetPages(wordsDocumentGuid, imageOptions); //Get cells document pages with encoding string cellsDocumentGuid = "document.csv"; List<PageImage> cellsDocumentPages = viewerImageHandler.GetPages(cellsDocumentGuid, imageOptions); //Get email document pages with encoding string emailDocumentGuid = "document.msg"; List<PageImage> emailDocumentPages = viewerImageHandler.GetPages(emailDocumentGuid, imageOptions); //Get words document info with encoding DocumentInfoOptions wordsDocumentInfoOptions = new DocumentInfoOptions(wordsDocumentGuid); wordsDocumentInfoOptions.WordsDocumentInfoOptions.Encoding = encoding; DocumentInfoContainer wordsDocumentInfoContainer = viewerImageHandler.GetDocumentInfo(wordsDocumentInfoOptions); //Get cells document info with encoding DocumentInfoOptions cellsDocumentInfoOptions = new DocumentInfoOptions(cellsDocumentGuid); cellsDocumentInfoOptions.CellsDocumentInfoOptions.Encoding = encoding; DocumentInfoContainer cellsDocumentInfoContainer = viewerImageHandler.GetDocumentInfo(cellsDocumentInfoOptions); //Get email document info with encoding DocumentInfoOptions emailDocumentInfoOptions = new DocumentInfoOptions(emailDocumentGuid); emailDocumentInfoOptions.EmailDocumentInfoOptions.Encoding = encoding; DocumentInfoContainer emailDocumentInfoContainer = viewerImageHandler.GetDocumentInfo(emailDocumentInfoOptions); }
/// <summary> /// Get all supported document formats /// </summary> public static void ShowAllSupportedFormats() { // Setup GroupDocs.Viewer config ViewerConfig config = Utilities.GetConfigurations(); // Create image or html handler ViewerImageHandler imageHandler = new ViewerImageHandler(config); // Get supported document formats DocumentFormatsContainer documentFormatsContainer = imageHandler.GetSupportedDocumentFormats(); Dictionary <string, string> supportedDocumentFormats = documentFormatsContainer.SupportedDocumentFormats; foreach (KeyValuePair <string, string> supportedDocumentFormat in supportedDocumentFormats) { Console.WriteLine(string.Format("Extension: '{0}'; Document format: '{1}'", supportedDocumentFormat.Key, supportedDocumentFormat.Value)); } Console.ReadKey(); }
/// <summary> /// Get document representation from Uri /// </summary> public static void Get_pages_from_Uri() { Console.WriteLine("***** {0} *****", "Get document representation from Uri"); /* ********************* SAMPLE ********************* */ // Setup GroupDocs.Viewer config ViewerConfig config = new ViewerConfig(); config.StoragePath = @"C:\storage"; // Create image handler ViewerImageHandler imageHandler = new ViewerImageHandler(config); Uri uri = new Uri("http://groupdocs.com/images/banner/carousel2/signature.png"); // Get pages by absolute path List<PageImage> pages = imageHandler.GetPages(uri); Console.WriteLine("Page count: {0}", pages.Count); }
protected void Page_Load(object sender, EventArgs e) { License lic = new License(); lic.SetLicense("E:/GroupDocs.Total.lic"); _config = new ViewerConfig { StoragePath = _storagePath, TempPath = _tempPath, UseCache = true }; _htmlHandler = new ViewerHtmlHandler(_config); _imageHandler = new ViewerImageHandler(_config); HttpContext.Current.Session["imageHandler"] = _imageHandler; HttpContext.Current.Session["htmlHandler"] = _htmlHandler; }
public static void Run() { // Setup GroupDocs.Viewer config ViewerConfig config = new ViewerConfig(); config.StoragePath = @"C:\storage"; // Create image or html handler ViewerImageHandler imageHandler = new ViewerImageHandler(config); // Get supported document formats DocumentFormatsContainer documentFormatsContainer = imageHandler.GetSupportedDocumentFormats(); Dictionary<string, string> supportedDocumentFormats = documentFormatsContainer.SupportedDocumentFormats; foreach (KeyValuePair<string, string> supportedDocumentFormat in supportedDocumentFormats) { Console.WriteLine(string.Format("Extension: '{0}'; Document format: '{1}'", supportedDocumentFormat.Key, supportedDocumentFormat.Value)); } }
public HttpResponseMessage Get(int?width, string file, string attachment, int page, string watermarkText, int?watermarkColor, WatermarkPosition?watermarkPosition, int?watermarkWidth, byte watermarkOpacity, int?height = null) { ViewerImageHandler handler = Utils.CreateViewerImageHandler(); ImageOptions o = new ImageOptions(); List <int> pageNumberstoRender = new List <int>(); pageNumberstoRender.Add(page); o.PageNumbersToRender = pageNumberstoRender; o.PageNumber = page; o.CountPagesToRender = 1; if (width.HasValue) { o.Width = Convert.ToInt32(width); } if (height.HasValue) { o.Height = Convert.ToInt32(height); } if (watermarkText != "") { o.Watermark = Utils.GetWatermark(watermarkText, watermarkColor, watermarkPosition, watermarkWidth, watermarkOpacity); } Stream stream = null; DocumentInfoContainer info = handler.GetDocumentInfo(file); // Iterate over the attachments collection foreach (AttachmentBase attachmentBase in info.Attachments.Where(x => x.Name == attachment)) { List <PageImage> pages = handler.GetPages(attachmentBase, o); foreach (PageImage attachmentPage in pages.Where(x => x.PageNumber == page)) { stream = attachmentPage.Stream; } ; } var result = new HttpResponseMessage(HttpStatusCode.OK); Image image = Image.FromStream(stream); MemoryStream memoryStream = new MemoryStream(); image.Save(memoryStream, ImageFormat.Jpeg); result.Content = new ByteArrayContent(memoryStream.ToArray()); result.Content.Headers.ContentType = new MediaTypeHeaderValue("image/jpeg"); return(result); }
/// <summary> /// Get original file /// </summary> public static void Run() { Console.WriteLine("***** {0} *****", "Get original file"); /* ********************* SAMPLE ********************* */ // Setup GroupDocs.Viewer config ViewerConfig config = new ViewerConfig(); config.StoragePath = @"C:\storage"; // Create image handler ViewerImageHandler imageHandler = new ViewerImageHandler(config); string guid = "word.doc"; // Get original file FileContainer container = imageHandler.GetFile(guid); Console.WriteLine("Stream lenght: {0}", container.Stream.Length); }
/// <summary> /// Render a document in PDF Form /// </summary> /// <param name="DocumentName"></param> public static void RenderDocumentAsPDF(String DocumentName) { //ExStart:RenderAsPdf // Create/initialize image handler ViewerImageHandler imageHandler = new ViewerImageHandler(Utilities.GetConfigurations()); //Initialize PdfFileOptions object PdfFileOptions options = new PdfFileOptions(); // Call GetPdfFile to get FileContainer type object which contains the stream of pdf file. FileContainer container = imageHandler.GetPdfFile(DocumentName, options); //Change the extension of the file and assign to a string type variable filename String filename = Path.GetFileNameWithoutExtension(DocumentName) + ".pdf"; //Save each image at disk Utilities.SaveFile(filename, container.Stream); //ExEnd:RenderAsPdf }
protected void Page_Load(object sender, EventArgs e) { var file = GetValueFromQueryString("file"); int page = Convert.ToInt32(GetValueFromQueryString("page")); int?width = Convert.ToInt32(GetValueFromQueryString("width")); int?height = Convert.ToInt32(GetValueFromQueryString("width")); ViewerImageHandler handler = Utils.CreateViewerImageHandler(); ImageOptions o = new ImageOptions(); List <int> pageNumberstoRender = new List <int>(); pageNumberstoRender.Add(page); o.PageNumbersToRender = pageNumberstoRender; o.PageNumber = page; o.CountPagesToRender = 1; if (width.HasValue) { o.Width = Convert.ToInt32(width); } if (height.HasValue) { o.Height = Convert.ToInt32(height); } Stream stream = null; List <PageImage> list = Utils.LoadPageImageList(handler, file, o); foreach (PageImage pageImage in list.Where(x => x.PageNumber == page)) { stream = pageImage.Stream; } ; var result = new HttpResponseMessage(HttpStatusCode.OK); System.Drawing.Image image = System.Drawing.Image.FromStream(stream); MemoryStream memoryStream = new MemoryStream(); image.Save(memoryStream, ImageFormat.Jpeg); HttpContext.Current.Response.ContentType = "image/jpeg"; memoryStream.WriteTo(HttpContext.Current.Response.OutputStream); HttpContext.Current.Response.Flush(); HttpContext.Current.Response.End(); }
/// <summary> /// Get document representation from relative path /// </summary> public static void Get_pages_relative_path() { Console.WriteLine("***** {0} *****", "Get document representation from relative path"); /* ********************* SAMPLE ********************* */ // Setup GroupDocs.Viewer config ViewerConfig config = new ViewerConfig(); config.StoragePath = @"C:\storage"; // Create image handler ViewerImageHandler imageHandler = new ViewerImageHandler(config); // Set relative path. So that full path will be C:\storage\word.doc string guid = "word.doc"; // Get pages by absolute path List<PageImage> pages = imageHandler.GetPages(guid); Console.WriteLine("Page count: {0}", pages.Count); }
/// <summary> /// Multiple pages per sheet /// </summary> /// <param name="DocumentName"></param> public static void RenderMultiExcelSheetsInOnePage(String DocumentName) { // Setup GroupDocs.Viewer config ViewerConfig config = Utilities.GetConfigurations(); // Create image or html handler ViewerImageHandler imageHandler = new ViewerImageHandler(config); string guid = DocumentName; // Set pdf file one page per sheet option to false, default value of this option is true PdfFileOptions pdfFileOptions = new PdfFileOptions(); pdfFileOptions.Guid = guid; pdfFileOptions.CellsOptions.OnePagePerSheet = false; //Get pdf file FileContainer fileContainer = imageHandler.GetPdfFile(pdfFileOptions); Utilities.SaveFile("test.pdf", fileContainer.Stream); }
/// <summary> /// Get document html for print with watermark /// </summary> public static void Get_PrintableHtml_WithWatermark() { Console.WriteLine("***** {0} *****", "Get document html for print with watermark"); /* ********************* SAMPLE ********************* */ // Setup GroupDocs.Viewer config ViewerConfig config = new ViewerConfig(); config.StoragePath = @"C:\storage"; // Create image handler ViewerImageHandler imageHandler = new ViewerImageHandler(config); string guid = "word.doc"; // Get document html for print with watermark var options = new PrintableHtmlOptions(guid, new Watermark("Watermark text")); var container = imageHandler.GetPrintableHtml(options); Console.WriteLine("Html content: {0}", container.HtmlContent); }
/// <summary> /// Remove cache file older than specified date /// </summary> public static void RemoveCacheFiles(TimeSpan OlderThanDays) { try { //ExStart:RemoveCacheFilesTimeSpan // Setup GroupDocs.Viewer config ViewerConfig config = Utilities.GetConfigurations(); // Init viewer image or html handler ViewerImageHandler viewerImageHandler = new ViewerImageHandler(config); //Clear files from cache older than specified time interval viewerImageHandler.ClearCache(OlderThanDays); //ExEnd:RemoveCacheFilesTimeSpan } catch (System.Exception exp) { Console.WriteLine(exp.Message); } }
/// <summary> /// Get original file in Pdf format /// </summary> public static void Run() { Console.WriteLine("***** {0} *****", "Get original file in Pdf format"); /* ********************* SAMPLE ********************* */ // Setup GroupDocs.Viewer config ViewerConfig config = new ViewerConfig(); config.StoragePath = @"C:\storage"; // Create image handler ViewerImageHandler imageHandler = new ViewerImageHandler(config); PdfFileOptions options = new PdfFileOptions(); options.Guid = "word.doc"; // Get file as pdf FileContainer container = imageHandler.GetPdfFile(options); Console.WriteLine("Stream lenght: {0}", container.Stream.Length); }
public ViewerController() { var htmlConfig = new ViewerConfig { StoragePath = _storagePath, CachePath = _cachePath, UseCache = true }; _htmlHandler = new ViewerHtmlHandler(htmlConfig); var imageConfig = new ViewerConfig { StoragePath = _storagePath, CachePath = _cachePath, UseCache = true, UsePdf = UsePdfInImageEngine }; _imageHandler = new ViewerImageHandler(imageConfig); }
public ViewerController() { var htmlConfig = new ViewerConfig { StoragePath = _storagePath, CachePath = _cachePath, UseCache = true }; _htmlHandler = new ViewerHtmlHandler(htmlConfig); var imageConfig = new ViewerConfig { StoragePath = _storagePath, CachePath = _cachePath, UseCache = true, UsePdf = UsePdfInImageEngine }; _imageHandler = new ViewerImageHandler(imageConfig); }
public QuickViewApiController() { quickViewConfig = new QuickViewConfig(); // create viewer application configuration ViewerConfig config = new ViewerConfig(); config.StoragePath = quickViewConfig.getApplication().getFilesDirectory(); config.EnableCaching = true; List <String> fontsDirectory = new List <String>(); fontsDirectory.Add(quickViewConfig.getApplication().getFontsDirectory()); config.FontDirectories = fontsDirectory; // set GroupDocs license License license = new License(); license.SetLicense(quickViewConfig.getApplication().getLicensePath()); // initialize viewer instance for the HTML mode viewerHtmlHandler = new ViewerHtmlHandler(config); // initialize viewer instance for the Image mode viewerImageHandler = new ViewerImageHandler(config); }
/// <summary> /// Get document html for print with custom css /// </summary> public static void Get_PrintableHtml_WithCss() { Console.WriteLine("***** {0} *****", "Get document html for print with custom css"); /* ********************* SAMPLE ********************* */ // Setup GroupDocs.Viewer config ViewerConfig config = new ViewerConfig(); config.StoragePath = @"C:\storage"; // Create image handler ViewerImageHandler imageHandler = new ViewerImageHandler(config); string guid = "word.doc"; string css = "a { color: hotpink; }"; // Some style // Get document html for print with custom css var options = new PrintableHtmlOptions(guid, css); var container = imageHandler.GetPrintableHtml(options); Console.WriteLine("Html content: {0}", container.HtmlContent); }
public static void Run() { // Setup GroupDocs.Viewer config ViewerConfig config = new ViewerConfig(); config.StoragePath = @"C:\storage"; // Create image or html handler ViewerImageHandler imageHandler = new ViewerImageHandler(config); string guid = "document.xlsx"; // Set pdf file one page per sheet option to false, default value of this option is true PdfFileOptions pdfFileOptions = new PdfFileOptions(); pdfFileOptions.Guid = guid; pdfFileOptions.CellsOptions.OnePagePerSheet = false; //Get pdf file FileContainer fileContainer = imageHandler.GetPdfFile(pdfFileOptions); //The pdf file stream Stream pdfStream = fileContainer.Stream; }
/// <summary> /// Render the document in image form and set the rotation angle to rotate the page while display. /// </summary> /// <param name="DocumentName"></param> /// <param name="RotationAngle">rotation angle in digits</param> /// <param name="DocumentPassword"></param> public static void RenderDocumentAsImages(String DocumentName, int RotationAngle, String DocumentPassword = null) { //ExStart:RenderAsImageWithRotationTransformation //Get Configurations ViewerConfig config = Utilities.GetConfigurations(); // Create image handler ViewerHandler <PageImage> handler = new ViewerImageHandler(config); // Guid implies that unique document name string guid = DocumentName; //Initialize ImageOptions Object and setting Rotate Transformation ImageOptions options = new ImageOptions { Transformations = Transformation.Rotate }; // Set password if document is password protected. if (!String.IsNullOrEmpty(DocumentPassword)) { options.Password = DocumentPassword; } //Call RotatePages to apply rotate transformation to a page Utilities.PageTransformations.RotatePages(ref handler, guid, 1, RotationAngle); //down cast the handler(ViewerHandler) to viewerHtmlHandler ViewerImageHandler imageHandler = (ViewerImageHandler)handler; //Get document pages in image form List <PageImage> Images = imageHandler.GetPages(guid, options); foreach (PageImage image in Images) { //Save each image at disk Utilities.SaveAsImage(image.PageNumber + "_" + DocumentName, image.Stream); } //ExEnd:RenderAsImageWithRotationTransformation }
/// <summary> /// document in image representation and reorder a page /// </summary> /// <param name="DocumentName">file/document name</param> /// <param name="CurrentPageNumber">Page existing order number</param> /// <param name="NewPageNumber">Page new order number</param> /// <param name="DocumentPassword">Password Parameter is optional</param> public static void RenderDocumentAsImages(String DocumentName, int CurrentPageNumber, int NewPageNumber, String DocumentPassword = null) { //ExStart:RenderAsImageAndReorderPage //Get Configurations ViewerConfig config = Utilities.GetConfigurations(); // Cast ViewerHtmlHandler class object to its base class(ViewerHandler). ViewerHandler <PageImage> handler = new ViewerImageHandler(config); // Guid implies that unique document name string guid = DocumentName; //Initialize ImageOptions Object and setting Reorder Transformation ImageOptions options = new ImageOptions { Transformations = Transformation.Reorder }; // Set password if document is password protected. if (!String.IsNullOrEmpty(DocumentPassword)) { options.Password = DocumentPassword; } //Call ReorderPage and pass the reference of ViewerHandler's class parameter by reference. Utilities.PageTransformations.ReorderPage(ref handler, guid, CurrentPageNumber, NewPageNumber); //down cast the handler(ViewerHandler) to viewerHtmlHandler ViewerImageHandler imageHandler = (ViewerImageHandler)handler; //Get document pages in image form List <PageImage> Images = imageHandler.GetPages(guid, options); foreach (PageImage image in Images) { //Save each image at disk Utilities.SaveAsImage(image.PageNumber + "_" + DocumentName, image.Stream); } //ExEnd:RenderAsImageAndReorderPage }
/// <summary> /// Perform multiple transformations in Image mode /// </summary> public static void Multiple_Transformations_For_Image() { Console.WriteLine("***** {0} *****", "Perform multiple transformations in Image mode"); /* ********************* SAMPLE ********************* */ // Setup GroupDocs.Viewer config ViewerConfig config = new ViewerConfig(); config.StoragePath = @"C:\storage"; // Create image handler ViewerImageHandler imageHandler = new ViewerImageHandler(config); string guid = "word.doc"; // Rotate first page 90 degrees imageHandler.RotatePage(new RotatePageOptions(guid, 1, 90)); // Rotate second page 180 degrees imageHandler.RotatePage(new RotatePageOptions(guid, 2, 180)); // Reorder first and second pages imageHandler.ReorderPage(new ReorderPageOptions(guid, 1, 2)); // Set options to include rotate and reorder transformations ImageOptions options = new ImageOptions { Transformations = Transformation.Rotate | Transformation.Reorder }; // Set watermark properties Watermark watermark = new Watermark("This is watermark text") { Color = System.Drawing.Color.Blue, Position = WatermarkPosition.Diagonal, Width = 100 }; options.Watermark = watermark; // Get document pages image representation with multiple transformations List<PageImage> pages = imageHandler.GetPages(guid, options); }
/// <summary> /// Load file tree list for custom path /// </summary> public static void LoadFileTree_CustomPath() { Console.WriteLine("***** {0} *****", "Load file tree list for custom path"); /* ********************* SAMPLE ********************* */ // Setup GroupDocs.Viewer config ViewerConfig config = new ViewerConfig(); config.StoragePath = @"C:\storage"; // Create image handler ViewerImageHandler imageHandler = new ViewerImageHandler(config); // Load file tree list for custom path var options = new FileTreeOptions(@"D:\"); FileTreeContainer container = imageHandler.LoadFileTree(options); foreach (var node in container.FileTree) { if (node.IsDirectory) { Console.WriteLine("Guid: {0} | Name: {1} | LastModificationDate: {2}", node.Guid, node.Name, node.LastModificationDate); } else Console.WriteLine("Guid: {0} | Name: {1} | Document type: {2} | File type: {3} | Extension: {4} | Size: {5} | LastModificationDate: {6}", node.Guid, node.Name, node.DocumentType, node.FileType, node.Extension, node.Size, node.LastModificationDate); } }
public ViewerController() { htmlConfig = new ViewerConfig { StoragePath = _storagePath, CachePath = _tempPath, UseCache = true }; _htmlHandler = new ViewerHtmlHandler(htmlConfig); imageConfig = new ViewerConfig { StoragePath = _storagePath, CachePath = _tempPath, UseCache = true }; _imageHandler = new ViewerImageHandler(imageConfig); // _streams.Add("ProcessFileFromStreamExample_1.pdf", HttpWebRequest.Create("http://unfccc.int/resource/docs/convkp/kpeng.pdf").GetResponse().GetResponseStream()); // _streams.Add("ProcessFileFromStreamExample_2.doc", HttpWebRequest.Create("http://www.acm.org/sigs/publications/pubform.doc").GetResponse().GetResponseStream()); }
public static void InImageRepresentation() { // Setup GroupDocs.Viewer config ViewerConfig config = new ViewerConfig(); config.StoragePath = @"C:\storage"; // Create image handler ViewerImageHandler imageHandler = new ViewerImageHandler(config); string guid = "document.xlsx"; // Set image options to show grid lines ImageOptions options = new ImageOptions(); options.CellsOptions.ShowGridLines = true; List<PageImage> pages = imageHandler.GetPages(guid, options); foreach (PageImage page in pages) { Console.WriteLine("Page number: {0}", page.PageNumber); // Page image stream Stream imageContent = page.Stream; } }
/// <summary> /// Load directory structure as file tree /// </summary> /// <param name="Path"></param> public static void LoadFileTree(String Path) { //ExStart:LoadFileTree // Create/initialize image handler ViewerImageHandler imageHandler = new ViewerImageHandler(Utilities.GetConfigurations()); // Load file tree list for custom path var options = new FileTreeOptions(Path); // Load file tree list for ViewerConfig.StoragePath FileTreeContainer container = imageHandler.LoadFileTree(options); foreach (var node in container.FileTree) { if (node.IsDirectory) { Console.WriteLine("Guid: {0} | Name: {1} | LastModificationDate: {2}", node.Guid, node.Name, node.LastModificationDate); } else { Console.WriteLine("Guid: {0} | Name: {1} | Document type: {2} | File type: {3} | Extension: {4} | Size: {5} | LastModificationDate: {6}", node.Guid, node.Name, node.DocumentType, node.FileType, node.Extension, node.Size, node.LastModificationDate); } } //ExEnd:LoadFileTree }
/// <summary> /// Get attached image with email message /// </summary> /// <param name="DocumentName">Input document name</param> public static void GetEmailAttachments(String DocumentName) { try { //ExStart:GetEmailAttachments // Setup GroupDocs.Viewer config ViewerConfig config = Utilities.GetConfigurations(); // Create image handler ViewerImageHandler handler = new ViewerImageHandler(config); EmailAttachment attachment = new EmailAttachment(DocumentName, "attachment-image.png"); // Get attachment original file FileContainer container = handler.GetFile(attachment); Console.WriteLine("Attach name: {0}, Type: {1}", attachment.Name, attachment.FileType); Console.WriteLine("Attach stream lenght: {0}", container.Stream.Length); //ExEnd:GetEmailAttachments } catch (System.Exception exp) { Console.WriteLine(exp.Message); } }
/// <summary> /// Get document Image representation /// </summary> public static void Get_document_Image_representation() { Console.WriteLine("***** {0} *****", "Get document image representation"); /* ********************* SAMPLE ********************* */ // Setup GroupDocs.Viewer config ViewerConfig config = new ViewerConfig(); config.StoragePath = @"C:\storage"; // Create image handler ViewerImageHandler imageHandler = new ViewerImageHandler(config); string guid = "word.doc"; List<PageImage> pages = imageHandler.GetPages(guid); foreach (PageImage page in pages) { Console.WriteLine("Page number: {0}", page.PageNumber); // Page image stream Stream imageContent = page.Stream; } }
/// <summary> /// Get document representation from Stream /// </summary> public static void Get_pages_from_stream() { Console.WriteLine("***** {0} *****", "Get document representation from Stream"); /* ********************* SAMPLE ********************* */ // Setup GroupDocs.Viewer config ViewerConfig config = new ViewerConfig(); config.StoragePath = @"C:\storage"; // Create image handler ViewerImageHandler imageHandler = new ViewerImageHandler(config); using (FileStream fileStream = new FileStream(@"C:\storage\word.doc", FileMode.Open, FileAccess.Read)) { // Get pages by absolute path List<PageImage> pages = imageHandler.GetPages(fileStream, "word.doc"); Console.WriteLine("Page count: {0}", pages.Count); } }
public ActionResult Get(int?width, int?height, string file, int page, string watermarkText, int?watermarkColor, WatermarkPosition?watermarkPosition, int?watermarkWidth, byte watermarkOpacity, int?rotate, int?zoom) { if (Utils.IsValidUrl(file)) { file = Utils.DownloadToStorage(file); } ViewerImageHandler handler = Utils.CreateViewerImageHandler(); if (rotate.HasValue) { if (rotate.Value > 0) { handler.ClearCache(file); } } ImageOptions options = new ImageOptions(); options.PageNumbersToRender = new List <int>(new int[] { page }); options.PageNumber = page; options.CountPagesToRender = 1; if (Path.GetExtension(file).ToLower().StartsWith(".xls")) { options.CellsOptions.OnePagePerSheet = false; options.CellsOptions.CountRowsPerPage = 150; } if (watermarkText != "") { options.Watermark = Utils.GetWatermark(watermarkText, watermarkColor, watermarkPosition, watermarkWidth, watermarkOpacity); } if (width.HasValue) { int w = Convert.ToInt32(width); if (zoom.HasValue) { w = w + zoom.Value; } options.Width = w; } if (height.HasValue) { if (zoom.HasValue) { options.Height = options.Height + zoom.Value; } } if (rotate.HasValue) { if (rotate.Value > 0) { if (width.HasValue) { int side = options.Width; DocumentInfoContainer documentInfoContainer = handler.GetDocumentInfo(file); int pageAngle = documentInfoContainer.Pages[page - 1].Angle; if (pageAngle == 90 || pageAngle == 270) { options.Height = side; } else { options.Width = side; } } options.Transformations = Transformation.Rotate; handler.RotatePage(file, new RotatePageOptions(page, rotate.Value)); } } else { options.Transformations = Transformation.None; handler.RotatePage(file, new RotatePageOptions(page, 0)); } using (new InterProcessLock(file)) { List <PageImage> list = handler.GetPages(file, options); PageImage pageImage = list.Single(_ => _.PageNumber == page); return(File(pageImage.Stream, "image/png")); } }
/// <summary> /// Rotate page in Image mode /// </summary> public static void Rotate_page_in_Image_mode() { Console.WriteLine("***** {0} *****", "Rotate page in Image mode"); /* ********************* SAMPLE ********************* */ string licensePath = @"D:\GroupDocs.Viewer.lic"; // Setup license GroupDocs.Viewer.License lic = new GroupDocs.Viewer.License(); lic.SetLicense(licensePath); /* ******************** SAMPLE BEGIN *********************** */ /* ******************** Rotate 1st page of the document by 90 deg *********************** */ // Setup GroupDocs.Viewer config ViewerConfig config = new ViewerConfig(); config.StoragePath = @"C:\storage"; // Create image handler ViewerImageHandler imageHandler = new ViewerImageHandler(config); string guid = "word.doc"; // Set rotation angle 90 for page number 1 RotatePageOptions rotateOptions = new RotatePageOptions(guid, 1, 90); // Perform page rotation imageHandler.RotatePage(rotateOptions); /* ******************** Retrieve all document pages including transformation *********************** */ // Set image options to include rotate transformations ImageOptions imageOptions = new ImageOptions { Transformations = Transformation.Rotate }; // Get image representation of all document pages, including rotate transformations List<PageImage> pages = imageHandler.GetPages(guid, imageOptions); /* ******************** Retrieve all document pages excluding transformation *********************** */ // Set image options NOT to include ANY transformations ImageOptions noTransformationsOptions = new ImageOptions { Transformations = Transformation.None // This is by default }; // Get image representation of all document pages, without transformations List<PageImage> pagesWithoutTransformations = imageHandler.GetPages(guid, noTransformationsOptions); // Get image representation of all document pages, without transformations List<PageImage> pagesWithoutTransformations2 = imageHandler.GetPages(guid); /********************* SAMPLE END *************************/ //foreach (PageImage page in pages) //{ // // Page number // Console.WriteLine("Page number: {0}", page.PageNumber); // // Page image stream // Stream imageContent = page.Stream; // using ( // FileStream file = new FileStream(string.Format(@"C:\{0}.png", page.PageNumber), // FileMode.Create, FileAccess.ReadWrite)) // { // MemoryStream xxx = new MemoryStream(); // page.Stream.CopyTo(xxx); // var arr = xxx.ToArray(); // file.Write(arr, 0, arr.Length); // } //} }