Solved

Inserting page break in PDF using itextsharp

Posted on 2014-11-04
5
2,106 Views
Last Modified: 2014-12-03
Hi,
I need to insert page break in PDF using itextsharp. Let me know if this is possible
0
Comment
Question by:kalyangkm
  • 2
  • 2
5 Comments
 
LVL 32

Expert Comment

by:Robberbaron (robr)
ID: 40423657
i haven't used itextsharp for a while, but i believe you need to add a new page and then add data to it.

thats the way PDFSharp works.  this code adds a number of index pages and adds text to them.

                            if ((idxCount) > indexpagenum * indexlinesperpage)
                            {
                                indexpagenum++;  //increment current index pages in use  
                                //add new page for rest of index
                                pageIdx = outPDF.InsertPage(indexpagenum - 1);  // add after prev index. starts at 0

                                gfx = XGraphics.FromPdfPage(pageIdx);


                                font = new XFont("Verdana", 10);
                                gfx.DrawString(string.Format("Index page {0}", indexpagenum), font, XBrushes.Black, marginX + 20, 70, XStringFormats.Default);
                                font = new XFont("Verdana", 12);

                            }

Open in new window

0
 
LVL 19

Accepted Solution

by:
Albert Van Halen earned 500 total points
ID: 40423667
Use the NewPage method
0
 
LVL 32

Expert Comment

by:Robberbaron (robr)
ID: 40423670
http://www.codeproject.com/Articles/686994/Create-Read-Advance-PDF-Report-using-iTextSharp-in

for (int i = 1; i <= 5; i++)
{
    doc.NewPage();
    doc.Add(new Paragraph(string.Format("This is a page {0}", i)));
}

Open in new window

0
 

Author Comment

by:kalyangkm
ID: 40477933
I've requested that this question be deleted for the following reason:

Not required
0
 
LVL 19

Expert Comment

by:Albert Van Halen
ID: 40477934
Required or not, the answers are correct.
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Why, and when, to use Windows Workflow 1 20
Check if number is currency 15 29
Hidden Field Value 10 37
Problem to page 4 29
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now