C# itextsharp是否支持courier新字体或c中的任何其他注册字体#
我已经准备好了pdf模板。在该模板上写入与pdf上的键匹配的值。需要使用itextsharp(pdfstamper)根据要求设置不同的字体和字体大小。 但我想设置各种不同的字体,如CourierNew、Arial和其他第三方注册的字体。如何使用itextsharp使用这些不同的字体。 请参考下面的代码片段。 以下代码段用于在pdf模板上写入值 要设置字体,请调用函数SetPrintFont,其中定义了不同的字体和字体大小。 请在同样的地方指导C# itextsharp是否支持courier新字体或c中的任何其他注册字体#,c#,fonts,itextsharp,C#,Fonts,Itextsharp,我已经准备好了pdf模板。在该模板上写入与pdf上的键匹配的值。需要使用itextsharp(pdfstamper)根据要求设置不同的字体和字体大小。 但我想设置各种不同的字体,如CourierNew、Arial和其他第三方注册的字体。如何使用itextsharp使用这些不同的字体。 请参考下面的代码片段。 以下代码段用于在pdf模板上写入值 要设置字体,请调用函数SetPrintFont,其中定义了不同的字体和字体大小。 请在同样的地方指导 var pdfReader = new PdfRea
var pdfReader = new PdfReader(filebyte);
var pdfStamper = new PdfStamper(pdfReader, new FileStream(pdfname, FileMode.Create));
AcroFields pdfFormFields = pdfStamper.AcroFields;
foreach (DictionaryEntry de in pdfReader.AcroFields.Fields)
{
//set the field to bold
pdfFormFields.SetFieldProperty(de.Key.ToString(), "textfont", font.BaseFont, null);
Regex regex = new Regex(@"^\d$");
if (regex.IsMatch(de.Key.ToString()))
{
//set the text of the form field
pdfFormFields.SetField(de.Key.ToString(), response.ResponseValues.ToString());
}
else
{
pdfFormFields.SetField(de.Key.ToString(), response.ResponseValues.ToString());
}
}
pdfStamper.FormFlattening = false;
pdfStamper.Close();
}您可以获得注册字体列表,如下所示:
ICollection<string> registeredFonts = iTextSharp.text.FontFactory.RegisteredFonts;
BaseFont
是iTextSharp.text.pdf
的成员。您可以获得注册字体列表,如下所示:
ICollection<string> registeredFonts = iTextSharp.text.FontFactory.RegisteredFonts;
BaseFont
是iTextSharp.text.pdf
@alreat的成员,我不能将Font对象与overContent.SetFontAndSize(Font,fontSize)一起使用;我需要使用BaseFont。@alreat我不能将Font对象与overContent一起使用。SetFontAndSize(Font,fontSize);我需要使用基本字体。