Solved

Inserting page break in PDF using itextsharp

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VB.NET 2008 - Windows Protected Your PC 7 41
exporting html table data 4 28
Name Space error VS2015 1 25
I need help adding validation to my MVC.Net view 6 10
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

827 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