TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Kshitij Bali
NA
2
1.5k
How to add page number in C# generated PDF. Format "Page 1of n"
Sep 21 2020 4:32 AM
In my C# code which publishes certain data into PDF, I am looking for a way to put page number in the footer (left, center or right indexed) in the format "Page 1 of n", n being the total number of pages.
Below is my code.
using
(SaveFileDialog sfd =
new
SaveFileDialog() { Filter =
"PDF file|*.pdf"
, ValidateNames =
true
})
{
if
(sfd.ShowDialog() == DialogResult.OK)
{
iTextSharp.text.Document doc =
new
iTextSharp.text.Document(PageSize.A4.Rotate(), 50f, 50f, 50f, 50f);
{
try
{
//Main pdf publishing code follows
}
catch
(Exception ex)
{
MessageBox.Show(ex.Message,
"Error! try again."
, MessageBoxButtons.OK, MessageBoxIcon.Error);
}
finally
{
doc.Close();
}
}
}
}
Reply
Answers (
4
)
update column in database
How to fix CAST rule - Exceptions naming convention-suffix control.