我已将iTextSharp包含在我的项目中,以便能够创建PDF文件.这是我的代码:
Document document = new Document(iTextSharp.text.PageSize.LETTER,20,20,42,35);
PdfWriter writer =
PdfWriter.GetInstance(document,newFileStream("Test.pdf",FileMode.Create));
document.Open();
Paragraph paragraph = new Paragraph("Test");
document.Add(paragraph);
document.Close();
Run Code Online (Sandbox Code Playgroud)
现在错误出现了:Font是System.Drawing.Font和iTextSharp.text.Font之间的模糊引用.
这是带有红色下划线的代码:
RichTextBox tempBox = new RichTextBox();
tempBox.Size = new Size(650,60);
tempBox.Font = new Font(FontFamily.GenericSansSerif,11.0F); //here is error
flowLayoutPanel1.Controls.Add(tempBox);
Run Code Online (Sandbox Code Playgroud)
我假设你有这些using指令:
using System.Drawing;
using iTextSharp.text;
Run Code Online (Sandbox Code Playgroud)
Font 在两个命名空间中,所以它确实是模糊的.
您可以完全限定它,以解决歧义:
using System.Drawing;
using iTextSharp.text;
// ...
tempBox.Font = new System.Drawing.Font(FontFamily.GenericSansSerif,11.0F);
Run Code Online (Sandbox Code Playgroud)
或者您可以指定别名:
using System.Drawing;
using Font = System.Drawing.Font;
using iTextSharp.text;
// ...
tempBox.Font = new Font(FontFamily.GenericSansSerif,11.0F);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
874 次 |
| 最近记录: |