Пример #1
0
        internal static IDisposable SaveClip(FixedContentEditor drawingSurface, Rect rectangle)
        {
            PathGeometry geometry    = MathHelper.TransformRectangle(drawingSurface.Position.Matrix, rectangle);
            var          pdfGeometry = PdfGeometryHelper.ConvertPathGeometry(geometry);

            return(drawingSurface.PushClipping(pdfGeometry));
        }
Пример #2
0
        internal static IDisposable SaveClip(FixedContentEditor drawingSurface, UIElement element)
        {
            Geometry         clip             = null;
            FrameworkElement frameworkElement = element as FrameworkElement;

            if (frameworkElement != null)
            {
                clip = System.Windows.Controls.Primitives.LayoutInformation.GetLayoutClip(frameworkElement);
            }
            if (clip == null)
            {
                clip = element.Clip;
            }

            RectangleGeometry rectangleClip = clip as RectangleGeometry;

            if (rectangleClip == null)
            {
                return(null);
            }

            PathGeometry geometry    = MathHelper.TransformRectangle(drawingSurface.Position.Matrix, rectangleClip.Rect);
            var          pdfGeometry = PdfGeometryHelper.ConvertPathGeometry(geometry);

            return(drawingSurface.PushClipping(pdfGeometry));
        }
Пример #3
0
        private void InsertClipping(FixedContentEditor editor)
        {
            #region radpdfprocessing-editing-fixedcontenteditor_6
            string visibleText       = "The last word in this text is";
            string text              = string.Format("{0} clipped.", visibleText); //The last word in this text is clipped.
            Size   visisibleTextSize = editor.MeasureText(visibleText);

            using (editor.PushClipping(new Rect(new Point(0, 0), visisibleTextSize)))
            {
                editor.DrawText(text);
            }
            #endregion
        }
Пример #4
0
        internal static IDisposable SaveClip(FixedContentEditor drawingSurface, UIElement element)
        {
            Geometry clip = null;
            FrameworkElement frameworkElement = element as FrameworkElement;
            if (frameworkElement != null)
            {
                clip = System.Windows.Controls.Primitives.LayoutInformation.GetLayoutClip(frameworkElement);
            }            
            if (clip == null)
            {
                clip = element.Clip;
            }

            RectangleGeometry rectangleClip = clip as RectangleGeometry;
            if (rectangleClip == null)
            {
                return null;
            }

            PathGeometry geometry = MathHelper.TransformRectangle(drawingSurface.Position.Matrix, rectangleClip.Rect);
            var pdfGeometry = PdfGeometryHelper.ConvertPathGeometry(geometry);
            return drawingSurface.PushClipping(pdfGeometry);
        }
Пример #5
0
        public static RadFixedDocument CreatePagedDocument(FrameworkElement element, bool landscaped)
        {
            RadFixedDocument document   = new RadFixedDocument();
            double           pageMagins = 20;
            var numberOfPages           = landscaped ? Math.Ceiling(element.ActualHeight / element.ActualWidth * 1.4) : Math.Ceiling(element.ActualHeight / element.ActualWidth * .7);

            Size elementSizePerPage = new Size(element.ActualWidth, element.ActualHeight / numberOfPages);
            Size pageSize           = new Size(elementSizePerPage.Width + 2 * pageMagins, elementSizePerPage.Height + 2 * pageMagins);

            for (int pageIndex = 0; pageIndex < numberOfPages; pageIndex++)
            {
                RadFixedPage page = document.Pages.AddPage();
                page.Size = pageSize;

                FixedContentEditor editor = new FixedContentEditor(page, MatrixPosition.Default);
                editor.Position.Translate(pageMagins, pageMagins);

                // Draw dashed lines at the page clipping margins.
                using (editor.SaveGraphicProperties())
                {
                    editor.GraphicProperties.IsFilled        = false;
                    editor.GraphicProperties.IsStroked       = true;
                    editor.GraphicProperties.StrokeColor     = new RgbColor(200, 200, 200);
                    editor.GraphicProperties.StrokeDashArray = new double[] { 5, 5 };
                    editor.DrawRectangle(new Rect(0, 0, elementSizePerPage.Width, elementSizePerPage.Height));
                }

                // Clip and translate the element, so that it is positioned correctly on different pages.
                using (editor.PushClipping(new Rect(pageMagins, pageMagins, elementSizePerPage.Width, elementSizePerPage.Height)))
                {
                    editor.Position.Translate(0, -pageIndex * elementSizePerPage.Height);
                    ExportHelper.ExportToPdf(element, editor);
                }
            }

            return(document);
        }