Example #1
0
        public static ReorderPageResponse ReorderPage(ReorderPageParameters parameters)
        {
            string guid = parameters.Path;

            DocumentInfoContainer documentInfoContainer = _imageHandler.GetDocumentInfo(guid);

            int pageNumber  = documentInfoContainer.Pages[parameters.OldPosition].Number;
            int newPosition = parameters.NewPosition + 1;

            ReorderPageOptions reorderPageOptions = new ReorderPageOptions(pageNumber, newPosition);

            _imageHandler.ReorderPage(guid, reorderPageOptions);

            return(new ReorderPageResponse());
        }
        /// <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);
        }
Example #3
0
        public ActionResult ReorderPage(ReorderPageParameters parameters)
        {
            string guid = parameters.Path;

            DocumentInfoOptions   documentInfoOptions   = new DocumentInfoOptions(guid);
            DocumentInfoContainer documentInfoContainer = _imageHandler.GetDocumentInfo(documentInfoOptions);

            int pageNumber  = documentInfoContainer.Pages[parameters.OldPosition].Number;
            int newPosition = parameters.NewPosition + 1;

            ReorderPageOptions reorderPageOptions = new ReorderPageOptions(guid, pageNumber, newPosition);

            _imageHandler.ReorderPage(reorderPageOptions);

            return(ToJsonResult(new ReorderPageResponse()));
        }
        /// <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);
        }
        public ActionResult ReorderPage(ReorderPageParameters parameters)
        {
            try
            {
                string guid = parameters.Path;

                DocumentInfoContainer documentInfoContainer = _imageHandler.GetDocumentInfo(guid);

                int pageNumber  = documentInfoContainer.Pages[parameters.OldPosition].Number;
                int newPosition = parameters.NewPosition + 1;

                ReorderPageOptions reorderPageOptions = new ReorderPageOptions(pageNumber, newPosition);
                _imageHandler.ReorderPage(guid, reorderPageOptions);

                return(ToJsonResult(new ReorderPageResponse()));
            }
            catch (Exception e)
            {
                return(this.JsonOrJsonP(new FailedResponse {
                    Reason = e.Message
                }, null));
            }
        }