iTextSharp字体干扰普通字体 [英] iTextSharp Font interfering with common font
本文介绍了iTextSharp字体干扰普通字体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已将iTextSharp包含在我的项目中,以便能够创建PDF文件。
这是我的代码:
I have included iTextSharp in my project to have an ability to create a PDF file. This is my code for this:
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();
现在错误出现了:字体是System.Drawing.Font和iTextSharp之间的模糊参考.text.Font。
And now the error comes up saying: Font is an ambiguous reference between System.Drawing.Font and iTextSharp.text.Font.
这是红色下划线的代码:
This is the code which is red underlined:
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);
推荐答案
我假设你有这些使用
指令:
using System.Drawing;
using iTextSharp.text;
字体
在两个名称空间中,所以它是确实含糊不清。
Font
is in both namespaces, so it's indeed ambiguous.
您可以完全限定它,以解决歧义:
You can fully qualify it, to resolve ambiguity:
using System.Drawing;
using iTextSharp.text;
// ...
tempBox.Font = new System.Drawing.Font(FontFamily.GenericSansSerif,11.0F);
或者您可以指定别名:
using System.Drawing;
using Font = System.Drawing.Font;
using iTextSharp.text;
// ...
tempBox.Font = new Font(FontFamily.GenericSansSerif,11.0F);
这篇关于iTextSharp字体干扰普通字体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文