iTextSharp.text.pdf.PdfPageLabels.AddPageLabel C# (CSharp) Метод

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

public AddPageLabel ( int page, int numberStyle, string text, int firstPage ) : void
page int
numberStyle int
text string
firstPage int
Результат void
        public void AddPageLabel(int page, int numberStyle, string text, int firstPage)
        {
            if (page < 1 || firstPage < 1)
                throw new ArgumentException(MessageLocalization.GetComposedMessage("in.a.page.label.the.page.numbers.must.be.greater.or.equal.to.1"));
            PdfDictionary dic = new PdfDictionary();
            if (numberStyle >= 0 && numberStyle < numberingStyle.Length)
                dic.Put(PdfName.S, numberingStyle[numberStyle]);
            if (text != null)
                dic.Put(PdfName.P, new PdfString(text, PdfObject.TEXT_UNICODE));
            if (firstPage != 1)
                dic.Put(PdfName.ST, new PdfNumber(firstPage));
            map[page - 1] = dic;
        }

Same methods

PdfPageLabels::AddPageLabel ( PdfPageLabelFormat format ) : void
PdfPageLabels::AddPageLabel ( int page, int numberStyle ) : void
PdfPageLabels::AddPageLabel ( int page, int numberStyle, string text ) : void

Usage Example

Пример #1
0
// ---------------------------------------------------------------------------    
    /**
     * Creates a PDF document.
     */
    public byte[] CreatePdf() {
      using (MemoryStream ms = new MemoryStream()) { 
        using (var c =  AdoDB.Provider.CreateConnection()) {
          c.ConnectionString = AdoDB.CS;
          c.Open();
          // step 1
          using (Document document = new Document(PageSize.A5)) {
            // step 2
            PdfWriter writer = PdfWriter.GetInstance(document, ms);
            // step 3
            document.Open();
            // step 4
            int[] start = new int[3];
            for (int i = 0; i < 3; i++) {
              start[i] = writer.PageNumber;
              AddParagraphs(document, c, SQL[i], FIELD[i]);
              document.NewPage();
            }
            PdfPageLabels labels = new PdfPageLabels();
            labels.AddPageLabel(start[0], PdfPageLabels.UPPERCASE_LETTERS);
            labels.AddPageLabel(start[1], PdfPageLabels.DECIMAL_ARABIC_NUMERALS);
            labels.AddPageLabel(
              start[2], PdfPageLabels.DECIMAL_ARABIC_NUMERALS, 
              "Movies-", start[2] - start[1] + 1
            );
            writer.PageLabels = labels;
          }
          return ms.ToArray();
        }
      }
    }
All Usage Examples Of iTextSharp.text.pdf.PdfPageLabels::AddPageLabel