Exemplo n.º 1
0
        /// <summary>
        /// Extracts text fragments from the 2nd page and highlights the glyphs in the fragment.
        /// </summary>
        /// <param name="document"></param>
        private static void ExtractTextAndHighlightGlyphs(PdfFixedDocument document)
        {
            PdfRgbColor penColor = new PdfRgbColor();
            PdfPen      pen      = new PdfPen(penColor, 0.5);
            Random      rnd      = new Random();

            byte[] rgb = new byte[3];

            PdfContentExtractor       ce  = new PdfContentExtractor(document.Pages[1]);
            PdfTextFragmentCollection tfc = ce.ExtractTextFragments();
            PdfTextFragment           tf  = tfc[1];

            for (int i = 0; i < tf.Glyphs.Count; i++)
            {
                rnd.NextBytes(rgb);
                penColor.R = rgb[0];
                penColor.G = rgb[1];
                penColor.B = rgb[2];

                PdfPath boundingPath = new PdfPath();
                boundingPath.StartSubpath(tf.Glyphs[i].GlyphCorners[0].X, tf.Glyphs[i].GlyphCorners[0].Y);
                boundingPath.AddLineTo(tf.Glyphs[i].GlyphCorners[1].X, tf.Glyphs[i].GlyphCorners[1].Y);
                boundingPath.AddLineTo(tf.Glyphs[i].GlyphCorners[2].X, tf.Glyphs[i].GlyphCorners[2].Y);
                boundingPath.AddLineTo(tf.Glyphs[i].GlyphCorners[3].X, tf.Glyphs[i].GlyphCorners[3].Y);
                boundingPath.CloseSubpath();

                document.Pages[1].Graphics.DrawPath(pen, boundingPath);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Extracts text fragments from the 3rd page and highlights the glyphs in the fragment.
        /// </summary>
        /// <param name="document"></param>
        private static void ExtractImagesAndHighlight(PdfFixedDocument document)
        {
            PdfPen                     pen       = new PdfPen(new PdfRgbColor(255, 0, 192), 0.5);
            PdfBrush                   brush     = new PdfBrush(new PdfRgbColor(0, 0, 0));
            PdfStandardFont            helvetica = new PdfStandardFont(PdfStandardFontFace.Helvetica, 8);
            PdfStringAppearanceOptions sao       = new PdfStringAppearanceOptions();

            sao.Brush = brush;
            sao.Font  = helvetica;
            PdfStringLayoutOptions slo = new PdfStringLayoutOptions();

            slo.Width = 1000;

            PdfContentExtractor      ce  = new PdfContentExtractor(document.Pages[2]);
            PdfVisualImageCollection eic = ce.ExtractImages(false);

            for (int i = 0; i < eic.Count; i++)
            {
                string imageProperties = string.Format("Image ID: {0}\nPixel width: {1} pixels\nPixel height: {2} pixels\n" +
                                                       "Display width: {3} points\nDisplay height: {4} points\nHorizonal Resolution: {5} dpi\nVertical Resolution: {6} dpi",
                                                       eic[i].ImageID, eic[i].Width, eic[i].Height, eic[i].DisplayWidth, eic[i].DisplayHeight, eic[i].DpiX, eic[i].DpiY);

                PdfPath boundingPath = new PdfPath();
                boundingPath.StartSubpath(eic[i].ImageCorners[0].X, eic[i].ImageCorners[0].Y);
                boundingPath.AddLineTo(eic[i].ImageCorners[1].X, eic[i].ImageCorners[1].Y);
                boundingPath.AddLineTo(eic[i].ImageCorners[2].X, eic[i].ImageCorners[2].Y);
                boundingPath.AddLineTo(eic[i].ImageCorners[3].X, eic[i].ImageCorners[3].Y);
                boundingPath.CloseSubpath();

                document.Pages[2].Graphics.DrawPath(pen, boundingPath);
                slo.X = eic[i].ImageCorners[3].X + 1;
                slo.Y = eic[i].ImageCorners[3].Y + 1;
                document.Pages[2].Graphics.DrawString(imageProperties, sao, slo);
            }
        }
Exemplo n.º 3
0
        private static void DrawPatterns(PdfPage page, PdfFont titleFont, PdfFont sectionFont)
        {
            PdfBrush brush    = new PdfBrush();
            PdfPen   blackPen = new PdfPen(PdfRgbColor.Black, 1);

            PdfPen   darkRedPen       = new PdfPen(new PdfRgbColor(0xFF, 0x40, 0x40), 0.8);
            PdfPen   darkOrangePen    = new PdfPen(new PdfRgbColor(0xA6, 0x4B, 0x00), 0.8);
            PdfPen   darkCyanPen      = new PdfPen(new PdfRgbColor(0x00, 0x63, 0x63), 0.8);
            PdfPen   darkGreenPen     = new PdfPen(new PdfRgbColor(0x00, 0x85, 0x00), 0.8);
            PdfBrush lightRedBrush    = new PdfBrush(new PdfRgbColor(0xFF, 0x73, 0x73));
            PdfBrush lightOrangeBrush = new PdfBrush(new PdfRgbColor(0xFF, 0x96, 0x40));
            PdfBrush lightCyanBrush   = new PdfBrush(new PdfRgbColor(0x33, 0xCC, 0xCC));
            PdfBrush lightGreenBrush  = new PdfBrush(new PdfRgbColor(0x67, 0xE6, 0x67));

            page.Graphics.DrawString("Patterns", titleFont, brush, 20, 50);

            page.Graphics.DrawString("Colored patterns", sectionFont, brush, 25, 70);

            // Create the pattern visual appearance.
            PdfColoredTilingPattern ctp = new PdfColoredTilingPattern(20, 20);

            // Red circle
            ctp.Graphics.DrawEllipse(darkRedPen, lightRedBrush, 1, 1, 8, 8);
            // Cyan square
            ctp.Graphics.DrawRectangle(darkCyanPen, lightCyanBrush, 11, 1, 8, 8);
            // Green diamond
            PdfPath diamondPath = new PdfPath();

            diamondPath.StartSubpath(1, 15);
            diamondPath.AddPolyLineTo(new PdfPoint[] { new PdfPoint(5, 11), new PdfPoint(9, 15), new PdfPoint(5, 19) });
            diamondPath.CloseSubpath();
            ctp.Graphics.DrawPath(darkGreenPen, lightGreenBrush, diamondPath);
            // Orange triangle
            PdfPath trianglePath = new PdfPath();

            trianglePath.StartSubpath(11, 19);
            trianglePath.AddPolyLineTo(new PdfPoint[] { new PdfPoint(15, 11), new PdfPoint(19, 19) });
            trianglePath.CloseSubpath();
            ctp.Graphics.DrawPath(darkOrangePen, lightOrangeBrush, trianglePath);

            // Create a pattern colorspace from the pattern object.
            PdfPatternColorSpace coloredPatternColorSpace = new PdfPatternColorSpace(ctp);
            // Create a color based on the pattern colorspace.
            PdfPatternColor coloredPatternColor = new PdfPatternColor(coloredPatternColorSpace);
            // The pen and brush use the pattern color like any other color.
            PdfPatternBrush patternBrush = new PdfPatternBrush(coloredPatternColor);
            PdfPatternPen   patternPen   = new PdfPatternPen(coloredPatternColor, 40);

            page.Graphics.DrawEllipse(patternBrush, 25, 90, 250, 200);
            page.Graphics.DrawRoundRectangle(patternPen, 310, 110, 250, 160, 100, 100);

            page.Graphics.DrawString("Uncolored patterns", sectionFont, brush, 25, 300);

            // Create the pattern visual appearance.
            PdfUncoloredTilingPattern uctp = new PdfUncoloredTilingPattern(20, 20);
            // A pen without color is used to create the pattern content.
            PdfPen noColorPen = new PdfPen(null, 0.8);

            // Circle
            uctp.Graphics.DrawEllipse(noColorPen, 1, 1, 8, 8);
            // Square
            uctp.Graphics.DrawRectangle(noColorPen, 11, 1, 8, 8);
            // Diamond
            diamondPath = new PdfPath();
            diamondPath.StartSubpath(1, 15);
            diamondPath.AddPolyLineTo(new PdfPoint[] { new PdfPoint(5, 11), new PdfPoint(9, 15), new PdfPoint(5, 19) });
            diamondPath.CloseSubpath();
            uctp.Graphics.DrawPath(noColorPen, diamondPath);
            // Triangle
            trianglePath = new PdfPath();
            trianglePath.StartSubpath(11, 19);
            trianglePath.AddPolyLineTo(new PdfPoint[] { new PdfPoint(15, 11), new PdfPoint(19, 19) });
            trianglePath.CloseSubpath();
            uctp.Graphics.DrawPath(noColorPen, trianglePath);

            // Create a pattern colorspace from the pattern object.
            PdfPatternColorSpace uncoloredPatternColorSpace = new PdfPatternColorSpace(uctp);
            // Create a color based on the pattern colorspace.
            PdfPatternColor uncoloredPatternColor = new PdfPatternColor(uncoloredPatternColorSpace);

            // The pen and brush use the pattern color like any other color.
            patternBrush = new PdfPatternBrush(uncoloredPatternColor);

            // Before using the uncolored pattern set the color that will be used to paint the pattern.
            patternBrush.UncoloredPatternPaintColor = new PdfRgbColor(0xFF, 0x40, 0x40);
            page.Graphics.DrawEllipse(patternBrush, 25, 320, 125, 200);
            patternBrush.UncoloredPatternPaintColor = new PdfRgbColor(0xA6, 0x4B, 0x00);
            page.Graphics.DrawEllipse(patternBrush, 175, 320, 125, 200);
            patternBrush.UncoloredPatternPaintColor = new PdfRgbColor(0x00, 0x63, 0x63);
            page.Graphics.DrawEllipse(patternBrush, 325, 320, 125, 200);
            patternBrush.UncoloredPatternPaintColor = new PdfRgbColor(0x00, 0x85, 0x00);
            page.Graphics.DrawEllipse(patternBrush, 475, 320, 125, 200);

            page.Graphics.DrawString("Shading patterns", sectionFont, brush, 25, 550);

            // Create the pattern visual appearance.
            PdfAxialShading horizontalShading = new PdfAxialShading();

            horizontalShading.StartColor = new PdfRgbColor(255, 0, 0);
            horizontalShading.EndColor   = new PdfRgbColor(0, 0, 255);
            horizontalShading.StartPoint = new PdfPoint(25, 600);
            horizontalShading.EndPoint   = new PdfPoint(575, 600);
            PdfShadingPattern sp = new PdfShadingPattern(horizontalShading);

            // Create a pattern colorspace from the pattern object.
            PdfPatternColorSpace shadingPatternColorSpace = new PdfPatternColorSpace(sp);
            // Create a color based on the pattern colorspace.
            PdfPatternColor shadingPatternColor = new PdfPatternColor(shadingPatternColorSpace);

            // The pen and brush use the pattern color like any other color.
            patternPen = new PdfPatternPen(shadingPatternColor, 40);

            page.Graphics.DrawEllipse(patternPen, 50, 600, 500, 150);

            page.Graphics.CompressAndClose();
        }
Exemplo n.º 4
0
        private static void DrawPatterns(PdfPage page, PdfFont titleFont, PdfFont sectionFont)
        {
            PdfBrush brush = new PdfBrush();
            PdfPen blackPen = new PdfPen(PdfRgbColor.Black, 1);

            PdfPen darkRedPen = new PdfPen(new PdfRgbColor(0xFF, 0x40, 0x40), 0.8);
            PdfPen darkOrangePen = new PdfPen(new PdfRgbColor(0xA6, 0x4B, 0x00), 0.8);
            PdfPen darkCyanPen = new PdfPen(new PdfRgbColor(0x00, 0x63, 0x63), 0.8);
            PdfPen darkGreenPen = new PdfPen(new PdfRgbColor(0x00, 0x85, 0x00), 0.8);
            PdfBrush lightRedBrush = new PdfBrush(new PdfRgbColor(0xFF, 0x73, 0x73));
            PdfBrush lightOrangeBrush = new PdfBrush(new PdfRgbColor(0xFF, 0x96, 0x40));
            PdfBrush lightCyanBrush = new PdfBrush(new PdfRgbColor(0x33, 0xCC, 0xCC));
            PdfBrush lightGreenBrush = new PdfBrush(new PdfRgbColor(0x67, 0xE6, 0x67));

            page.Graphics.DrawString("Patterns", titleFont, brush, 20, 50);

            page.Graphics.DrawString("Colored patterns", sectionFont, brush, 25, 70);

            // Create the pattern visual appearance.
            PdfColoredTilingPattern ctp = new PdfColoredTilingPattern(20, 20);
            // Red circle
            ctp.Graphics.DrawEllipse(darkRedPen, lightRedBrush, 1, 1, 8, 8);
            // Cyan square
            ctp.Graphics.DrawRectangle(darkCyanPen, lightCyanBrush, 11, 1, 8, 8);
            // Green diamond
            PdfPath diamondPath = new PdfPath();
            diamondPath.StartSubpath(1, 15);
            diamondPath.AddPolyLineTo(new PdfPoint[] { new PdfPoint(5, 11), new PdfPoint(9, 15), new PdfPoint(5, 19) });
            diamondPath.CloseSubpath();
            ctp.Graphics.DrawPath(darkGreenPen, lightGreenBrush, diamondPath);
            // Orange triangle
            PdfPath trianglePath = new PdfPath();
            trianglePath.StartSubpath(11, 19);
            trianglePath.AddPolyLineTo(new PdfPoint[] { new PdfPoint(15, 11), new PdfPoint(19, 19) });
            trianglePath.CloseSubpath();
            ctp.Graphics.DrawPath(darkOrangePen, lightOrangeBrush, trianglePath);

            // Create a pattern colorspace from the pattern object.
            PdfPatternColorSpace coloredPatternColorSpace = new PdfPatternColorSpace(ctp);
            // Create a color based on the pattern colorspace.
            PdfPatternColor coloredPatternColor = new PdfPatternColor(coloredPatternColorSpace);
            // The pen and brush use the pattern color like any other color.
            PdfPatternBrush patternBrush = new PdfPatternBrush(coloredPatternColor);
            PdfPatternPen patternPen = new PdfPatternPen(coloredPatternColor, 40);

            page.Graphics.DrawEllipse(patternBrush, 25, 90, 250, 200);
            page.Graphics.DrawRoundRectangle(patternPen, 310, 110, 250, 160, 100, 100);

            page.Graphics.DrawString("Uncolored patterns", sectionFont, brush, 25, 300);

            // Create the pattern visual appearance.
            PdfUncoloredTilingPattern uctp = new PdfUncoloredTilingPattern(20, 20);
            // A pen without color is used to create the pattern content.
            PdfPen noColorPen = new PdfPen(null, 0.8);
            // Circle
            uctp.Graphics.DrawEllipse(noColorPen, 1, 1, 8, 8);
            // Square
            uctp.Graphics.DrawRectangle(noColorPen, 11, 1, 8, 8);
            // Diamond
            diamondPath = new PdfPath();
            diamondPath.StartSubpath(1, 15);
            diamondPath.AddPolyLineTo(new PdfPoint[] { new PdfPoint(5, 11), new PdfPoint(9, 15), new PdfPoint(5, 19) });
            diamondPath.CloseSubpath();
            uctp.Graphics.DrawPath(noColorPen, diamondPath);
            // Triangle
            trianglePath = new PdfPath();
            trianglePath.StartSubpath(11, 19);
            trianglePath.AddPolyLineTo(new PdfPoint[] { new PdfPoint(15, 11), new PdfPoint(19, 19) });
            trianglePath.CloseSubpath();
            uctp.Graphics.DrawPath(noColorPen, trianglePath);

            // Create a pattern colorspace from the pattern object.
            PdfPatternColorSpace uncoloredPatternColorSpace = new PdfPatternColorSpace(uctp);
            // Create a color based on the pattern colorspace.
            PdfPatternColor uncoloredPatternColor = new PdfPatternColor(uncoloredPatternColorSpace);
            // The pen and brush use the pattern color like any other color.
            patternBrush = new PdfPatternBrush(uncoloredPatternColor);

            // Before using the uncolored pattern set the color that will be used to paint the pattern.
            patternBrush.UncoloredPatternPaintColor = new PdfRgbColor(0xFF, 0x40, 0x40);
            page.Graphics.DrawEllipse(patternBrush, 25, 320, 125, 200);
            patternBrush.UncoloredPatternPaintColor = new PdfRgbColor(0xA6, 0x4B, 0x00);
            page.Graphics.DrawEllipse(patternBrush, 175, 320, 125, 200);
            patternBrush.UncoloredPatternPaintColor = new PdfRgbColor(0x00, 0x63, 0x63);
            page.Graphics.DrawEllipse(patternBrush, 325, 320, 125, 200);
            patternBrush.UncoloredPatternPaintColor = new PdfRgbColor(0x00, 0x85, 0x00);
            page.Graphics.DrawEllipse(patternBrush, 475, 320, 125, 200);

            page.Graphics.DrawString("Shading patterns", sectionFont, brush, 25, 550);

            // Create the pattern visual appearance.
            PdfAxialShading horizontalShading = new PdfAxialShading();
            horizontalShading.StartColor = new PdfRgbColor(255, 0, 0);
            horizontalShading.EndColor = new PdfRgbColor(0, 0, 255);
            horizontalShading.StartPoint = new PdfPoint(25, 600);
            horizontalShading.EndPoint = new PdfPoint(575, 600);
            PdfShadingPattern sp = new PdfShadingPattern(horizontalShading);

            // Create a pattern colorspace from the pattern object.
            PdfPatternColorSpace shadingPatternColorSpace = new PdfPatternColorSpace(sp);
            // Create a color based on the pattern colorspace.
            PdfPatternColor shadingPatternColor = new PdfPatternColor(shadingPatternColorSpace);
            // The pen and brush use the pattern color like any other color.
            patternPen = new PdfPatternPen(shadingPatternColor, 40);

            page.Graphics.DrawEllipse(patternPen, 50, 600, 500, 150);

            page.Graphics.CompressAndClose();
        }
Exemplo n.º 5
0
        /// <summary>
        /// Main method for running the sample.
        /// </summary>
        public static SampleOutputInfo[] Run(Stream input)
        {
            PdfBrush brush = new PdfBrush();
            PdfPen redPen = new PdfPen(PdfRgbColor.Red, 1);
            PdfStandardFont helvetica = new PdfStandardFont(PdfStandardFontFace.Helvetica, 10);

            PdfFixedDocument document = new PdfFixedDocument(input);

            PdfContentExtractor ce = new PdfContentExtractor(document.Pages[0]);
            PdfVisualObjectCollection voc = ce.ExtractVisualObjects(false);

            PdfPath contour = null;
            for (int i = 0; i < voc.Count; i++)
            {
                switch (voc[i].Type)
                {
                    case PdfVisualObjectType.Image:
                        PdfImageVisualObject ivo = voc[i] as PdfImageVisualObject;
                        contour = new PdfPath();
                        contour.StartSubpath(ivo.Image.ImageCorners[0].X - 5, ivo.Image.ImageCorners[0].Y + 5);
                        contour.AddLineTo(ivo.Image.ImageCorners[1].X + 5, ivo.Image.ImageCorners[1].Y + 5);
                        contour.AddLineTo(ivo.Image.ImageCorners[2].X + 5, ivo.Image.ImageCorners[2].Y - 5);
                        contour.AddLineTo(ivo.Image.ImageCorners[3].X - 5, ivo.Image.ImageCorners[3].Y - 5);
                        contour.CloseSubpath();
                        document.Pages[0].Graphics.DrawPath(redPen, contour);

                        document.Pages[0].Graphics.DrawString("Image", helvetica, brush,
                            ivo.Image.ImageCorners[0].X - 5, ivo.Image.ImageCorners[0].Y + 5);
                        break;
                    case PdfVisualObjectType.Text:
                        PdfTextVisualObject tvo = voc[i] as PdfTextVisualObject;
                        contour = new PdfPath();
                        contour.StartSubpath(tvo.TextFragment.FragmentCorners[0].X - 5, tvo.TextFragment.FragmentCorners[0].Y + 5);
                        contour.AddLineTo(tvo.TextFragment.FragmentCorners[1].X + 5, tvo.TextFragment.FragmentCorners[1].Y + 5);
                        contour.AddLineTo(tvo.TextFragment.FragmentCorners[2].X + 5, tvo.TextFragment.FragmentCorners[2].Y - 5);
                        contour.AddLineTo(tvo.TextFragment.FragmentCorners[3].X - 5, tvo.TextFragment.FragmentCorners[3].Y - 5);
                        contour.CloseSubpath();
                        document.Pages[0].Graphics.DrawPath(redPen, contour);

                        document.Pages[0].Graphics.DrawString("Text", helvetica, brush,
                            tvo.TextFragment.FragmentCorners[0].X - 5, tvo.TextFragment.FragmentCorners[0].Y + 5);
                        break;
                    case PdfVisualObjectType.Path:
                        PdfPathVisualObject pvo = voc[i] as PdfPathVisualObject;
                        // Examine all the path points and determine the minimum rectangle that bounds the path.
                        double minX = 999999, minY = 999999, maxX = -999999, maxY = -999999;
                        for (int j = 0; j < pvo.PathItems.Count; j++)
                        {
                            PdfPathItem pi = pvo.PathItems[j];
                            if (pi.Points != null)
                            {
                                for (int k = 0; k < pi.Points.Length; k++)
                                {
                                    if (minX >= pi.Points[k].X)
                                    {
                                        minX = pi.Points[k].X;
                                    }
                                    if (minY >= pi.Points[k].Y)
                                    {
                                        minY = pi.Points[k].Y;
                                    }
                                    if (maxX <= pi.Points[k].X)
                                    {
                                        maxX = pi.Points[k].X;
                                    }
                                    if (maxY <= pi.Points[k].Y)
                                    {
                                        maxY = pi.Points[k].Y;
                                    }
                                }
                            }
                        }

                        contour = new PdfPath();
                        contour.StartSubpath(minX - 5, minY - 5);
                        contour.AddLineTo(maxX + 5, minY - 5);
                        contour.AddLineTo(maxX + 5, maxY + 5);
                        contour.AddLineTo(minX - 5, maxY + 5);
                        contour.CloseSubpath();
                        document.Pages[0].Graphics.DrawPath(redPen, contour);

                        document.Pages[0].Graphics.DrawString("Path", helvetica, brush, minX - 5, maxY + 5);
                        // Skip the rest of path objects, they are the evaluation message
                        i = voc.Count;
                        break;
                }
            }

            SampleOutputInfo[] output = new SampleOutputInfo[] { new SampleOutputInfo(document, "xfinium.pdf.sample.pageobjects.pdf") };
            return output;
        }
Exemplo n.º 6
0
        /// <summary>
        /// Main method for running the sample.
        /// </summary>
        public static SampleOutputInfo[] Run(Stream input)
        {
            PdfBrush        brush     = new PdfBrush();
            PdfPen          redPen    = new PdfPen(PdfRgbColor.Red, 1);
            PdfStandardFont helvetica = new PdfStandardFont(PdfStandardFontFace.Helvetica, 10);

            PdfFixedDocument document = new PdfFixedDocument(input);

            PdfContentExtractor       ce  = new PdfContentExtractor(document.Pages[0]);
            PdfVisualObjectCollection voc = ce.ExtractVisualObjects(false);

            PdfPath contour = null;

            for (int i = 0; i < voc.Count; i++)
            {
                switch (voc[i].Type)
                {
                case PdfVisualObjectType.Image:
                    PdfImageVisualObject ivo = voc[i] as PdfImageVisualObject;
                    contour = new PdfPath();
                    contour.StartSubpath(ivo.Image.ImageCorners[0].X - 5, ivo.Image.ImageCorners[0].Y + 5);
                    contour.AddLineTo(ivo.Image.ImageCorners[1].X + 5, ivo.Image.ImageCorners[1].Y + 5);
                    contour.AddLineTo(ivo.Image.ImageCorners[2].X + 5, ivo.Image.ImageCorners[2].Y - 5);
                    contour.AddLineTo(ivo.Image.ImageCorners[3].X - 5, ivo.Image.ImageCorners[3].Y - 5);
                    contour.CloseSubpath();
                    document.Pages[0].Graphics.DrawPath(redPen, contour);

                    document.Pages[0].Graphics.DrawString("Image", helvetica, brush,
                                                          ivo.Image.ImageCorners[0].X - 5, ivo.Image.ImageCorners[0].Y + 5);
                    break;

                case PdfVisualObjectType.Text:
                    PdfTextVisualObject tvo = voc[i] as PdfTextVisualObject;
                    contour = new PdfPath();
                    contour.StartSubpath(tvo.TextFragment.FragmentCorners[0].X - 5, tvo.TextFragment.FragmentCorners[0].Y + 5);
                    contour.AddLineTo(tvo.TextFragment.FragmentCorners[1].X + 5, tvo.TextFragment.FragmentCorners[1].Y + 5);
                    contour.AddLineTo(tvo.TextFragment.FragmentCorners[2].X + 5, tvo.TextFragment.FragmentCorners[2].Y - 5);
                    contour.AddLineTo(tvo.TextFragment.FragmentCorners[3].X - 5, tvo.TextFragment.FragmentCorners[3].Y - 5);
                    contour.CloseSubpath();
                    document.Pages[0].Graphics.DrawPath(redPen, contour);

                    document.Pages[0].Graphics.DrawString("Text", helvetica, brush,
                                                          tvo.TextFragment.FragmentCorners[0].X - 5, tvo.TextFragment.FragmentCorners[0].Y + 5);
                    break;

                case PdfVisualObjectType.Path:
                    PdfPathVisualObject pvo = voc[i] as PdfPathVisualObject;
                    // Examine all the path points and determine the minimum rectangle that bounds the path.
                    double minX = 999999, minY = 999999, maxX = -999999, maxY = -999999;
                    for (int j = 0; j < pvo.PathItems.Count; j++)
                    {
                        PdfPathItem pi = pvo.PathItems[j];
                        if (pi.Points != null)
                        {
                            for (int k = 0; k < pi.Points.Length; k++)
                            {
                                if (minX >= pi.Points[k].X)
                                {
                                    minX = pi.Points[k].X;
                                }
                                if (minY >= pi.Points[k].Y)
                                {
                                    minY = pi.Points[k].Y;
                                }
                                if (maxX <= pi.Points[k].X)
                                {
                                    maxX = pi.Points[k].X;
                                }
                                if (maxY <= pi.Points[k].Y)
                                {
                                    maxY = pi.Points[k].Y;
                                }
                            }
                        }
                    }

                    contour = new PdfPath();
                    contour.StartSubpath(minX - 5, minY - 5);
                    contour.AddLineTo(maxX + 5, minY - 5);
                    contour.AddLineTo(maxX + 5, maxY + 5);
                    contour.AddLineTo(minX - 5, maxY + 5);
                    contour.CloseSubpath();
                    document.Pages[0].Graphics.DrawPath(redPen, contour);

                    document.Pages[0].Graphics.DrawString("Path", helvetica, brush, minX - 5, maxY + 5);
                    // Skip the rest of path objects, they are the evaluation message
                    i = voc.Count;
                    break;
                }
            }

            SampleOutputInfo[] output = new SampleOutputInfo[] { new SampleOutputInfo(document, "xfinium.pdf.sample.pageobjects.pdf") };
            return(output);
        }