Solved

Inserting page break in PDF using itextsharp

Posted on 2014-11-04
5
2,210 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Class Library Dynamics For Connectstring Information 2 23
Angular JS Route 3 54
C# Json POSt to Rest API 4 37
Capture logon name 13 46
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

895 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

13 Experts available now in Live!

Get 1:1 Help Now