iTextSharp.text.Rectangle.GetRectangle C# (CSharp) Метод

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

Gets a Rectangle that is altered to fit on the page.
public GetRectangle ( float top, float bottom ) : Rectangle
top float the top position
bottom float the bottom position
Результат Rectangle
        public Rectangle GetRectangle(float top, float bottom)
        {
            Rectangle tmp = new Rectangle(this);
            if (this.Top > top) {
                tmp.Top = top;
                tmp.Border = border - (border & TOP_BORDER);
            }
            if (Bottom < bottom) {
                tmp.Bottom = bottom;
                tmp.Border = border - (border & BOTTOM_BORDER);
            }
            return tmp;
        }

Usage Example

Пример #1
0
        public void AddPageNumber(string str, string displaytext)
        {
            byte[] bytes = File.ReadAllBytes(str);

            iTextSharp.text.Font blackFont = FontFactory.GetFont("Arial", 6, iTextSharp.text.Font.NORMAL, BaseColor.BLACK);

            using (var stream = new MemoryStream())
            {
                stream.Flush();
                System.Windows.Forms.Application.DoEvents();
                PdfReader reader = new PdfReader(bytes);
                PdfReader.unethicalreading = true;
                Paragraph p   = new Paragraph();
                Document  doc = new Document();
                using (PdfStamper stamper = new PdfStamper(reader, stream))
                {
                    System.Windows.Forms.Application.DoEvents();

                    //PdfContentByte canvas = stamper.GetOverContent(1);
                    //iTextSharp.text.Rectangle size = reader.GetPageSizeWithRotation(1);
                    int pages = reader.NumberOfPages;
                    for (int i = 1; i <= pages; i++)
                    {
                        iTextSharp.text.Rectangle mediabox = reader.GetPageSize(i);
                        float x, y;
                        x = mediabox.Height;
                        y = mediabox.Width;

                        iTextSharp.text.Rectangle cropBox = reader.GetCropBox(i);
                        cropBox.GetRectangle(y - 1000, x - 50);
                        iTextSharp.text.Rectangle bottomRight = new iTextSharp.text.Rectangle(cropBox.GetRight(199), cropBox.Bottom, cropBox.Right, cropBox.GetBottom(18));
                        //TextField tf = new TextField(stamper.Writer, new iTextSharp.text.Rectangle(0, 0, 300, 100), displaytext);
                        ////Change the orientation of the text
                        //tf.Rotation = 0;

                        EmptyTextBoxSimple(stamper, i, bottomRight, BaseColor.WHITE);
                        ColumnText columnText = GenerateTextBox(stamper, i, bottomRight);
                        columnText.AddText(new Phrase(displaytext.ToString(), blackFont));
                        columnText.Go();
                    }
                }

                bytes = stream.ToArray();
                //stream.Flush();
            }
            System.Threading.Thread.Sleep(200);
            File.WriteAllBytes(str, bytes);
        }
All Usage Examples Of iTextSharp.text.Rectangle::GetRectangle