我正在添加段落,我收到错误
p.setindentationLeft不是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)
答案 0 :(得分:1)
您在iTextSharp应用程序中使用iText代码。您需要使用此答案中解释的规则将iText代码转换为iTextSharp代码:converting iText code to iTextSharp code。
如有疑问,请注意iTextSharp是一个开源库。您可以随时查阅源代码。在您的情况下,您可以在Paragraph.cs上查看文件Github。
您会注意到Java方法setIndentationLeft()
实际上是这样实现的:
/// <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;
}
}
这意味着您需要在代码中使用此功能:
p.IndentationLeft = indentation
setFirstLineIndent()
方法也是如此:
p.FirstLineIndent = -indentation
如前所述,您应该将Java示例视为伪代码,并且每当您点击而不是成员问题时,您应该应用其中一个遵循以下规则来解决问题:
add()
和addCell()
等方法更改为{{ 1}}和Add()
。AddCell()
和cell.setBorder(border);
等行更改为border = cell.getBorder();
和cell.Border = border
。这是对您之前的一个问题的答案的复制粘贴。如您所见,这个答案也解决了您当前的问题。