Exemple #1
0
            public override void OnEndPage(PdfWriter writer, Document doc)
            {
                BaseColor grey = new BaseColor(128, 128, 128);
                 iTextSharp.text.Font font = FontFactory.GetFont("Arial", 11, iTextSharp.text.Font.NORMAL, grey);
                 // cell height
                 float cellHeight = doc.TopMargin;
                 // PDF document size
                 iTextSharp.text.Rectangle page = doc.PageSize;

                 // create two column table
                 PdfPTable head = new PdfPTable(2);
                 head.TotalWidth = page.Width - 30;
                 string url = "logo.jpg";
                iTextSharp.text.Image img = iTextSharp.text.Image.GetInstance(url);
                img.ScaleAbsolute(175, 45);
                img.Alignment = Element.ALIGN_LEFT;
                PdfPTable logo = new PdfPTable(1);
                 PdfPCell c = new PdfPCell(img, false);
                 c.HorizontalAlignment = Element.ALIGN_LEFT;
                 //c.FixedHeight = cellHeight;
                 c.Border = PdfPCell.NO_BORDER;
                 logo.AddCell(c);
                 BaseColor color = new BaseColor(249, 79, 1);
                 Paragraph heade = new Paragraph("MANTA & ALEX LTD", FontFactory.GetFont(BaseFont.TIMES_BOLD, 17, color)) { Alignment = Element.ALIGN_RIGHT };
                 c = new PdfPCell(new Phrase(heade));
                 c.HorizontalAlignment = Element.ALIGN_LEFT;
                 c.Border = PdfPCell.NO_BORDER;
                 logo.AddCell(c);
                 c = new PdfPCell(logo);
                 c.HorizontalAlignment = Element.ALIGN_LEFT;
                 c.Border = PdfPCell.NO_BORDER;
                 head.AddCell(c);
                 PdfPTable t = new PdfPTable(1);
                 Paragraph header = new Paragraph("WAGE LIST", FontFactory.GetFont(BaseFont.TIMES_BOLD, 17)) { Alignment = Element.ALIGN_RIGHT };
                 Paragraph header1 = new Paragraph("33 THE CHASE, EDGWARE, MIDDLESEX \nLONDON HA8 5DW \nTel/Fax No 02032096071 \nMobile No: 07792820031, 07800963526 \nEmail [email protected] \n\n\n\n", FontFactory.GetFont(BaseFont.TIMES_BOLD, 12, BaseColor.BLACK)) { Alignment = Element.ALIGN_RIGHT };
                 Paragraph proces = new Paragraph("Proces date: " + pdate, FontFactory.GetFont(BaseFont.TIMES_ROMAN, 12)) { Alignment = Element.ALIGN_RIGHT };
                 Paragraph week = new Paragraph(" Week: " + weeek, FontFactory.GetFont(BaseFont.TIMES_ROMAN, 12)) { Alignment = Element.ALIGN_RIGHT };
                 Paragraph period = new Paragraph("Period: " + start + " - " + end + "\n\n", FontFactory.GetFont(BaseFont.TIMES_ROMAN, 12)) { Alignment = Element.ALIGN_RIGHT };
                 c = new PdfPCell(new Phrase(header));
                 c.HorizontalAlignment = Element.ALIGN_RIGHT;
                 c.Border = PdfPCell.NO_BORDER;
                 t.AddCell(c);
                 c = new PdfPCell(new Phrase(proces));
                 c.HorizontalAlignment = Element.ALIGN_RIGHT;
                 c.Border = PdfPCell.NO_BORDER;
                 t.AddCell(c);
                 c = new PdfPCell(new Phrase(week));
                 c.HorizontalAlignment = Element.ALIGN_RIGHT;
                 c.Border = PdfPCell.NO_BORDER;
                 t.AddCell(c);
                 c = new PdfPCell(new Phrase(period));
                 c.HorizontalAlignment = Element.ALIGN_RIGHT;
                 c.Border = PdfPCell.NO_BORDER;
                 t.AddCell(c);
                 c = new PdfPCell(t);
                 c.HorizontalAlignment = Element.ALIGN_RIGHT;
                 c.Border = PdfPCell.NO_BORDER;
                 head.AddCell(c);
                 head.WriteSelectedRows(0, -1, 15, page.Height - cellHeight + 115, writer.DirectContent);
                 //tbl footer
                 PdfPTable footerTbl = new PdfPTable(1);
                 footerTbl.TotalWidth = doc.PageSize.Width;
                 //numero de la page

                 Chunk myFooter = new Chunk("Page " + (doc.PageNumber), FontFactory.GetFont(FontFactory.HELVETICA_OBLIQUE, 8, grey));
                 PdfPCell footer = new PdfPCell(new Phrase(myFooter));
                 footer.Border = iTextSharp.text.Rectangle.NO_BORDER;
                 footer.HorizontalAlignment = Element.ALIGN_CENTER;
                 footerTbl.AddCell(footer);
                 footerTbl.WriteSelectedRows(0, -1, 0, (doc.BottomMargin + 3), writer.DirectContent);
                 //doc.PageSize.Width = doc.PageSize.Width - 200;
                 writer.SetMargins(25, 25, 500, 60);
                 PdfPCell cel = new PdfPCell();
                 doc.Add(cel);
                 doc.Add(cel);
                 doc.Add(cel);
                 doc.Add(cel);
                 doc.Add(cel);
            }