// Example with an image and embedded font ( subset ). public static void Example2() { byte [] myImageBytes = Util.GetFile(@"c:\PdfFiles\666.png"); byte [] freeSansBytes = Util.GetFile(@"c:\PdfFiles\FreeSans.ttf"); using (IO.FileStream fs = IO.File.Create("Example2.pdf")) { PdfWriter w = new Pdf.PdfWriter(); w.Title = "Graphics and embedded font example"; w.Initialise(fs); PdfImage myImage = ImageUtil.Add(w, myImageBytes); w.LineAdvance = myImage.Height / 2 + 10; // Make space for the image w.NewLine(); w.LineAdvance = 15; // Restore LineAdvance to default value. w.CP.DrawImage(myImage, w.CP.X, w.CP.Y, 0.5f); PdfFont freeSans = new TrueTypeFont("DJGTGD+Sans", freeSansBytes); w.SetFont(freeSans, 12); w.Txt("Hello world"); w.Finish(); } }
// Example with an embedded font ( subset ). public static void Example3() { byte [] freeSansBytes = Util.GetFile(@"c:\PdfFiles\FreeSans.ttf"); using (IO.FileStream fs = IO.File.Create("Example3.pdf")) { PdfWriter w = new Pdf.PdfWriter(); w.Compress = false; w.Title = "Embedded font example"; w.Initialise(fs); PdfFont freeSans = new TrueTypeFont("DJGTGD+Sans", freeSansBytes); w.SetFont(freeSans, 12); w.Txt("Hello world"); w.Finish(); } }
// Example usage public static void Example1() { using (IO.FileStream fs = IO.File.Create("Example1.pdf")) { PdfWriter w = new Pdf.PdfWriter(); w.Title = "Hello World"; w.Fonts = Pdf.StandardFontFamily.Times(); // Sets font family ( optional, default is Helvetica ). // Default PageLayout (width, height, margins) may be adjusted here. w.SetColumns(3, 5); // Sets pages to be formatted as 3 columns, 5pt space between columns. w.Initialise(fs); // Creates first page, ready to write text. // Optional style settings. w.Justify = 2; // Causes text to be justified. w.SetFont(w.Fonts[0], 9); // Sets font and font size. for (int i = 0; i < 100; i += 1) { w.Txt("Some arbitrary text which is long enough to demonstrate word wrapping. "); } w.Finish(); } }