public HttpResponseMessage RotateDocumentPages(PostedDataWrapper postedData)
 {
     try
     {
         // get/set parameters
         String     documentGuid = postedData.guid;
         int        angle        = postedData.angle;
         List <int> pages        = postedData.pages;
         bool       htmlMode     = postedData.htmlMode;
         string     password     = postedData.password;
         // a list of the rotated pages info
         List <RotatedPageWrapper> rotatedPages = new List <RotatedPageWrapper>();
         // rotate pages
         for (int i = 0; i < pages.Count; i++)
         {
             // prepare rotated page info object
             RotatedPageWrapper rotatedPage = new RotatedPageWrapper();
             int pageNumber = pages[i];
             RotatePageOptions rotateOptions = new RotatePageOptions(pageNumber, angle);
             // perform page rotation
             String resultAngle = "0";
             // set password for protected document
             if (!String.IsNullOrEmpty(password))
             {
                 rotateOptions.Password = password;
             }
             if (htmlMode)
             {
                 viewerHtmlHandler.RotatePage(documentGuid, rotateOptions);
                 resultAngle = viewerHtmlHandler.GetDocumentInfo(documentGuid).Pages[pageNumber - 1].Angle.ToString();
             }
             else
             {
                 viewerImageHandler.RotatePage(documentGuid, rotateOptions);
                 resultAngle = viewerImageHandler.GetDocumentInfo(documentGuid).Pages[pageNumber - 1].Angle.ToString();
             }
             // add rotated page number
             rotatedPage.pageNumber = pageNumber;
             // add rotated page angle
             rotatedPage.angle = resultAngle;
             // add rotated page object into resulting list
             rotatedPages.Add(rotatedPage);
         }
         return(Request.CreateResponse(HttpStatusCode.OK, rotatedPages));
     }
     catch (Exception ex)
     {
         // set exception message
         ErrorMsgWrapper errorMsgWrapper = new ErrorMsgWrapper();
         errorMsgWrapper.message   = ex.Message;
         errorMsgWrapper.exception = ex;
         return(Request.CreateResponse(HttpStatusCode.OK, errorMsgWrapper));
     }
 }
        /// <summary>
        /// Perform multiple transformations in Html mode
        /// </summary>
        public static void Multiple_Transformations_For_Html()
        {
            Console.WriteLine("***** {0} *****", "Perform multiple transformations in Html mode");

            /* ********************* SAMPLE ********************* */

            // Setup GroupDocs.Viewer config
            ViewerConfig config = new ViewerConfig();
            config.StoragePath = @"C:\storage";

            // Create html handler
            ViewerHtmlHandler htmlHandler = new ViewerHtmlHandler(config);
            string guid = "word.doc";

            // Rotate first page 90 degrees
            htmlHandler.RotatePage(new RotatePageOptions(guid, 1, 90));

            // Rotate second page 180 degrees
            htmlHandler.RotatePage(new RotatePageOptions(guid, 2, 180));

            // Reorder first and second pages
            htmlHandler.ReorderPage(new ReorderPageOptions(guid, 1, 2));

            // Set options to include rotate and reorder transformations
            HtmlOptions options = new HtmlOptions { 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 html representation with multiple transformations
            List<PageHtml> pages = htmlHandler.GetPages(guid, options);
        }
        /// <summary>
        /// Rotate page in Html mode
        /// </summary>
        public static void Rotate_Page_In_Html_Mode()
        {
            Console.WriteLine("***** {0} *****", "Rotate page in Html 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 html handler
            ViewerHtmlHandler htmlHandler = new ViewerHtmlHandler(config);
            string guid = "word.doc";

            // Set rotation angle 90 for page number 1
            RotatePageOptions rotateOptions = new RotatePageOptions(guid, 1, 90);

            // Perform page rotation
            htmlHandler.RotatePage(rotateOptions);


            /* ********************  Retrieve all document pages including transformation *********************** */
            // Set html options to include rotate transformations
            HtmlOptions htmlOptions = new HtmlOptions
            {
                Transformations = Transformation.Rotate
            };

            // Get html representation of all document pages, including rotate transformations 
            List<PageHtml> pages = htmlHandler.GetPages(guid, htmlOptions);


            /* ********************  Retrieve all document pages excluding transformation *********************** */
            // Set html options NOT to include ANY transformations
            HtmlOptions noTransformationsOptions = new HtmlOptions
            {
                Transformations = Transformation.None // This is by default
            };

            // Get html representation of all document pages, without transformations 
            List<PageHtml> pagesWithoutTransformations = htmlHandler.GetPages(guid, noTransformationsOptions);

            // Get html representation of all document pages, without transformations
            List<PageHtml> pagesWithoutTransformations2 = htmlHandler.GetPages(guid);

            /*********************  SAMPLE END *************************/
            //foreach (PageHtml page in pages)
            //{
            //    // Page number
            //    Console.WriteLine("Page number: {0}", page.PageNumber);
            //}
        }