GroupDocsGists
10/24/2017 - 7:09 AM

Examples-GroupDocs.Viewer.Examples.CSharp-GroupDocs.Viewer.Examples-ViewGenerator-RenderAsImageWithRotationTransformation.cs

// For complete examples and data files, please go to https://github.com/groupdocsviewer/GroupDocs_Viewer_NET
 //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);
            }