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
- {
-
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message, "Error! try again.", MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- finally
- {
- doc.Close();
- }
- }
- }
- }