![]() ![]() You can define a Rectangle and add objects such as Paragraph, List, PdfPTable. See my answer to Adding footer to existing PDF If you want to add text at absolute positions, iText offers convenience methods and objects such as ColumnText. You can also trigger a new page yourself using: document.NewPage() The beauty of adding these objects to a Document using the Add() method, is that a new page gets triggered automagically as soon as a page is full. Instead you can use objects such as Paragraph, List, PdfPTable. If you don't know the PDF reference (ISO 32000-1) by heart, you should avoid code like this. If is very easy to make mistakes, as shown in this question: What is causing syntax errors in a page created with iText? In your code, you are adding text at absolute positions by introducing PDF syntax, such as BeginText() ( BT) / EndText() ( ET) / SetFontAndSize() ( Tf). The first thing you'll see, is the most popular iText example (which I am porting to C# for your convenience): // step 1įileStream fs = new FileStream("hello.pdf", FileMode.Create) ĭocument.Add(new Paragraph("Hello World!")) Please go to the official documentation and click Q&A to go to the most frequently asked questions. // close the streams and voilá the file should be changed :) PdfImportedPage page = writer.GetImportedPage(reader, 1) ![]() reader = new PdfReader(oldFile) //old file // create the new page and add it to the pdf If (word.ToString().ToUpper().Contains("(REV")=false & st = false)Ĭb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, "SAG & TENSION CHARTS", 80, height, 0) Ĭb.SetFontAndSize(BaseFont.CreateFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED), 11) Ĭb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, word.ToString().ToUpper(), 80, height, 0) Ĭb.ShowTextAligned(PdfContentByte.ALIGN_CENTER, ".", 335, height, 0) Ĭb.ShowTextAligned(PdfContentByte.ALIGN_RIGHT, totalPage.ToString(), 500, height, 0) put the alignment and coordinates hereĬb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, "CONSTRUCTION PRINTS", 80, height, 0) If (word.ToString().ToUpper().Contains("(REV")=true & cons = false)Ĭb.SetFontAndSize(BaseFont.CreateFont(BaseFont.HELVETICA_BOLD, BaseFont.CP1252, BaseFont.NOT_EMBEDDED), 11) int height = 600 įoreach (string al in combo) //my loop to write on the pdf but "combo" has 100 lines, which would fit into a single page. How can I write a loop to write contents on the first pdf page and the remaining to the second, third, etc.So far, I'm only seeing one page. My code below is working well for one page however, my content will not fit into a single page. ![]() I'm trying the create a multiple-page pdf using iTextSharp, but I'm having some issue creating a loop to have more than a single page. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |