-1

I am adding paragraph where I am getting error

p.setindentationLeft is not a member of itextsharp.text.paragraph.

 Dim bf As BaseFont = BaseFont.CreateFont()
 Dim p As New Paragraph(Label + CONTENT, New Font(bf, 12))
 Dim indentation As Single = bf.GetWidthPoint(Label, 12)
 p.setIndentationLeft(indentation)
 p.setFirstLineIndent(-indentation)
 Document.Add(p)
 Document.Add(Chunk.NEWLINE)  
Sunil Bhagwat
  • 137
  • 2
  • 13

1 Answers1

1

You are using iText code in an iTextSharp application. You need to convert the iText code to iTextSharp code using the rules explained in this answer: converting iText code to iTextSharp code.

When in doubt, please not that iTextSharp is an open source library. You can always consult the source code. In your case, you can check the file Paragraph.cs on Github.

You'll notice that the Java method setIndentationLeft() is actually implemented like this:

/// <summary>
/// Get/set the indentation of this paragraph on the left side.
/// </summary>
/// <value>a float</value>
virtual public float IndentationLeft {
    get {
        return indentationLeft;
    }
    set {
        this.indentationLeft = value;
    }
}

Which means that you need this in your code:

p.IndentationLeft = indentation

The same goes for the setFirstLineIndent() method:

p.FirstLineIndent = -indentation

As mentioned before, you should treat the Java examples as if it were pseudo code and whenever you hit a not a member of problem, you should apply one of the following rules to solve the problem:

  • Methods in Java start with lower case; methods in .NET start with upper case, so when people ask you to use Java code as pseudo code and to convert Java to .NET, you need to change methods such as add() and addCell() into Add() and AddCell().
  • Member-variables in Java are changed and consulted using getters and setters; variables in .NET are changed and consulted using methods that look like properties. This means the you need to change lines such as cell.setBorder(border); and border = cell.getBorder(); into cell.Border = border and border = cell.Border.

This is a copy paste of an answer to one of your earlier questions. As you can see, this answer also solves your current problem.

Community
  • 1
  • 1
Bruno Lowagie
  • 75,994
  • 9
  • 109
  • 165