예제 #1
0
    public override void OnEndPage(PdfWriter writer, Document document)
    {
        base.OnEndPage(writer, document);
        cb       = writer.DirectContent;
        template = cb.CreateTemplate(50, 50);
        BaseFont font  = BaseFont.CreateFont();
        int      pageN = writer.PageNumber;
        String   text  = pageN.ToString();
        float    len   = font.GetWidthPoint(text, 9);

        iTextSharp.text.Rectangle pageSize = document.PageSize;
        // cb.SetRGBColorFill(100, 100, 100);

        ;
        cb.BeginText();
        cb.SetFontAndSize(font, 9);
        cb.SetTextMatrix(document.LeftMargin, pageSize.GetBottom(document.BottomMargin));
        //cb.ShowText(text);

        if (pageN > 1 && TotalNumber == 0)
        {
            cb.ShowTextAligned(Element.ALIGN_CENTER, (pageN - 6).ToString(), 300f, 10f, 0);
        }
        cb.EndText();
        cb.AddTemplate(template, document.LeftMargin + len, pageSize.GetBottom(document.BottomMargin));
    }
        public void CellLayout(PdfPCell cell, iTextSharp.text.Rectangle rect, PdfContentByte[] canvases)
        {
            //draw line 1
            PdfContentByte cb = writer.DirectContent;

            cb.MoveTo(rect.GetLeft(0), rect.GetBottom(0) - padding);
            cb.LineTo(rect.GetRight(0), rect.GetBottom(0) - padding);
            //draw line 2
            cb.MoveTo(rect.GetLeft(0), rect.GetBottom(0) - padding - 2);
            cb.LineTo(rect.GetRight(0), rect.GetBottom(0) - padding - 2);
            cb.Stroke();
        }
예제 #3
0
 public override void OnEndPage(PdfWriter writer, Document document)
 {
     Font arial = FontFactory.GetFont("Arial", 10, GrayColor.GRAY);
     base.OnEndPage(writer, document);
     int pageN = writer.PageNumber;
     BaseFont bf = BaseFont.CreateFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
     string text = String.Format("Page {0} of ", pageN.ToString());
     float len = bf.GetWidthPoint(text, 8);
     iTextSharp.text.Rectangle pageSize = document.PageSize;
     cb.SetRGBColorFill(100, 100, 100);
     cb.BeginText();
     cb.SetFontAndSize(bf, 10);
     cb.SetTextMatrix(10, pageSize.GetBottom(10));
     cb.ShowText(text);
     cb.EndText();
     cb.AddTemplate(template, 60, pageSize.GetBottom(10));
 }
예제 #4
0
        public override void OnEndPage(PdfWriter writer, iTextSharp.text.Document document)
        {
            base.OnEndPage(writer, document);

            int    pageN = writer.PageNumber;
            String text  = "Page " + pageN.ToString() + " of ";
            float  len   = this.RunDateFont.BaseFont.GetWidthPoint(text, this.RunDateFont.Size);

            iTextSharp.text.Rectangle pageSize = document.PageSize;

            cb.SetRGBColorFill(100, 100, 100);

            cb.BeginText();
            cb.SetFontAndSize(this.RunDateFont.BaseFont, this.RunDateFont.Size);
            cb.SetTextMatrix(document.LeftMargin, pageSize.GetBottom(document.BottomMargin));
            cb.ShowText(text);

            cb.EndText();

            cb.AddTemplate(template, document.LeftMargin + len, pageSize.GetBottom(document.BottomMargin));
        }
예제 #5
0
        /// <summary>
        /// Metodo para manejar los eventos de las celdas
        /// </summary>
        /// <param name="celda"></param>
        /// <param name="posicion"></param>
        /// <param name="canvass"></param>
        public void CellLayout(PdfPCell celda, iTextSharp.text.Rectangle posicion
                               , PdfContentByte[] canvass)
        {
            float          x1     = posicion.GetLeft(0) + 2;
            float          x2     = posicion.GetRight(0) - 2;
            float          y1     = posicion.GetTop(0) - 2;
            float          y2     = posicion.GetBottom(0) + 2;
            PdfContentByte canvas = canvass[PdfPTable.LINECANVAS];

            canvas.Rectangle(x1, y1, x2 - x1, y2 - y1);
            canvas.Stroke();
            canvas.ResetRGBColorStroke();
        }
    public void CellLayout(PdfPCell cell, iTextSharp.text.Rectangle rect, PdfContentByte[] canvases)
    {
        //Create the field's rectangle based on the current cell and requested padded
        var newRect = new PdfRectangle(rect.GetLeft(Padding), rect.GetBottom(Padding), rect.GetRight(Padding), rect.GetTop(Padding));

        //Set the appearance's rectangle to the same as the box
        Field.Box = newRect.Rectangle;
        //Get the raw field
        var tf = this.Field.GetTextField();

        //Change the field's rectangle
        tf.Put(PdfName.RECT, newRect);
        //Add the annotation to the writer
        Writer.AddAnnotation(tf);
    }