![]() ![]() ![]() We can use ColumnText to format text in column wise. ![]() To get the location for header and footer, we need to create a rectangle and get location by using Rectangle.getLeft, Rectangle.getRight, Rectangle.getTop and Rectangle.getBottom methods. While defining these methods we do not need to use Document.add() method. To add header and footer, we need to override onStartPage and onEndPage methods. Some event methods of PdfPageEventHelper are as below PdfPageEventHelper class has different event methods for PDF. Find the complete explanation as below.Ĭreate an Event Class Extending PdfPageEventHelper To add header and footer we need to create a class extending PdfPageEventHelper and override onStartPage and onEndPage methods. iText provides PdfPageEventHelper class that has different event methods that is called while writing PDF. ![]() Th1.AddCell(new Cell().SetTextAlignment(TextAlignment.RIGHT).SetBorder(Border.NO_BORDER).SetFont(regular).SetFontSize(10f).Add(new Paragraph("\t")).ITextThis page will provide the tutorial for how to add header and footer in every page of PDF using iText in java. Th1.AddCell(new Cell().SetTextAlignment(TextAlignment.CENTER).SetBorder(Border.NO_BORDER).SetFont(regular).SetFontSize(10f).Add(new Paragraph(txt1))).SetTextAlignment(TextAlignment.CENTER) Th1.AddCell(new Cell().SetTextAlignment(TextAlignment.LEFT).SetBorder(Border.NO_BORDER).SetFont(regular).SetFontSize(10f).Add(new Paragraph(""))).SetTextAlignment(TextAlignment.LEFT) Th1.SetWidth(UnitValue.CreatePercentValue(100)) th1 = new (UnitValue.CreatePercentArray(3)).UseAllAvailableWidth() ImageData imageDatawmf = ImageDataFactory.Create(wmfBarcodeFileName) String wmfBarcodeFileName = ReportDirPath ().ToString() ".wmf" Į.CreateBarCodeImage(proBarcodeString, wmfBarcodeFileName. LineSeparator lne = new LineSeparator(new SolidLine()) Th.AddCell(new Cell().SetTextAlignment(TextAlignment.RIGHT).SetBorder(Border.NO_BORDER).SetFont(regular).SetFontSize(10f).Add(new Paragraph(test2))) Th.AddCell(new Cell().SetTextAlignment(TextAlignment.CENTER).SetBorder(Border.NO_BORDER).SetFont(regular).SetFontSize(10f).Add(new Paragraph("\n").Add(new Paragraph(text1)))) Th.AddCell(new Cell().SetTextAlignment(TextAlignment.LEFT).SetBorder(Border.NO_BORDER).SetFont(regular).SetFontSize(10f).Add(new Paragraph(""))) Th.SetHorizontalAlignment(HorizontalAlignment.CENTER) Text test2 = new Text("Customer Order Detail" "\n" "OrderNo:" KV.Value.OrderNumber).SetBold().SetFontSize(12f) th = new (UnitValue.CreatePercentArray(3)).UseAllAvailableWidth() String proBarcodeString = KV.Value.OrderNumber "P" Ĭanvas canvas = new Canvas(pdfCanvas, rectangle) Rectangle rectangle = new Rectangle(30, 770, 120, 60) PdfCanvas pdfCanvas = new PdfCanvas(page) ImageData imageData = ImageDataFactory.Create(imageSource logoFileName) If (System.IO.File.Exists(LogoDirPath logoFileName)) Rectangle rectangle = page.GetPageSize() PdfDocument pdf = docEvent.GetDocument() PdfFont bold = PdfFontFactory.CreateFont(StandardFonts.HELVETICA_BOLD) PdfDocumentEvent docEvent = regular = PdfFontFactory.CreateFont(StandardFonts.HELVETICA) Public virtual void HandleEvent(Event page = pdf.AddNewPage() įoreach (KeyValuePair KV in Contentvalue) Public Header(Document doc, Dictionary Content) But in next page only image logo is showing other line and table is not showing. So in first page header showing correctly. I am creating header in text 7, in this header image, line and table ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |