/// <summary> /// Adds new page to document /// </summary> /// <returns>Page</returns> public PdfPage AddPage(PdfUnit unit) { unit = unit ?? Unit ?? PdfUnit.Default; var size = PageSize != null?PageSize.ChangeUnits(unit) : PdfPageSize.Default(unit); return(AddPage(size)); }
private void button5_Click(object sender, EventArgs e) { var document = new PdfDocument(); document.Fonts.Add(PdfFont.Courier); var units = new[] { Tuple.Create("Point: 1 pt", PdfUnit.Point), Tuple.Create("Millimeter 2.83 pt", PdfUnit.Millimeter), Tuple.Create("Centimeter 28.3 pt", PdfUnit.Centimeter), Tuple.Create("Inch: 72 pt", PdfUnit.Inch), Tuple.Create("Custom: 100 pt", PdfUnit.ByName("My Custom 100", 100)) }; foreach (var unit in units) { var page = document.AddPage(new PdfSize(unit.Item2, 200, 300)); // create 200x300 units page page.AddRectangle(0, 280, 10, 290, PdfColor.Blue, 0.0F, PdfColor.White); var text = page.AddText(unit.Item1 + "(upper rectangle's size is 10x10 units)", 5, PdfFont.Courier); text.X = 0; text.Y = 270; } document.Save(@"test.pdf"); Process.Start(@"test.pdf"); }
public static PdfSize Default(PdfUnit unit = null) { unit = unit ?? PdfUnit.Default; return Letter(unit); }
public static PdfSize B5(PdfUnit unit = null) { unit = unit ?? PdfUnit.Default; return new PdfSize(unit, B5_WIDTH_POINTS / unit.Points, B5_HEIGHT_POINTS / unit.Points); }
public static PdfSize Letter(PdfUnit unit = null) { unit = unit ?? PdfUnit.Default; return new PdfSize(unit, LETTER_WIDTH_POINTS / unit.Points, LETTER_HEIGHT_POINTS / unit.Points); }
public static PdfSize B5(PdfUnit unit = null) { unit = unit ?? PdfUnit.Default; return(new PdfSize(unit, B5_WIDTH_POINTS / unit.Points, B5_HEIGHT_POINTS / unit.Points)); }
public static PdfSize Letter(PdfUnit unit = null) { unit = unit ?? PdfUnit.Default; return(new PdfSize(unit, LETTER_WIDTH_POINTS / unit.Points, LETTER_HEIGHT_POINTS / unit.Points)); }
public static PdfSize Default(PdfUnit unit = null) { unit = unit ?? PdfUnit.Default; return(Letter(unit)); }
public static PdfSize A4(PdfUnit unit = null) { unit = unit ?? PdfUnit.Default; return new PdfSize(unit, A4_WIDTH_POINTS / unit.Points, A4_HEIGHT_POINTS / unit.Points); }