示例#1
0
 public TextElement(string content, float fontSize, PdfFont font, PdfColor color)
 {
     Content = content;
       FontSize = fontSize;
       Font = font;
       Color = color;
 }
示例#2
0
 /// <summary>
 /// Writes PDF font into file stream
 /// </summary>
 /// <param name="font">PDF font</param>
 internal void Write(PdfFont font)
 {
     writeBeginObject(font.ObjectId);
       writeBeginDictionary();
       writeDictionaryEntry("/Type", "/Font");
       writeDictionaryEntry("/Subtype", "/TrueType");
       writeDictionaryEntry("/Name", font.GetResourceReference());
       writeDictionaryEntry("/BaseFont", BASE_FONT_FORMAT.Args(font.Name));
       writeDictionaryEntry("/Encoding", "/WinAnsiEncoding");
       writeEndDictionary();
       writeEndObject();
 }
示例#3
0
文件: PdfFont.cs 项目: itadapter/nfx
 public bool Equals(PdfFont other)
 {
     if (other == null) return false;
       return m_Name.EqualsOrdSenseCase(other.m_Name);
 }
示例#4
0
 public TextElement(string content, float fontSize, PdfFont font)
     : this(content, fontSize, font, PdfColor.Black)
 {
 }
示例#5
0
文件: PdfPage.cs 项目: itadapter/nfx
        /// <summary>
        /// Add raw text to the page
        /// </summary>
        public TextElement AddText(string text, float fontSize, PdfFont font, PdfColor foreground)
        {
            var element = new TextElement(text, fontSize, font, foreground);
              Add(element);

              return element;
        }
示例#6
0
文件: PdfPage.cs 项目: itadapter/nfx
 /// <summary>
 /// Add raw text to the page
 /// </summary>
 public TextElement AddText(string text, float fontSize, PdfFont font)
 {
     return this.AddText(text, fontSize, font, PdfColor.Black);
 }
示例#7
0
文件: PdfFont.cs 项目: jorik041/nfx
 public bool Equals(PdfFont other)
 {
   if (other == null) return false;
   return string.Equals(this.m_Name, other.m_Name, StringComparison.Ordinal);
 }
示例#8
0
 /// <summary>
 /// Add raw text to the page
 /// </summary>
 public TextElement AddText(string text, float fontSize, PdfFont font)
 {
     return(this.AddText(text, fontSize, font, PdfColor.Black));
 }
示例#9
0
    private void button7_Click(object sender, EventArgs e)
    {
      var document = new PdfDocument();
      document.Fonts.Add(PdfFont.Helvetica);
      document.Fonts.Add(PdfFont.HelveticaBold);
      document.Fonts.Add(PdfFont.HelveticaOblique);
      document.Fonts.Add(PdfFont.HelveticaBoldOblique);
      document.Fonts.Add(PdfFont.Courier);
      document.Fonts.Add(PdfFont.CourierBold);
      document.Fonts.Add(PdfFont.CourierOblique);
      document.Fonts.Add(PdfFont.CourierBoldOblique);
      document.Fonts.Add(PdfFont.Times);
      document.Fonts.Add(PdfFont.TimesBold);
      document.Fonts.Add(PdfFont.TimesItalic);
      document.Fonts.Add(PdfFont.TimesBoldItalic);

      var arial = new PdfFont("Arial");
      var verdana = new PdfFont("Verdana");
      var calibri = new PdfFont("Calibri");
      var segoeUI = new PdfFont("SegoeUI");
      var tahoma = new PdfFont("Tahoma");
      var stencil = new PdfFont("Stencil");
      var castellar = new PdfFont("Castellar");
      var monaco = new PdfFont("Monaco");
      document.Fonts.Add(arial);
      document.Fonts.Add(verdana);
      document.Fonts.Add(calibri);
      document.Fonts.Add(segoeUI);
      document.Fonts.Add(tahoma);
      document.Fonts.Add(stencil);
      document.Fonts.Add(castellar);
      document.Fonts.Add(monaco);

      var page = document.AddPage();

      var predefinedFonts = new Dictionary<string, PdfFont>
      {
         { "Helvetica",             PdfFont.Helvetica },
         { "Helvetica-Bold",        PdfFont.HelveticaBold },
         { "Helvetica-Oblique",     PdfFont.HelveticaOblique },
         { "Helvetica-BoldOblique", PdfFont.HelveticaBoldOblique },
         { "Courier",               PdfFont.Courier },
         { "Courier-Bold",          PdfFont.CourierBold },
         { "Courier-Oblique",       PdfFont.CourierOblique },
         { "Courier-BoldOblique",   PdfFont.CourierBoldOblique },
         { "Times-Roman",           PdfFont.Times },
         { "Times-Bold",            PdfFont.TimesBold },
         { "Times-Italic",          PdfFont.TimesItalic },
         { "Times-BoldItalic",      PdfFont.TimesBoldItalic }
      };

      var otherFonts = new Dictionary<string, PdfFont>
      {
        { "Arial",     arial },
        { "Verdana",   verdana },
        { "Calibri",   calibri },
        { "SegoeUI",   segoeUI },
        { "Tahoma",    tahoma },
        { "Stencil",   stencil },
        { "Castellar", castellar },
        { "Monaco",  monaco }
      };

      var text = page.AddText(@"Predefined Fonts (Courier is monospaced):", 20, PdfFont.Times);
      text.X = 30;
      text.Y = 730;

      var top = text.Y - 10;
      foreach (var font in predefinedFonts)
      {
        top -= 12;

        text = page.AddText(font.Key + ": ", 10, PdfFont.Times);
        text.X = 30;
        text.Y = top;

        text = page.AddText("Lenin is alive", 10, font.Value);
        text.X = 140;
        text.Y = top;
      }

      top -= 40;

      text = page.AddText(@"Some other Fonts (Monaco is monospaced):", 20, PdfFont.Times);
      text.X = 50;
      text.Y = top;

      top -= 10;
      foreach (var font in otherFonts)
      {
        top -= 12;

        text = page.AddText(font.Key + ": ", 10, PdfFont.Times);
        text.X = 30;
        text.Y = top;

        text = page.AddText("Lenin is alive", 10, font.Value);
        text.X = 140;
        text.Y = top;
      }

      document.Save(@"test.pdf");

      Process.Start(@"test.pdf");
    }