Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
PdfFileStamp class allows you to add PDF page stamp on all the pages of a PDF file. In order to add PDF page stamp, you first need to create objects of PdfFileStamp and Stamp classes. You also need to create the PDF page stamp using PdfFileStamp method of Stamp class. You can set other attributes like origin, rotation, background etc. using Stamp object as well. Then you can add the stamp in the PDF file using AddStamp method of PdfFileStamp class. Finally, save the output PDF file using Close method of PdfFileStamp class. The following code snippet shows you how to add PDF page stamp on all pages in a PDF file.
// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void AddPageStampOnAllPages()
{
// The path to the documents directory
var dataDir = RunExamples.GetDataDir_AsposePdf_Images();
// Create PdfFileStamp object
using (var fileStamp = new Aspose.Pdf.Facades.PdfFileStamp())
{
// Bind PDF document
fileStamp.BindPdf(dataDir + "SourcePDF.pdf");
// Create stamp
var stamp = new Aspose.Pdf.Facades.Stamp();
// Bind PDF document
stamp.BindPdf(dataDir + "AddPageStampOnAllPages.pdf", 1);
stamp.SetOrigin(20, 20);
stamp.Rotation = 90.0F;
stamp.IsBackground = true;
// Add stamp to PDF file
fileStamp.AddStamp(stamp);
// Save PDF document
fileStamp.Save(dataDir + "PageStampOnAllPages_out.pdf");
}
}
PdfFileStamp class allows you to add PDF page stamp on particular pages of a PDF file. In order to add PDF page stamp, you first need to create objects of PdfFileStamp and Stamp classes. You also need to create the PDF page stamp using BindPdf method of Stamp class. You can set other attributes like origin, rotation, background etc. using Stamp object as well. As you want to add PDF page stamp on particular pages of the PDF file, you also need to set the Pages property of the Stamp class. This property requires an integer array containing numbers of the pages on which you want to add the stamp. Then you can add the stamp in the PDF file using AddStamp method of PdfFileStamp class. Finally, save the output PDF file using Close method of PdfFileStamp class. The following code snippet shows you how to add PDF page stamp on particular pages in a PDF file.
// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void AddPageStampOnCertainPages()
{
// The path to the documents directory
var dataDir = RunExamples.GetDataDir_AsposePdf_Images();
// Create PdfFileStamp object
using (var fileStamp = new Aspose.Pdf.Facades.PdfFileStamp())
{
// Bind PDF document
fileStamp.BindPdf(dataDir + "SourcePDF.pdf");
// Create stamp
var stamp = new Aspose.Pdf.Facades.Stamp();
// Bind PDF document
stamp.BindPdf(dataDir + "PageStampOnCertainPages.pdf", 1);
stamp.SetOrigin(20, 20);
stamp.Rotation = 90.0F;
stamp.IsBackground = true;
stamp.Pages = new[] { 1, 3 }; // Apply stamp to specific pages (1 and 3)
// Add stamp to PDF file
fileStamp.AddStamp(stamp);
// Save PDF document
fileStamp.Save(dataDir + "PageStampOnCertainPages_out.pdf");
}
}
PdfFileStamp class allows you to add page numbers in a PDF file. In order to add page numbers, you first need to create object of PdfFileStamp class. If you want to show page number like “Page X of N” while X being the current page number and N the total number of pages in the PDF file then you first need to get the page count using NumberOfpages property of PdfFileInfo class. In order to get the current page number you can use # sign in your text anywhere you like. You can format the page number text using FormattedText class. If you want to start the page numbering from a specific number then you can set StartingNumber property. Once you’re ready to add page number in the file, you need to call AddPageNumber method of PdfFileStamp class. Finally, save the output PDF file using Close method of PdfFileStamp class. The following code snippet shows you how to add page number in a PDF file.
// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void AddPageNumberInPdfFile()
{
// The path to the documents directory
var dataDir = RunExamples.GetDataDir_AsposePdf_Images();
// Create PdfFileStamp object
using (var fileStamp = new Aspose.Pdf.Facades.PdfFileStamp())
{
// Bind PDF document
fileStamp.BindPdf(dataDir + "StampPDF.pdf");
// Get total number of pages
int totalPages = new Aspose.Pdf.Facades.PdfFileInfo(dataDir + "StampPDF.pdf").NumberOfPages;
// Create formatted text for page number
var formattedText = new Aspose.Pdf.Facades.FormattedText($"Page # of {totalPages}",
System.Drawing.Color.AntiqueWhite,
System.Drawing.Color.Gray,
Aspose.Pdf.Facades.FontStyle.TimesBoldItalic,
Aspose.Pdf.Facades.EncodingType.Winansi,
false, 12);
// Set starting number for first page; you might want to start from 2 or more
fileStamp.StartingNumber = 1;
// Add page number in upper right corner
fileStamp.AddPageNumber(formattedText, (int)PageNumPosition.PosUpperRight);
// Save PDF document
fileStamp.Save(dataDir + "AddPageNumber_out.pdf");
}
}
// Add PDF Page Numbers
public enum PageNumPosition
{
PosBottomMiddle, PosBottomRight, PosUpperRight, PosSidesRight, PosUpperMiddle, PosBottomLeft, PosSidesLeft, PosUpperLeft
}
The PdfFileStamp class offers the feature to add Page Number information as stamp object inside PDF document. Prior to this release, the class only supported 1,2,3,4 as page numbering style. However, there has been a requirement from some customers to use custom numbering style when placing page number stamp inside PDF document. In order to accomplish this requirement, NumberingStyle property has been introduced, which accepts the values from NumberingStyle enumeration. Specified below are values offered in this enumeration.
// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void AddCustomPageNumberInPdfFile()
{
// The path to the documents directory
var dataDir = RunExamples.GetDataDir_AsposePdf_Images();
// Create PdfFileStamp object
using (var fileStamp = new Aspose.Pdf.Facades.PdfFileStamp())
{
// Bind PDF document
fileStamp.BindPdf(dataDir + "StampPDF.pdf");
// Get total number of pages
int totalPages = new Aspose.Pdf.Facades.PdfFileInfo(dataDir + "StampPDF.pdf").NumberOfPages;
// Create formatted text for page number
var formattedText = new Aspose.Pdf.Facades.FormattedText($"Page # of {totalPages}",
System.Drawing.Color.AntiqueWhite,
System.Drawing.Color.Gray,
Aspose.Pdf.Facades.FontStyle.TimesBoldItalic,
Aspose.Pdf.Facades.EncodingType.Winansi,
false, 12);
// Specify numbering style as Numerals Roman UpperCase
fileStamp.NumberingStyle = Aspose.Pdf.NumberingStyle.NumeralsRomanUppercase;
// Set starting number for first page; you might want to start from 2 or more
fileStamp.StartingNumber = 1;
// Add page number in upper right corner
fileStamp.AddPageNumber(formattedText, (int)PageNumPosition.PosUpperRight);
// Save PDF document
fileStamp.Save(dataDir + "AddCustomPageNumber_out.pdf");
}
}
// Add PDF Page Numbers
public enum PageNumPosition
{
PosBottomMiddle, PosBottomRight, PosUpperRight, PosSidesRight, PosUpperMiddle, PosBottomLeft, PosSidesLeft, PosUpperLeft
}
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.