public ActionResult RotatePage(RotatePageParameters parameters) { try { string guid = parameters.Path; int pageIndex = parameters.PageNumber; DocumentInfoContainer documentInfoContainer = _imageHandler.GetDocumentInfo(guid); int pageNumber = documentInfoContainer.Pages[pageIndex].Number; RotatePageOptions rotatePageOptions = new RotatePageOptions(pageNumber, parameters.RotationAmount); _imageHandler.RotatePage(guid, rotatePageOptions); DocumentInfoContainer container = _imageHandler.GetDocumentInfo(guid); PageData pageData = container.Pages.Single(_ => _.Number == pageNumber); RotatePageResponse response = new RotatePageResponse { resultAngle = pageData.Angle }; return(ToJsonResult(response)); } catch (Exception e) { return(this.JsonOrJsonP(new FailedResponse { Reason = e.Message }, null)); } }
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)); } }
public static RotatePageResponse RotatePage(RotatePageParameters parameters) { string guid = parameters.Path; int pageIndex = parameters.PageNumber; DocumentInfoOptions documentInfoOptions = new DocumentInfoOptions(guid); DocumentInfoContainer documentInfoContainer = _imageHandler.GetDocumentInfo(documentInfoOptions); int pageNumber = documentInfoContainer.Pages[pageIndex].Number; RotatePageOptions rotatePageOptions = new RotatePageOptions(guid, pageNumber, parameters.RotationAmount); RotatePageContainer rotatePageContainer = _imageHandler.RotatePage(rotatePageOptions); RotatePageResponse response = new RotatePageResponse { resultAngle = rotatePageContainer.CurrentRotationAngle }; return(response); }
public ActionResult RotatePage(RotatePageParameters parameters) { string guid = parameters.Path; int pageIndex = parameters.PageNumber; DocumentInfoContainer documentInfoContainer = _imageHandler.GetDocumentInfo(guid); int pageNumber = documentInfoContainer.Pages[pageIndex].Number; RotatePageOptions rotatePageOptions = new RotatePageOptions(pageNumber, parameters.RotationAmount); _imageHandler.RotatePage(guid, rotatePageOptions); documentInfoContainer = _imageHandler.GetDocumentInfo(guid); var resultAngle = documentInfoContainer.Pages[pageIndex].Angle; return(ToJsonResult(new RotatePageResponse { resultAngle = resultAngle })); }
public static RotatePageResponse RotatePage(RotatePageParameters parameters) { string guid = parameters.Path; int pageIndex = parameters.PageNumber; DocumentInfoContainer documentInfoContainer = _imageHandler.GetDocumentInfo(guid); int pageNumber = documentInfoContainer.Pages[pageIndex].Number; RotatePageOptions rotatePageOptions = new RotatePageOptions(pageNumber, parameters.RotationAmount); _imageHandler.RotatePage(guid, rotatePageOptions); DocumentInfoContainer container = _imageHandler.GetDocumentInfo(guid); PageData pageData = container.Pages.Single(_ => _.Number == pageNumber); RotatePageResponse response = new RotatePageResponse { resultAngle = pageData.Angle }; return(response); }
/// <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); //} }
/// <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); // } //} }
public ActionResult RotatePage(RotatePageParameters parameters) { string guid = parameters.Path; int pageIndex = parameters.PageNumber; DocumentInfoContainer documentInfoContainer = _imageHandler.GetDocumentInfo(guid); int pageNumber = documentInfoContainer.Pages[pageIndex].Number; RotatePageOptions rotatePageOptions = new RotatePageOptions(guid, pageNumber, parameters.RotationAmount); _imageHandler.RotatePage(rotatePageOptions); documentInfoContainer = _imageHandler.GetDocumentInfo(guid); var resultAngle = documentInfoContainer.Pages[pageIndex].Angle; return ToJsonResult(new RotatePageResponse { resultAngle = resultAngle }); }