Dear Aspose Support Team,
In our product using the below code we are able to create header and footer.
Aspose.Pdf.Document pdfDocumentissuance = new Aspose.Pdf.Document(InputFileName);
TextStamp stampEsignatureMeaningLeft = new TextStamp(strEsignatureMeaning.ToString().Trim());
TextStamp stampEsignatureMeaningCenter = new TextStamp(strEsignatureMeaning.ToString().Trim());
TextStamp stampEsignatureMeaningRight = new TextStamp(strEsignatureMeaning.ToString().Trim());
//fileStamp.Close();
stampEsignatureMeaningLeft.BottomMargin = 40;
stampEsignatureMeaningCenter.BottomMargin = 40;
stampEsignatureMeaningRight.BottomMargin = 40;
stampEsignatureMeaningLeft.RightMargin = 30;
stampEsignatureMeaningRight.RightMargin = 25;
stampEsignatureMeaningLeft.LeftMargin = 30;
stampEsignatureMeaningLeft.YIndent = 90;
stampEsignatureMeaningLeft.TopMargin = 10;
stampEsignatureMeaningCenter.TopMargin = 10;
stampEsignatureMeaningRight.TopMargin = 10;
stampEsignatureMeaningLeft.TextState.FontStyle = FontStyles.Bold;
stampEsignatureMeaningCenter.TextState.FontStyle = FontStyles.Bold;
stampEsignatureMeaningRight.TextState.FontStyle = FontStyles.Bold;
stampEsignatureMeaningLeft.HorizontalAlignment = Aspose.Pdf.HorizontalAlignment.Left;
stampEsignatureMeaningCenter.HorizontalAlignment = Aspose.Pdf.HorizontalAlignment.Center;
stampEsignatureMeaningRight.HorizontalAlignment = Aspose.Pdf.HorizontalAlignment.Right;
stampEsignatureMeaningLeft.VerticalAlignment = VerticalAlignment.Top;
stampEsignatureMeaningCenter.VerticalAlignment = VerticalAlignment.Top;
stampEsignatureMeaningRight.VerticalAlignment = VerticalAlignment.Top;
//stampEsignatureMeaning.TextState.FontSize = Convert.ToInt32(strFontSize);
foreach (Aspose.Pdf.Page page in pdfDocumentissuance.Pages)
{
page.AddStamp(stampEsignatureMeaningLeft);
page.AddStamp(stampEsignatureMeaningCenter);
page.AddStamp(stampEsignatureMeaningRight);
//page.Header =
}
//create TextAbsorber object to find all instances of the input search phrase
TextFragmentAbsorber textFragmentAbsorber = new TextFragmentAbsorber(oldText);
//accept the absorber for all the pages
pdfDocumentissuance.Pages[1].Accept(textFragmentAbsorber);
//get the extracted text fragments
TextFragmentCollection textFragmentCollection = textFragmentAbsorber.TextFragments;
//loop through the fragments
foreach (TextFragment textFragment in textFragmentCollection)
{
if (textFragment.TextState.HorizontalAlignment != Aspose.Pdf.HorizontalAlignment.Left)
{
textFragment.Text = "";
textFragment.Text = strEsignatureMeaning;
}
}
stampEsignatureMeaningLeft.VerticalAlignment = VerticalAlignment.Bottom;
stampEsignatureMeaningCenter.VerticalAlignment = VerticalAlignment.Bottom;
stampEsignatureMeaningRight.VerticalAlignment = VerticalAlignment.Bottom;
foreach (Aspose.Pdf.Page page in pdfDocumentissuance.Pages)
{
page.AddStamp(stampEsignatureMeaningLeft);
page.AddStamp(stampEsignatureMeaningCenter);
//page.AddStamp(stampEsignatureMeaningRight);
stampEsignatureMeaningRight.Value = "Page { "+page.Number+"} of { "+pdfDocumentissuance.Pages.Count+"}";
page.AddStamp(stampEsignatureMeaningRight);
}
pdfDocumentissuance.Save(OutputFileName);
pdfDocumentissuance.Dispose();
But we are not able to update the text in the header or footer if we wrongly inserted.
By using text replace feature , it replace all the occurrences in the page.
We want to update only the text in the Header and footer.
Can you please help me to sort out this issue ASAP ?
Thanks
Naveenkumar S S