iTextSharp.text.pdf.Type3Font.DefineGlyph C# (CSharp) Метод

DefineGlyph() публичный Метод

public DefineGlyph ( char c, float wx, float llx, float lly, float urx, float ury ) : PdfContentByte
c char
wx float
llx float
lly float
urx float
ury float
Результат PdfContentByte
        public PdfContentByte DefineGlyph(char c, float wx, float llx, float lly, float urx, float ury)
        {
            if (c == 0 || c > 255)
                throw new ArgumentException(MessageLocalization.GetComposedMessage("the.char.1.doesn.t.belong.in.this.type3.font", (int)c));
            usedSlot[c] = true;
            Type3Glyph glyph;
            char2glyph.TryGetValue(c, out glyph);
            if (glyph != null)
                return glyph;
            widths3[c] = (int)wx;
            if (!colorized) {
                if (float.IsNaN(this.llx)) {
                    this.llx = llx;
                    this.lly = lly;
                    this.urx = urx;
                    this.ury = ury;
                }
                else {
                    this.llx = Math.Min(this.llx, llx);
                    this.lly = Math.Min(this.lly, lly);
                    this.urx = Math.Max(this.urx, urx);
                    this.ury = Math.Max(this.ury, ury);
                }
            }
            glyph = new Type3Glyph(writer, pageResources, wx, llx, lly, urx, ury, colorized);
            char2glyph[c] = glyph;
            return glyph;
        }

Usage Example

Пример #1
0
// ===========================================================================
    public void Write(Stream stream) {
      // step 1
      using (Document document = new Document()) {
        // step 2
        PdfWriter writer = PdfWriter.GetInstance(document, stream);
        // step 3
        document.Open();
        // step 4
        Type3Font t3 = new Type3Font(writer, true);
        PdfContentByte d = t3.DefineGlyph('D', 600, 0, 0, 600, 700);
        d.SetColorStroke(new BaseColor(0xFF, 0x00, 0x00));
        d.SetColorFill(new GrayColor(0.7f));
        d.SetLineWidth(100);
        d.MoveTo(5, 5);
        d.LineTo(300, 695);
        d.LineTo(595, 5);
        d.ClosePathFillStroke();
        PdfContentByte s = t3.DefineGlyph('S', 600, 0, 0, 600, 700);
        s.SetColorStroke(new BaseColor(0x00, 0x80, 0x80));
        s.SetLineWidth(100);
        s.MoveTo(595,5);
        s.LineTo(5, 5);
        s.LineTo(300, 350);
        s.LineTo(5, 695);
        s.LineTo(595, 695);
        s.Stroke();
        Font f = new Font(t3, 12);
        Paragraph p = new Paragraph();
        p.Add("This is a String with a Type3 font that contains a fancy Delta (");
        p.Add(new Chunk("D", f));
        p.Add(") and a custom Sigma (");
        p.Add(new Chunk("S", f));
        p.Add(").");
        document.Add(p);        
      }
    }