예제 #1
0
        /// <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));
        }
예제 #2
0
        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");
        }
예제 #3
0
 public static PdfSize Default(PdfUnit unit = null)
 {
     unit = unit ?? PdfUnit.Default;
       return Letter(unit);
 }
예제 #4
0
 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);
 }
예제 #5
0
 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);
 }
예제 #6
0
 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));
 }
예제 #7
0
 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));
 }
예제 #8
0
 public static PdfSize Default(PdfUnit unit = null)
 {
     unit = unit ?? PdfUnit.Default;
     return(Letter(unit));
 }
예제 #9
0
 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);
 }