/// <summary>
        /// Rotates image with annotations.
        /// </summary>
        /// <param name="annotationViewer">The annotation viewer.</param>
        /// <param name="undoManager">The undo manager.</param>
        /// <param name="dataStorage">The data storage.</param>
        public static void RotateImageWithAnnotations(AnnotationViewer annotationViewer, CompositeUndoManager undoManager, IDataStorage dataStorage)
        {
            // cancel annotation building
            annotationViewer.CancelAnnotationBuilding();

            // create rotate image dialog
            using (RotateImageWithAnnotationsForm dialog = new RotateImageWithAnnotationsForm(annotationViewer.Image.PixelFormat))
            {
                // if image with annotation must be rotated
                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    // if undo manager is enabled
                    if (undoManager.IsEnabled)
                    {
                        // begin the composite undo action
                        undoManager.BeginCompositeAction("Rotate image with annotations");

                        // if undo manager does not contain the history for current image
                        if (!undoManager.ContainsActionForSourceObject(annotationViewer.Image))
                        {
                            // create change undo action
                            ChangeImageUndoAction originalImageAction = new ChangeImageUndoAction(dataStorage, annotationViewer.Image);
                            undoManager.AddAction(originalImageAction, null);
                        }
                        try
                        {
                            // create change undo action
                            ChangeImageUndoAction action = new ChangeImageUndoAction(dataStorage, annotationViewer.Image, "Rotate");
                            // clone focused image
                            using (VintasoftImage previousImage = (VintasoftImage)annotationViewer.Image.Clone())
                            {
                                // rotate focused image with annotations
                                RotateFocusedImageWithAnnotations(annotationViewer, (float)dialog.Angle, dialog.BorderColorType, dialog.SourceImagePixelFormat);

                                // add action to the undo manager
                                undoManager.AddAction(action, previousImage);
                            }
                        }
                        finally
                        {
                            // end the composite undo action
                            undoManager.EndCompositeAction();
                        }
                    }
                    else
                    {
                        // rotate focused image with annotations
                        RotateFocusedImageWithAnnotations(annotationViewer, (float)dialog.Angle, dialog.BorderColorType, dialog.SourceImagePixelFormat);
                    }
                }
            }
        }
        /// <summary>
        /// Burns annotations on image.
        /// </summary>
        /// <param name="annotationViewer">The annotation viewer.</param>
        /// <param name="undoManager">The undo manager.</param>
        /// <param name="dataStorage">The data storage.</param>
        public static void BurnAnnotationsOnImage(AnnotationViewer annotationViewer, CompositeUndoManager undoManager, IDataStorage dataStorage)
        {
            // cancel annotation building
            annotationViewer.CancelAnnotationBuilding();

            // if focused image is not correct
            if (!CheckImage(annotationViewer))
            {
                return;
            }

            // get focused image
            VintasoftImage sourceImage = annotationViewer.Image;

#if !REMOVE_PDF_PLUGIN
            // if focused image is PDF vector image
            if (sourceImage.IsVectorImage && sourceImage.SourceInfo.Decoder is PdfDecoder)
            {
                // get PDF page
                PdfPage page = PdfDocumentController.GetPageAssociatedWithImage(sourceImage);
                // if focused PDF page contains vector content
                if (!page.IsImageOnly)
                {
                    DialogResult result = MessageBox.Show(string.Format("{0}\n\n{1}\n\n{2}\n\n{3}",
                                                                        "This page is a vector page of PDF document. How annotations should be drawn on the page?",
                                                                        "Press 'Yes' if you want convert annotations to PDF annotations and draw annotations on PDF page in a vector form.",
                                                                        "Press 'No' if you want rasterize PDF page and draw annotations on raster image in raster form.",
                                                                        "Press 'Cancel' to cancel burning."),
                                                          "Burn Annotations", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning);
                    if (result == DialogResult.Yes)
                    {
                        // burn vector annotations
                        BurnPdfAnnotations(
                            annotationViewer.AnnotationDataCollection,
                            sourceImage.Resolution,
                            page);
                        // remove annotations
                        annotationViewer.AnnotationDataCollection.ClearAndDisposeItems();
                        // reload focused image
                        sourceImage.Reload(true);
                        return;
                    }
                    if (result == DialogResult.Cancel)
                    {
                        return;
                    }
                }
            }
#endif
            // if undo manager is enabled
            if (undoManager.IsEnabled)
            {
                // create focused image copy
                using (VintasoftImage image = (VintasoftImage)sourceImage.Clone())
                {
                    // begin the composite undo action
                    undoManager.BeginCompositeAction("Burn annotations on image");

                    // if undo manager does not contain the history for current image
                    if (!undoManager.ContainsActionForSourceObject(sourceImage))
                    {
                        // create change undo action
                        ChangeImageUndoAction originalImageAction = new ChangeImageUndoAction(dataStorage, sourceImage);
                        undoManager.AddAction(originalImageAction, null);
                    }
                    try
                    {
                        // burn annotations on focused image
                        annotationViewer.AnnotationViewController.BurnAnnotationCollectionOnImage(annotationViewer.FocusedIndex);
                        // create change undo action
                        ChangeImageUndoAction action = new ChangeImageUndoAction(dataStorage, sourceImage, "Burn annotations on image");
                        undoManager.AddAction(action, image);
                    }
                    finally
                    {
                        // end the composite undo action
                        undoManager.EndCompositeAction();
                    }
                }
            }
            else
            {
                // burn annotations on focused image
                annotationViewer.AnnotationViewController.BurnAnnotationCollectionOnImage(annotationViewer.FocusedIndex);
            }
        }