Reputation: 113
I am working with iTextSharp C#.net and dealing with RenderText method but I am getting "Can not apply indexing with[] to an expression of type method group." error in the below "Chunk Location" section. Here is my code:
public virtual void RenderText(TextRenderInfo renderInfo)
{
LineSegment segment = renderInfo.GetBaseline();
TextChunk location = new TextChunk(renderInfo.GetText(), segment.GetStartPoint(), segment.GetEndPoint(), renderInfo.GetSingleSpaceWidth());
**"//Chunk Location:"**
Debug.Print(renderInfo.GetText());
location.PosLeft =renderInfo.GetDescentLine().GetStartPoint[Vector.I1])); //In the below four lines getting the error.
location.PosRight = renderInfo.GetAscentLine().GetEndPoint[Vector.I1];
location.PosBottom = renderInfo.GetDescentLine().GetStartPoint[Vector.I2];
location.PosTop = renderInfo.GetAscentLine().GetEndPoint[Vector.I2];
//Chunk Font Size: (Height)
location.curFontSize = location.PosTop - segment.GetStartPoint()[Vector.I2];
//Use Font name and Size as Key in the SortedList
string StrKey = renderInfo.GetFont().PostscriptFontName + location.curFontSize.ToString();
//Add this font to ThisPdfDocFonts SortedList if it's not already present
if (!ThisPdfDocFonts.ContainsKey(StrKey))
{
ThisPdfDocFonts.Add(StrKey, renderInfo.GetFont());
}
//Store the SortedList index in this Chunk, so we can get it later
location.FontIndex = ThisPdfDocFonts.IndexOfKey(StrKey);
locationalResult.Add(location);
}
Upvotes: 0
Views: 1052
Reputation: 9489
You need to place the indexing after the method call.
location.PosLeft =renderInfo.GetDescentLine().GetStartPoint()[Vector.I1];
location.PosRight = renderInfo.GetAscentLine().GetEndPoint()[Vector.I1];
location.PosBottom = renderInfo.GetDescentLine().GetStartPoint()[Vector.I2];
location.PosTop = renderInfo.GetAscentLine().GetEndPoint()[Vector.I2];
Upvotes: 1