Aspose.Pdf.Examples.CSharp.AsposePDFFacades.StampsWatermarks.AddPageNumber.Run C# (CSharp) Method

Run() public static method

public static Run ( ) : void
return void
        public static void Run()
        {
            // ExStart:AddPageNumber
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_StampsWatermarks();

            // Create PdfFileStamp object
            PdfFileStamp fileStamp = new PdfFileStamp();

            // Open Document
            fileStamp.BindPdf(dataDir + "AddPageNumber.pdf");
            
            // Get total number of pages
            int totalPages = new PdfFileInfo(dataDir + "AddPageNumber.pdf").NumberOfPages;

            // Create formatted text for page number
            FormattedText formattedText = new FormattedText("Page # Of " + totalPages, System.Drawing.Color.Blue, System.Drawing.Color.Gray, Aspose.Pdf.Facades.FontStyle.Courier, EncodingType.Winansi, false, 14);

            // Set starting number for first page; you might want to start from 2 or more
            fileStamp.StartingNumber = 1;

            // Add page number
            fileStamp.AddPageNumber(formattedText, 0);

            // Save updated PDF file
            fileStamp.Save(dataDir + "AddPageNumber_out.pdf");

            // Close fileStamp
            fileStamp.Close();
            // ExEnd:AddPageNumber
            
        }
        public static void CustomNumberStyle()