Hi ,
I am using Aspose.Pdf.dll version. 10.0 to do Date stamp in Pdf file which contain 5 pages.
I am getting Correct pages count in document object , but while checking the page collection there showing only 4 pages .
Please let me know is there any exception with the code or apose dll .
Please see the code which i am using
Document objPdfDocument = new Document(strPDFPath);
DateTime DateStamp=DateTime.Now;
string annotationText = string.Concat(DateStamp.ToString("yyyy/MM/dd"), " - ", DateStamp.ToString("HH:MM:ss"));
//create text stamp
TextStamp textStamp = new TextStamp(annotationText);
//set properties of the stamp
textStamp.TopMargin = 10;
textStamp.RightMargin = 20;
textStamp.HorizontalAlignment = Aspose.Pdf.HorizontalAlignment.Right;
textStamp.VerticalAlignment = VerticalAlignment.Top;
//create page number stamp
PageNumberStamp pageNumberStamp = new PageNumberStamp();
//whether the stamp is background
pageNumberStamp.Background = false;
pageNumberStamp.Format = filename + " - pages(#/" + objPdfDocument.Pages.Count + ")";
pageNumberStamp.TopMargin = 10;
pageNumberStamp.LeftMargin = 20;
pageNumberStamp.HorizontalAlignment = HorizontalAlignment.Left;
pageNumberStamp.VerticalAlignment = VerticalAlignment.Top;
pageNumberStamp.StartingNumber = 1;
//set text properties
pageNumberStamp.TextState.Font = FontRepository.FindFont("Arial");
pageNumberStamp.TextState.FontSize = 10;
pageNumberStamp.TextState.FontStyle = FontStyles.Regular;
pageNumberStamp.TextState.FontStyle = FontStyles.Italic;
pageNumberStamp.TextState.ForegroundColor = Color.Black;
foreach (Page page in objPdfDocument.Pages)
{
//adding stamp on stamp collection
page.AddStamp(textStamp);
Aspose.Pdf.InteractiveFeatures.DefaultAppearance default_appearance = new Aspose.Pdf.InteractiveFeatures.DefaultAppearance("Arial", 6, System.Drawing.Color.Black);
Aspose.Pdf.InteractiveFeatures.Annotations.FreeTextAnnotation textAnnotation = new Aspose.Pdf.InteractiveFeatures.Annotations.FreeTextAnnotation(page, new Aspose.Pdf.Rectangle(0, 0, 0, 0), default_appearance);
textAnnotation.Name = "Stamp";
textAnnotation.Accept(new AnnotationSelector(textAnnotation));
textAnnotation.Contents = textStamp.Value;
//textAnnotation.Open = true;
//textAnnotation.Icon = Aspose.Pdf.InteractiveFeatures.Annotations.TextIcon.Key;
Aspose.Pdf.InteractiveFeatures.Annotations.Border border = new Aspose.Pdf.InteractiveFeatures.Annotations.Border(textAnnotation);
border.Width = 0;
border.Dash = new Aspose.Pdf.InteractiveFeatures.Annotations.Dash(1, 1);
textAnnotation.Border = border;
textAnnotation.Rect = new Aspose.Pdf.Rectangle(0, 0, 0, 0);
page.Annotations.Add(textAnnotation);
//add stamp to particular page
page.AddStamp(pageNumberStamp);
}
// Save updated document
objPdfDocument.Save(strPDFPath);
Attached the Quick watch details of document Object