我正在添加出现错误的段落
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)
您正在 iTextSharp 应用程序中使用 iText 代码。您需要使用此答案中解释的规则将 iText 代码转换为 iTextSharp 代码:将 iText 代码转换为 iTextSharp 代码 https://stackoverflow.com/a/29586862/1622493.
如有疑问,请注意 iTextSharp 是一个开源库。您可以随时查阅源代码。对于您的情况,您可以检查该文件段落.cs https://github.com/itext/itextsharp/blob/master/src/core/iTextSharp/text/Paragraph.cs on Github https://github.com/itext/itextsharp.
你会注意到 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()
method:
p.FirstLineIndent = -indentation
如前所述,您应该将 Java 示例视为伪代码每当你击中不是以下成员问题,您应该应用以下规则之一来解决问题:
- Java中的方法以小写字母开头; .NET 中的方法以大写开头,因此当人们要求您使用 Java 代码作为伪代码并将 Java 转换为 .NET 时,您需要更改方法,例如
add()
and addCell()
into Add()
and AddCell()
.
- Java 中的成员变量使用 getter 和 setter 进行更改和查询; .NET 中的变量可以使用类似于属性的方法进行更改和查询。这意味着您需要更改线路,例如
cell.setBorder(border);
and border = cell.getBorder();
into cell.Border = border
and border = cell.Border
.
这是您之前的一个问题的答案的复制粘贴。正如您所看到的,这个答案也解决了您当前的问题。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)