VintaSoft Imaging .NET SDK v8.7
Vintasoft.Imaging.Pdf Namespace / PdfContentRenderer Class
Members Example



In This Topic
    PdfContentRenderer Class
    In This Topic
    Provides functionality for overriding algorithms of PDF content rendering.
    Object Model
    PdfContentRenderer Class
    Syntax
    'Declaration
     
    Public MustInherit Class PdfContentRenderer 
    public abstract class PdfContentRenderer 
    public __gc abstract class PdfContentRenderer 
    public ref class PdfContentRenderer abstract 
    Remarks
    This class can be used for the following tasks:
    • Hide some content (text, images, lines, shading or tiling patterns, etc).
    • Override PDF content rendering algorithms (e.g. increase/decrease weight of lines, change image drawing or processing, etc).
    • Change graphics state during rendering (line width, font size, colors, CTM, text-space parameters, etc).
    Example
    This example shows how to override the PDF page rendering algorithm and render the PDF pages with different settings.
    Class PdfContentRendererExample
    	''' <summary>
    	''' Shows how manage rendering of PDF page, i.e. render PDF page without images,
    	''' render PDF page without text, etc
    	''' </summary>
    	''' <param name="pdfFilename">The filename of PDF document.</param>
    	Public Shared Sub TestCustomContentRenderer(pdfFilename As String)
    		' output TIFF file name format string
    		Dim outputFileName As String = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(pdfFilename), System.IO.Path.GetFileNameWithoutExtension(pdfFilename))
    		outputFileName = outputFileName & "_{0}.tif"
                
    		' custom renderer
    		Dim renderer As CustomContentRenderer
                
    		' create image collection
    		Using images As New Vintasoft.Imaging.ImageCollection()
    			' open source PDF file
    			images.Add(pdfFilename)
                
    			' render PDF pages without images
    			renderer = New CustomContentRenderer()
    			renderer.DrawImages = False
    			RenderPdfUseContentRenderer(images, String.Format(outputFileName, "withoutImages"), renderer)
                
    			' render PDF pages and invert rendered images
    			renderer = New CustomContentRenderer()
    			renderer.ImageProcessing = New Vintasoft.Imaging.ImageProcessing.Color.InvertCommand()
    			RenderPdfUseContentRenderer(images, String.Format(outputFileName, "invertImages"), renderer)
                
    			' render PDF pages without path filling
    			renderer = New CustomContentRenderer()
    			renderer.FillAreaUseShadingPatterns = False
    			renderer.FillPaths = False
    			renderer.FillPathsUseShadingPatterns = False
    			renderer.FillPathsUseTilingPatterns = False
    			RenderPdfUseContentRenderer(images, String.Format(outputFileName, "withoutFillPath"), renderer)
                
    			' render PDF pages without path drawing
    			renderer = New CustomContentRenderer()
    			renderer.DrawPaths = False
    			RenderPdfUseContentRenderer(images, String.Format(outputFileName, "withoutDrawPath"), renderer)
                
    			' render PDF pages without text
    			renderer = New CustomContentRenderer()
    			renderer.DrawText = False
    			RenderPdfUseContentRenderer(images, String.Format(outputFileName, "withoutText"), renderer)
                
    			' clear image collection and dispose images
    			images.ClearAndDisposeItems()
    		End Using
    	End Sub
                
    	''' <summary>
    	''' Renders the PDF file using specified content renderer.
    	''' </summary>
    	''' <param name="images">The images to render.</param>
    	''' <param name="outputTiffFileName">Name of the output tiff file.</param>
    	''' <param name="renderer">The renderer.</param>
    	Public Shared Sub RenderPdfUseContentRenderer(images As Vintasoft.Imaging.ImageCollection, outputTiffFileName As String, renderer As Vintasoft.Imaging.Pdf.PdfContentRenderer)
    		' create PDF rendering settings
    		Dim settings As New Vintasoft.Imaging.Pdf.PdfRenderingSettings()
    		' specify the custom PDF content renderer
    		settings.ContentRenderer = renderer
    		' specify PDF rendering settings for images (PDF pages)
    		images.SetRenderingSettings(settings)
                
    		' create TIFF encoder
    		Using encoder As New Vintasoft.Imaging.Codecs.Encoders.TiffEncoder()
    			' save PDF pages to a TIFF file
    			images.SaveSync(outputTiffFileName, encoder)
    		End Using
    	End Sub
                
                
    	''' <summary>
    	''' Provides functionality for overriding algorithms of PDF content rendering.
    	''' </summary>
    	Public Class CustomContentRenderer
    		Inherits Vintasoft.Imaging.Pdf.PdfContentRenderer
                
    		#Region "Fields"
                
    		''' <summary>
    		''' Determines that string is drawing.
    		''' </summary>
    		Private _stringDrawing As Boolean = False
                
    		#End Region
                
                
                
    		#Region "Properties"
                
    		Private _drawAnnotations As Boolean = True
    		''' <summary>
    		''' Gets or sets a value indicating whether the renderer must draw 
    		''' annotations on PDF page.
    		''' </summary>        
    		Public Property DrawAnnotations() As Boolean
    			Get
    				Return _drawAnnotations
    			End Get
    			Set
    				_drawAnnotations = value
    			End Set
    		End Property
                
    		Private _drawForms As Boolean = True
    		''' <summary>
    		''' Gets or sets a value indicating whether the renderer must draw 
    		''' form XObjects on PDF page.
    		''' </summary>
    		Public Property DrawForms() As Boolean
    			Get
    				Return _drawForms
    			End Get
    			Set
    				_drawForms = value
    			End Set
    		End Property
                
    		Private _drawImages As Boolean = True
    		''' <summary>
    		''' Gets or sets a value indicating whether the renderer must draw 
    		''' images on PDF page.
    		''' </summary>
    		Public Property DrawImages() As Boolean
    			Get
    				Return _drawImages
    			End Get
    			Set
    				_drawImages = value
    			End Set
    		End Property
                
    		Private _drawInlineImages As Boolean = True
    		''' <summary>
    		''' Gets or sets a value indicating whether the renderer must draw 
    		''' inline images on PDF page.
    		''' </summary>
    		Public Property DrawInlineImages() As Boolean
    			Get
    				Return _drawInlineImages
    			End Get
    			Set
    				_drawInlineImages = value
    			End Set
    		End Property
                
    		Private _drawPaths As Boolean = True
    		''' <summary>
    		''' Gets or sets a value indicating whether the renderer must draw 
    		''' graphics paths on PDF page.
    		''' </summary>
    		Public Property DrawPaths() As Boolean
    			Get
    				Return _drawPaths
    			End Get
    			Set
    				_drawPaths = value
    			End Set
    		End Property
                
    		Private _fillPaths As Boolean = True
    		''' <summary>
    		''' Gets or sets a value indicating whether the renderer must fill 
    		''' graphics paths on PDF page.
    		''' </summary>
    		Public Property FillPaths() As Boolean
    			Get
    				Return _fillPaths
    			End Get
    			Set
    				_fillPaths = value
    			End Set
    		End Property
                
    		Private _fillPathsUseTilingPatterns As Boolean = True
    		''' <summary>
    		''' Gets or sets a value indicating whether the renderer must fill
    		''' graphics paths use tiling patterns on PDF page.
    		''' </summary>
    		Public Property FillPathsUseTilingPatterns() As Boolean
    			Get
    				Return _fillPathsUseTilingPatterns
    			End Get
    			Set
    				_fillPathsUseTilingPatterns = value
    			End Set
    		End Property
                
    		Private _fillPathsUseShadingPatterns As Boolean = True
    		''' <summary>
    		''' Gets or sets a value indicating whether the renderer must fill
    		''' graphics paths use shading patterns on PDF page.
    		''' </summary>
    		Public Property FillPathsUseShadingPatterns() As Boolean
    			Get
    				Return _fillPathsUseShadingPatterns
    			End Get
    			Set
    				_fillPathsUseShadingPatterns = value
    			End Set
    		End Property
                
                
    		Private _fillAreaUseShadingPatterns As Boolean = True
    		''' <summary>
    		''' Gets or sets a value indicating whether the renderer must fill
    		''' all visible area use tiling patterns on PDF page.
    		''' </summary>
    		Public Property FillAreaUseShadingPatterns() As Boolean
    			Get
    				Return _fillAreaUseShadingPatterns
    			End Get
    			Set
    				_fillAreaUseShadingPatterns = value
    			End Set
    		End Property
                
    		Private _drawText As Boolean = True
    		''' <summary>
    		''' Gets or sets a value indicating whether the renderer must draw 
    		''' text on PDF page.
    		''' </summary>
    		Public Property DrawText() As Boolean
    			Get
    				Return _drawText
    			End Get
    			Set
    				_drawText = value
    			End Set
    		End Property
                
    		Private _drawInvisibleText As Boolean = False
    		''' <summary>
    		''' Gets or sets a value indicating whether the renderer must draw 
    		''' invisible text on PDF page.
    		''' </summary>
    		Public Property DrawInvisibleText() As Boolean
    			Get
    				Return _drawInvisibleText
    			End Get
    			Set
    				_drawInvisibleText = value
    			End Set
    		End Property
                
    		Private _setClipPaths As Boolean = True
    		''' <summary>
    		''' Gets or sets a value indicating whether the renderer must set 
    		''' clip paths.
    		''' </summary>
    		Public Property SetClipPaths() As Boolean
    			Get
    				Return _setClipPaths
    			End Get
    			Set
    				_setClipPaths = value
    			End Set
    		End Property
                
    		Private _linesWeigth As Single = 1
    		''' <summary>
    		''' Gets or sets the lines weigth, in percents.
    		''' </summary>
    		Public Property LinesWeigth() As Single
    			Get
    				Return _linesWeigth
    			End Get
    			Set
    				_linesWeigth = value
    			End Set
    		End Property
                
    		Private _imageProcessing As Vintasoft.Imaging.ImageProcessing.ProcessingCommandBase = Nothing
    		''' <summary>
    		''' Gets or sets the image processing command that apply 
    		''' before an image draws on PDF page.
    		''' </summary>
    		Public Property ImageProcessing() As Vintasoft.Imaging.ImageProcessing.ProcessingCommandBase
    			Get
    				Return _imageProcessing
    			End Get
    			Set
    				_imageProcessing = value
    			End Set
    		End Property
                
    		#End Region
                
                
                
    		#Region "Methods"
                
    		''' <summary>
    		''' Draws a text string.
    		''' </summary>
    		''' <param name="context">The rendering context.</param>
    		''' <param name="charCodes">The codes, in font encoding, of text characters.</param>
    		Public Overrides Sub DrawString(context As Vintasoft.Imaging.Pdf.PdfContentRenderingContext, charCodes As ULong())
    			' if text must be drawn AND text is visible
    			If _drawText AndAlso context.GraphicsState.TextRenderingMode <> Vintasoft.Imaging.Pdf.Content.TextRenderingMode.Invisible Then
    				_stringDrawing = True
    				MyBase.DrawString(context, charCodes)
    				_stringDrawing = False
    			' if invisible text must be drawn AND text is invisible
    			ElseIf _drawInvisibleText AndAlso context.GraphicsState.TextRenderingMode = Vintasoft.Imaging.Pdf.Content.TextRenderingMode.Invisible Then
    				context.GraphicsState.TextRenderingMode = Vintasoft.Imaging.Pdf.Content.TextRenderingMode.Fill
    				MyBase.DrawString(context, charCodes)
    				context.GraphicsState.TextRenderingMode = Vintasoft.Imaging.Pdf.Content.TextRenderingMode.Invisible
    			End If
    		End Sub
                
    		''' <summary>
    		''' Draws path using specified pen.
    		''' </summary>
    		''' <param name="context">The rendering context.</param>
    		''' <param name="path">The path to draw.</param>
    		''' <param name="pen">The pen to use for drawing path.</param>
    		Public Overrides Sub DrawPath(context As Vintasoft.Imaging.Pdf.PdfContentRenderingContext, path As System.Drawing.Drawing2D.GraphicsPath, pen As System.Drawing.Pen)
    			' if path must be drawn
    			If (_drawPaths AndAlso Not _stringDrawing) OrElse (_drawText AndAlso _stringDrawing) Then
    				' if path is not a path of text symbol
    				If _linesWeigth <> 1 AndAlso Not _stringDrawing Then
    					Dim oldWidth As Single = pen.Width
    					pen.Width *= _linesWeigth
    					MyBase.DrawPath(context, path, pen)
    					pen.Width = oldWidth
    				Else
    					MyBase.DrawPath(context, path, pen)
    				End If
    			End If
    		End Sub
                
    		''' <summary>
    		''' Fills path using specified brush.
    		''' </summary>
    		''' <param name="context">The rendering context.</param>
    		''' <param name="path">The path to fill.</param>
    		''' <param name="brush">The brush to use for filling path.</param>
    		Public Overrides Sub FillPath(context As Vintasoft.Imaging.Pdf.PdfContentRenderingContext, path As System.Drawing.Drawing2D.GraphicsPath, brush As System.Drawing.Brush)
    			' if path must be filled
    			If (_fillPaths AndAlso Not _stringDrawing) OrElse (_drawText AndAlso _stringDrawing) Then
    				MyBase.FillPath(context, path, brush)
    			End If
    		End Sub
                
    		''' <summary>
    		''' Fills path using specified pattern.
    		''' </summary>
    		''' <param name="context">The rendering context.</param>
    		''' <param name="path">The path to fill.</param>
    		''' <param name="pattern">The pattern to use for filling path.</param>
    		Public Overrides Sub FillPath(context As Vintasoft.Imaging.Pdf.PdfContentRenderingContext, path As System.Drawing.Drawing2D.GraphicsPath, pattern As Vintasoft.Imaging.Pdf.Tree.Patterns.PdfGraphicalPattern)
    			If Not _fillPathsUseShadingPatterns AndAlso TypeOf pattern Is Vintasoft.Imaging.Pdf.Tree.Patterns.ShadingPattern Then
    				Return
    			End If
    			If Not _fillPathsUseTilingPatterns AndAlso TypeOf pattern Is Vintasoft.Imaging.Pdf.Tree.Patterns.TilingPattern Then
    				Return
    			End If
    			MyBase.FillPath(context, path, pattern)
    		End Sub
                
    		''' <summary>
    		''' Fills all visible areas using specified shading pattern.
    		''' </summary>
    		''' <param name="context">The rendering context.</param>
    		''' <param name="shadingPattern">The shading pattern.</param>
    		Public Overrides Sub FillArea(context As Vintasoft.Imaging.Pdf.PdfContentRenderingContext, shadingPattern As Vintasoft.Imaging.Pdf.Tree.ShadingPatterns.PdfShadingPattern)
    			If _fillAreaUseShadingPatterns Then
    				MyBase.FillArea(context, shadingPattern)
    			End If
    		End Sub
                
    		''' <summary>
    		''' Draws a form XObject.
    		''' </summary>
    		''' <param name="context">The rendering context.</param>
    		''' <param name="formResource">The form XObject to draw.</param>
    		Public Overrides Sub DrawFormXObject(context As Vintasoft.Imaging.Pdf.PdfContentRenderingContext, formResource As Vintasoft.Imaging.Pdf.Tree.PdfFormXObjectResource)
    			If _drawForms Then
    				MyBase.DrawFormXObject(context, formResource)
    			End If
    		End Sub
                
    		''' <summary>
    		''' Draws an annotation.
    		''' </summary>
    		''' <param name="context">The rendering context.</param>
    		''' <param name="annotation">The annotation to draw.</param>
    		''' <param name="appearanceForm">The annotation appearance form.</param>
    		Public Overrides Sub DrawAnnotation(context As Vintasoft.Imaging.Pdf.PdfContentRenderingContext, annotation As Vintasoft.Imaging.Pdf.Tree.Annotations.PdfAnnotation, appearanceForm As Vintasoft.Imaging.Pdf.Tree.PdfFormXObjectResource)
    			If _drawAnnotations Then
    				MyBase.DrawAnnotation(context, annotation, appearanceForm)
    			End If
    		End Sub
                
    		''' <summary>
    		''' Intersects current clip region with specified clip path.
    		''' </summary>
    		''' <param name="context">The rendering context.</param>
    		''' <param name="clipPath">The clip path.</param>
    		Public Overrides Sub IntersectClip(context As Vintasoft.Imaging.Pdf.PdfContentRenderingContext, clipPath As System.Drawing.Drawing2D.GraphicsPath)
    			If _setClipPaths Then
    				MyBase.IntersectClip(context, clipPath)
    			End If
    		End Sub
                
    		''' <summary>
    		''' Draws an image resource.
    		''' </summary>
    		''' <param name="context">The rendering context.</param>
    		''' <param name="imageResource">The image XObject resource to draw.</param>
    		Public Overrides Sub DrawImageResource(context As Vintasoft.Imaging.Pdf.PdfContentRenderingContext, imageResource As Vintasoft.Imaging.Pdf.Tree.PdfImageResource)
    			If Not _drawImages AndAlso Not imageResource.IsInline Then
    				Return
    			End If
    			If Not _drawInlineImages AndAlso imageResource.IsInline Then
    				Return
    			End If
    			MyBase.DrawImageResource(context, imageResource)
    		End Sub
                
    		''' <summary>
    		''' Draws an image.
    		''' </summary>
    		''' <param name="context">The rendering context.</param>
    		''' <param name="image">The image to draw.</param>
    		''' <param name="points">Array of three System.Drawing.PointF structures that
    		''' define a parallelogram on rendering content where image must be drawn.</param>
    		Public Overrides Sub DrawImage(context As Vintasoft.Imaging.Pdf.PdfContentRenderingContext, image As Vintasoft.Imaging.VintasoftImage, points As System.Drawing.PointF())
    			' if image must be processed
    			If ImageProcessing IsNot Nothing AndAlso ImageProcessing.IsPixelFormatSupported(image.PixelFormat) Then
    				SyncLock image
    					Using tempImage As Vintasoft.Imaging.VintasoftImage = ImageProcessing.Execute(image)
    						MyBase.DrawImage(context, tempImage, points)
    					End Using
    				End SyncLock
    			Else
    				MyBase.DrawImage(context, image, points)
    			End If
    		End Sub
                
    		''' <summary>
    		''' Creates a new object that is a copy of this instance.
    		''' </summary>
    		''' <returns>
    		''' A new object that is a copy of this instance.
    		''' </returns>
    		Public Overrides Function Clone() As Object
    			Dim result As New CustomContentRenderer()
                
    			result._drawAnnotations = _drawAnnotations
    			result._drawForms = _drawForms
    			result._drawImages = _drawImages
    			result._drawInlineImages = _drawInlineImages
    			result._drawInvisibleText = _drawInvisibleText
    			result._drawPaths = _drawPaths
    			result._drawText = _drawText
    			result._fillAreaUseShadingPatterns = _fillAreaUseShadingPatterns
    			result._fillPaths = _fillPaths
    			result._fillPathsUseShadingPatterns = _fillPathsUseShadingPatterns
    			result._fillPathsUseTilingPatterns = _fillPathsUseTilingPatterns
    			If _imageProcessing IsNot Nothing Then
    				result._imageProcessing = DirectCast(_imageProcessing.Clone(), Vintasoft.Imaging.ImageProcessing.ProcessingCommandBase)
    			End If
    			result._linesWeigth = _linesWeigth
    			result._setClipPaths = _setClipPaths
                
    			Return result
    		End Function
                
    		#End Region
                
    	End Class
                
    End Class
    class PdfContentRendererExample
    {
        /// <summary>
        /// Shows how manage rendering of PDF page, i.e. render PDF page without images,
        /// render PDF page without text, etc
        /// </summary>
        /// <param name="pdfFilename">The filename of PDF document.</param>
        public static void TestCustomContentRenderer(string pdfFilename)
        {
            // output TIFF file name format string
            string outputFileName = System.IO.Path.Combine(
                System.IO.Path.GetDirectoryName(pdfFilename), 
                System.IO.Path.GetFileNameWithoutExtension(pdfFilename));
            outputFileName = outputFileName + "_{0}.tif";
                
            // custom renderer
            CustomContentRenderer renderer;
                
            // create image collection
            using (Vintasoft.Imaging.ImageCollection images = 
                new Vintasoft.Imaging.ImageCollection())
            {
                // open source PDF file
                images.Add(pdfFilename);
                
                // render PDF pages without images
                renderer = new CustomContentRenderer();
                renderer.DrawImages = false;
                RenderPdfUseContentRenderer(images, string.Format(outputFileName, "withoutImages"), renderer);
                
                // render PDF pages and invert rendered images
                renderer = new CustomContentRenderer();
                renderer.ImageProcessing = new Vintasoft.Imaging.ImageProcessing.Color.InvertCommand();
                RenderPdfUseContentRenderer(images, string.Format(outputFileName, "invertImages"), renderer);
                
                // render PDF pages without path filling
                renderer = new CustomContentRenderer();
                renderer.FillAreaUseShadingPatterns = false;
                renderer.FillPaths = false;
                renderer.FillPathsUseShadingPatterns = false;
                renderer.FillPathsUseTilingPatterns = false;
                RenderPdfUseContentRenderer(images, string.Format(outputFileName, "withoutFillPath"), renderer);
                
                // render PDF pages without path drawing
                renderer = new CustomContentRenderer();
                renderer.DrawPaths = false;
                RenderPdfUseContentRenderer(images, string.Format(outputFileName, "withoutDrawPath"), renderer);
                
                // render PDF pages without text
                renderer = new CustomContentRenderer();
                renderer.DrawText = false;
                RenderPdfUseContentRenderer(images, string.Format(outputFileName, "withoutText"), renderer);
                
                // clear image collection and dispose images
                images.ClearAndDisposeItems();
            }
        }
                
        /// <summary>
        /// Renders the PDF file using specified content renderer.
        /// </summary>
        /// <param name="images">The images to render.</param>
        /// <param name="outputTiffFileName">Name of the output tiff file.</param>
        /// <param name="renderer">The renderer.</param>
        public static void RenderPdfUseContentRenderer(
            Vintasoft.Imaging.ImageCollection images,
            string outputTiffFileName,
            Vintasoft.Imaging.Pdf.PdfContentRenderer renderer)
        {
            // create PDF rendering settings
            Vintasoft.Imaging.Pdf.PdfRenderingSettings settings = 
                new Vintasoft.Imaging.Pdf.PdfRenderingSettings();
            // specify the custom PDF content renderer
            settings.ContentRenderer = renderer;
            // specify PDF rendering settings for images (PDF pages)
            images.SetRenderingSettings(settings);
                
            // create TIFF encoder
            using (Vintasoft.Imaging.Codecs.Encoders.TiffEncoder encoder = 
                new Vintasoft.Imaging.Codecs.Encoders.TiffEncoder())
                // save PDF pages to a TIFF file
                images.SaveSync(outputTiffFileName, encoder);
        }
                
                
        /// <summary>
        /// Provides functionality for overriding algorithms of PDF content rendering.
        /// </summary>
        public class CustomContentRenderer : Vintasoft.Imaging.Pdf.PdfContentRenderer
        {
                
            #region Fields
                
            /// <summary>
            /// Determines that string is drawing.
            /// </summary>
            bool _stringDrawing = false;
                
            #endregion
                
                
                
            #region Properties
                
            bool _drawAnnotations = true;
            /// <summary>
            /// Gets or sets a value indicating whether the renderer must draw 
            /// annotations on PDF page.
            /// </summary>        
            public bool DrawAnnotations
            {
                get
                {
                    return _drawAnnotations;
                }
                set
                {
                    _drawAnnotations = value;
                }
            }
                
            bool _drawForms = true;
            /// <summary>
            /// Gets or sets a value indicating whether the renderer must draw 
            /// form XObjects on PDF page.
            /// </summary>
            public bool DrawForms
            {
                get
                {
                    return _drawForms;
                }
                set
                {
                    _drawForms = value;
                }
            }
                
            bool _drawImages = true;
            /// <summary>
            /// Gets or sets a value indicating whether the renderer must draw 
            /// images on PDF page.
            /// </summary>
            public bool DrawImages
            {
                get
                {
                    return _drawImages;
                }
                set
                {
                    _drawImages = value;
                }
            }
                
            bool _drawInlineImages = true;
            /// <summary>
            /// Gets or sets a value indicating whether the renderer must draw 
            /// inline images on PDF page.
            /// </summary>
            public bool DrawInlineImages
            {
                get
                {
                    return _drawInlineImages;
                }
                set
                {
                    _drawInlineImages = value;
                }
            }
                
            bool _drawPaths = true;
            /// <summary>
            /// Gets or sets a value indicating whether the renderer must draw 
            /// graphics paths on PDF page.
            /// </summary>
            public bool DrawPaths
            {
                get
                {
                    return _drawPaths;
                }
                set
                {
                    _drawPaths = value;
                }
            }
                
            bool _fillPaths = true;
            /// <summary>
            /// Gets or sets a value indicating whether the renderer must fill 
            /// graphics paths on PDF page.
            /// </summary>
            public bool FillPaths
            {
                get
                {
                    return _fillPaths;
                }
                set
                {
                    _fillPaths = value;
                }
            }
                
            bool _fillPathsUseTilingPatterns = true;
            /// <summary>
            /// Gets or sets a value indicating whether the renderer must fill
            /// graphics paths use tiling patterns on PDF page.
            /// </summary>
            public bool FillPathsUseTilingPatterns
            {
                get
                {
                    return _fillPathsUseTilingPatterns;
                }
                set
                {
                    _fillPathsUseTilingPatterns = value;
                }
            }
                
            bool _fillPathsUseShadingPatterns = true;
            /// <summary>
            /// Gets or sets a value indicating whether the renderer must fill
            /// graphics paths use shading patterns on PDF page.
            /// </summary>
            public bool FillPathsUseShadingPatterns
            {
                get
                {
                    return _fillPathsUseShadingPatterns;
                }
                set
                {
                    _fillPathsUseShadingPatterns = value;
                }
            }
                
                
            bool _fillAreaUseShadingPatterns = true;
            /// <summary>
            /// Gets or sets a value indicating whether the renderer must fill
            /// all visible area use tiling patterns on PDF page.
            /// </summary>
            public bool FillAreaUseShadingPatterns
            {
                get
                {
                    return _fillAreaUseShadingPatterns;
                }
                set
                {
                    _fillAreaUseShadingPatterns = value;
                }
            }
                
            bool _drawText = true;
            /// <summary>
            /// Gets or sets a value indicating whether the renderer must draw 
            /// text on PDF page.
            /// </summary>
            public bool DrawText
            {
                get
                {
                    return _drawText;
                }
                set
                {
                    _drawText = value;
                }
            }
                
            bool _drawInvisibleText = false;
            /// <summary>
            /// Gets or sets a value indicating whether the renderer must draw 
            /// invisible text on PDF page.
            /// </summary>
            public bool DrawInvisibleText
            {
                get
                {
                    return _drawInvisibleText;
                }
                set
                {
                    _drawInvisibleText = value;
                }
            }
                
            bool _setClipPaths = true;
            /// <summary>
            /// Gets or sets a value indicating whether the renderer must set 
            /// clip paths.
            /// </summary>
            public bool SetClipPaths
            {
                get
                {
                    return _setClipPaths;
                }
                set
                {
                    _setClipPaths = value;
                }
            }
                
            float _linesWeigth = 1;
            /// <summary>
            /// Gets or sets the lines weigth, in percents.
            /// </summary>
            public float LinesWeigth
            {
                get
                {
                    return _linesWeigth;
                }
                set
                {
                    _linesWeigth = value;
                }
            }
                
            Vintasoft.Imaging.ImageProcessing.ProcessingCommandBase _imageProcessing = null;
            /// <summary>
            /// Gets or sets the image processing command that apply 
            /// before an image draws on PDF page.
            /// </summary>
            public Vintasoft.Imaging.ImageProcessing.ProcessingCommandBase ImageProcessing
            {
                get
                {
                    return _imageProcessing;
                }
                set
                {
                    _imageProcessing = value;
                }
            }
                
            #endregion
                
                
                
            #region Methods
                
            /// <summary>
            /// Draws a text string.
            /// </summary>
            /// <param name="context">The rendering context.</param>
            /// <param name="charCodes">The codes, in font encoding, of text characters.</param>
            public override void DrawString(Vintasoft.Imaging.Pdf.PdfContentRenderingContext context, ulong[] charCodes)
            {
                // if text must be drawn AND text is visible
                if (_drawText && context.GraphicsState.TextRenderingMode != 
                    Vintasoft.Imaging.Pdf.Content.TextRenderingMode.Invisible)
                {
                    _stringDrawing = true;
                    base.DrawString(context, charCodes);
                    _stringDrawing = false;
                }
                // if invisible text must be drawn AND text is invisible
                else if (_drawInvisibleText && context.GraphicsState.TextRenderingMode == 
                    Vintasoft.Imaging.Pdf.Content.TextRenderingMode.Invisible)
                {
                    context.GraphicsState.TextRenderingMode = Vintasoft.Imaging.Pdf.Content.TextRenderingMode.Fill;
                    base.DrawString(context, charCodes);
                    context.GraphicsState.TextRenderingMode = Vintasoft.Imaging.Pdf.Content.TextRenderingMode.Invisible;
                }
            }
                
            /// <summary>
            /// Draws path using specified pen.
            /// </summary>
            /// <param name="context">The rendering context.</param>
            /// <param name="path">The path to draw.</param>
            /// <param name="pen">The pen to use for drawing path.</param>
            public override void DrawPath(
                Vintasoft.Imaging.Pdf.PdfContentRenderingContext context,
                System.Drawing.Drawing2D.GraphicsPath path,
                System.Drawing.Pen pen)
            {
                // if path must be drawn
                if ((_drawPaths && !_stringDrawing) || (_drawText && _stringDrawing))
                {
                    // if path is not a path of text symbol
                    if (_linesWeigth != 1 && !_stringDrawing)
                    {
                        float oldWidth = pen.Width;
                        pen.Width *= _linesWeigth;
                        base.DrawPath(context, path, pen);
                        pen.Width = oldWidth;
                    }
                    else
                    {
                        base.DrawPath(context, path, pen);
                    }
                }
            }
                
            /// <summary>
            /// Fills path using specified brush.
            /// </summary>
            /// <param name="context">The rendering context.</param>
            /// <param name="path">The path to fill.</param>
            /// <param name="brush">The brush to use for filling path.</param>
            public override void FillPath(
                Vintasoft.Imaging.Pdf.PdfContentRenderingContext context,
                System.Drawing.Drawing2D.GraphicsPath path,
                System.Drawing.Brush brush)
            {
                // if path must be filled
                if ((_fillPaths && !_stringDrawing) || (_drawText && _stringDrawing))
                    base.FillPath(context, path, brush);
            }
                
            /// <summary>
            /// Fills path using specified pattern.
            /// </summary>
            /// <param name="context">The rendering context.</param>
            /// <param name="path">The path to fill.</param>
            /// <param name="pattern">The pattern to use for filling path.</param>
            public override void FillPath(
                Vintasoft.Imaging.Pdf.PdfContentRenderingContext context,
                System.Drawing.Drawing2D.GraphicsPath path,
                Vintasoft.Imaging.Pdf.Tree.Patterns.PdfGraphicalPattern pattern)
            {
                if (!_fillPathsUseShadingPatterns && pattern is Vintasoft.Imaging.Pdf.Tree.Patterns.ShadingPattern)
                    return;
                if (!_fillPathsUseTilingPatterns && pattern is Vintasoft.Imaging.Pdf.Tree.Patterns.TilingPattern)
                    return;
                base.FillPath(context, path, pattern);
            }
                
            /// <summary>
            /// Fills all visible areas using specified shading pattern.
            /// </summary>
            /// <param name="context">The rendering context.</param>
            /// <param name="shadingPattern">The shading pattern.</param>
            public override void FillArea(
                Vintasoft.Imaging.Pdf.PdfContentRenderingContext context,
                Vintasoft.Imaging.Pdf.Tree.ShadingPatterns.PdfShadingPattern shadingPattern)
            {
                if (_fillAreaUseShadingPatterns)
                    base.FillArea(context, shadingPattern);
            }
                
            /// <summary>
            /// Draws a form XObject.
            /// </summary>
            /// <param name="context">The rendering context.</param>
            /// <param name="formResource">The form XObject to draw.</param>
            public override void DrawFormXObject(
                Vintasoft.Imaging.Pdf.PdfContentRenderingContext context,
                Vintasoft.Imaging.Pdf.Tree.PdfFormXObjectResource formResource)
            {
                if (_drawForms)
                    base.DrawFormXObject(context, formResource);
            }
                
            /// <summary>
            /// Draws an annotation.
            /// </summary>
            /// <param name="context">The rendering context.</param>
            /// <param name="annotation">The annotation to draw.</param>
            /// <param name="appearanceForm">The annotation appearance form.</param>
            public override void DrawAnnotation(
                Vintasoft.Imaging.Pdf.PdfContentRenderingContext context,
                Vintasoft.Imaging.Pdf.Tree.Annotations.PdfAnnotation annotation,
                Vintasoft.Imaging.Pdf.Tree.PdfFormXObjectResource appearanceForm)
            {
                if (_drawAnnotations)
                    base.DrawAnnotation(context, annotation, appearanceForm);
            }
                
            /// <summary>
            /// Intersects current clip region with specified clip path.
            /// </summary>
            /// <param name="context">The rendering context.</param>
            /// <param name="clipPath">The clip path.</param>
            public override void IntersectClip(
                Vintasoft.Imaging.Pdf.PdfContentRenderingContext context,
                System.Drawing.Drawing2D.GraphicsPath clipPath)
            {
                if (_setClipPaths)
                    base.IntersectClip(context, clipPath);
            }
                
            /// <summary>
            /// Draws an image resource.
            /// </summary>
            /// <param name="context">The rendering context.</param>
            /// <param name="imageResource">The image XObject resource to draw.</param>
            public override void DrawImageResource(
                Vintasoft.Imaging.Pdf.PdfContentRenderingContext context,
                Vintasoft.Imaging.Pdf.Tree.PdfImageResource imageResource)
            {
                if (!_drawImages && !imageResource.IsInline)
                    return;
                if (!_drawInlineImages && imageResource.IsInline)
                    return;
                base.DrawImageResource(context, imageResource);
            }
                
            /// <summary>
            /// Draws an image.
            /// </summary>
            /// <param name="context">The rendering context.</param>
            /// <param name="image">The image to draw.</param>
            /// <param name="points">Array of three System.Drawing.PointF structures that
            /// define a parallelogram on rendering content where image must be drawn.</param>
            public override void DrawImage(
                Vintasoft.Imaging.Pdf.PdfContentRenderingContext context,
                Vintasoft.Imaging.VintasoftImage image,
                System.Drawing.PointF[] points)
            {
                // if image must be processed
                if (ImageProcessing != null &&
                    ImageProcessing.IsPixelFormatSupported(image.PixelFormat))
                {
                    lock (image)
                        using (Vintasoft.Imaging.VintasoftImage tempImage = ImageProcessing.Execute(image))
                            base.DrawImage(context, tempImage, points);
                }
                else
                {
                    base.DrawImage(context, image, points);
                }
            }
                
            /// <summary>
            /// Creates a new object that is a copy of this instance.
            /// </summary>
            /// <returns>
            /// A new object that is a copy of this instance.
            /// </returns>
            public override object Clone()
            {
                CustomContentRenderer result = new CustomContentRenderer();
                
                result._drawAnnotations = _drawAnnotations;
                result._drawForms = _drawForms;
                result._drawImages = _drawImages;
                result._drawInlineImages = _drawInlineImages;
                result._drawInvisibleText = _drawInvisibleText;
                result._drawPaths = _drawPaths;
                result._drawText = _drawText;
                result._fillAreaUseShadingPatterns = _fillAreaUseShadingPatterns;
                result._fillPaths = _fillPaths;
                result._fillPathsUseShadingPatterns = _fillPathsUseShadingPatterns;
                result._fillPathsUseTilingPatterns = _fillPathsUseTilingPatterns;
                if (_imageProcessing != null)
                    result._imageProcessing = 
                        (Vintasoft.Imaging.ImageProcessing.ProcessingCommandBase)_imageProcessing.Clone();
                result._linesWeigth = _linesWeigth;
                result._setClipPaths = _setClipPaths;
                
                return result;
            }
                
            #endregion
                
        }
                
    }
    Inheritance Hierarchy

    System.Object
       Vintasoft.Imaging.Pdf.PdfContentRenderer

    Requirements

    Target Platforms: Windows 10, Windows 8, Windows 7, Windows Vista, Windows XP, Windows Server 2012, Windows Server 2008, Windows Server 2003

    See Also