|
Using C# PDF SDK
C# PDF Builder: How to add, apply Font resources to PDF file
C# Demo Code to add a font to adobe pdf file
Use standard 14 fonts
String outputFilePath = Program.RootPath + "\\" + "Sample14.pdf";
Document document = new Document();
PDFBuildHandler.Create(document, outputFilePath);
// open document
document.Open();
document.Add(new Paragraph("Font: Helvetica Regular", new Font(Font.FontFamily.Helvetica, 24F, Font.FontStyle.Regular)));
document.Add(new Paragraph("Font: Helvetica Bold", new Font(Font.FontFamily.Helvetica, 24F, Font.FontStyle.Bold)));
document.Add(new Paragraph("Font: Helvetica Italic", new Font(Font.FontFamily.Helvetica, 24F, Font.FontStyle.Italic)));
document.Add(new Paragraph("Font: Helvetica Bold Italic", new Font(Font.FontFamily.Helvetica, 24F, Font.FontStyle.BoldItalic)));
document.Add(new Paragraph("Font: Times New Roman Regular", new Font(Font.FontFamily.TimesRoman, 24F, Font.FontStyle.Regular)));
document.Add(new Paragraph("Font: Times New Roman Bold", new Font(Font.FontFamily.TimesRoman, 24F, Font.FontStyle.Bold)));
document.Add(new Paragraph("Font: Times New Roman Italic", new Font(Font.FontFamily.TimesRoman, 24F, Font.FontStyle.Italic)));
document.Add(new Paragraph("Font: Times New Roman Bold Italic", new Font(Font.FontFamily.TimesRoman, 24F, Font.FontStyle.BoldItalic)));
document.Add(new Paragraph("Font: Courier Regular", new Font(Font.FontFamily.Courier, 24F, Font.FontStyle.Regular)));
document.Add(new Paragraph("Font: Courier Bold", new Font(Font.FontFamily.Courier, 24F, Font.FontStyle.Bold)));
document.Add(new Paragraph("Font: Courier Italic", new Font(Font.FontFamily.Courier, 24F, Font.FontStyle.Italic)));
document.Add(new Paragraph("Font: Courier Bold Italic", new Font(Font.FontFamily.Courier, 24F, Font.FontStyle.BoldItalic)));
document.Add(new Paragraph("Font: Symbol", new Font(Font.FontFamily.Symbol, 24F, Font.FontStyle.Regular)));
document.Add(new Paragraph("Font: ZapfDingbats", new Font(Font.FontFamily.ZapfDingbats, 24F, Font.FontStyle.Regular)));
// close document and save to the output file
document.Close();
Create font by importing from a system font
String outputFilePath = Program.RootPath + "\\" + "Sample15.pdf";
Document document = new Document();
PDFBuildHandler.Create(document, outputFilePath);
// open document
document.Open();
Font aFont = Font.CreateFont(new System.Drawing.Font("Arial", 72F, System.Drawing.FontStyle.Regular), new Color(255, 0, 0));
document.Add(new Paragraph("Embedded Font: Arial, 72F, Rregular", aFont));
// close document and save to the output file
document.Close();
|