Solved

Inserting page break in PDF using itextsharp

Posted on 2014-11-04
5
2,544 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

733 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