Results 1 to 9 of 9

Thread: Help needed translating c# code

Threaded View

  1. #5
    Frenzied Member
    Join Date
    Jul 2011
    Location
    UK
    Posts
    1,335

    Re: Help needed translating c# code

    The problem lies in the overridden Attach method.

    As it stands, it returns True if text is about to be rendered using the Calibri Font, and False for all other circumstances.

    Returning True allows the processing to continue, so all the callibri text is processed, but returning False stops further processing so whilst the text in Arial font is not rendered, the clipping rectangle is also ignored.

    What it should be doing is returning False when text is about to be rendered in a font that is NOT Calibri (so rendering of that text does not happen). For all other circumstances, the base class's Accept method should be called to check if processing should be allowed to continue according to any other filters in effect, and then the result of that call to the base method is what needs to be returned by the overridden method:
    Code:
    Public Overrides Function Accept(ByVal data As IEventData, ByVal type As EventType) As Boolean
    
    	'   ignore all text rendering where the Font is not Calibri
    	If type.Equals(EventType.RENDER_TEXT) Then
    		Dim renderInfo As TextRenderInfo = DirectCast(data, TextRenderInfo)
    
    		Dim font As PdfFont = renderInfo.GetFont()
    		If font IsNot Nothing Then
    			Dim fontName As String = font.GetFontProgram().GetFontNames().GetFontName()
    			If Not fontName.EndsWith("Calibri") Then
    				'   font is not Calibri so
    				'   do not continue processing this TEXT RENDER event
    				Return False
    			End If
    		End If
    
    	End If
    
    	'   check if the base class allows processing of everything else
    	Return MyBase.Accept(data, type)
    End Function
    Last edited by Inferrd; Mar 16th, 2021 at 03:52 PM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width