Here's some more code so you can see how the codes currently set up.
private static FormattedText GetHeaderFooterFormattedText(string label)
{
float textSize = 10.0F;
return new FormattedText(label, System.Drawing.Color.Black, System.Drawing.Color.White, "Verdana", EncodingType.Winansi, true, textSize);
}
public static string AddReportHeadersFooters(string inFile, string outFile, bool includePage1, string ulLabel, string llLabel, string urLabel)
{
bool RunMixedMode = true;
PdfFileInfo fileInfo = new PdfFileInfo(inFile);
int count = fileInfo.NumberOfPages;
PdfFileStamp fileStamp = new PdfFileStamp(inFile, outFile);
FormattedText UpperLeftControlIDText = GetHeaderFooterFormattedText(ulLabel); //"Control ID # 09-0001"
float UpperLeftControlIDWidth = UpperLeftControlIDText.TextWidth;
FormattedText LowerLeftEntityNameText = GetHeaderFooterFormattedText(llLabel); //"Corte Madera Town Center2"
float LowerLeftEntityNameWidth = LowerLeftEntityNameText.TextWidth;
FormattedText UpperRightControlIDText = GetHeaderFooterFormattedText(urLabel); //"Asset Summary Report"
float UpperRightControlIDWidth = UpperRightControlIDText.TextWidth;
FormattedText LowerRightEntityNameText = GetHeaderFooterFormattedText(System.DateTime.Now.ToShortDateString());
float LowerRightEntityNameWidth = LowerRightEntityNameText.TextWidth;
string ReportLogPath = HttpContext.Current.Server.MapPath("/images/reportlogo.png"); //Defaulting the logo here.
for (int i = 1; i <= count; i++)
{
if (includePage1 && i == 1 || i > 1)
{
if (RunMixedMode) //Only add these stamps if you're in mixed mode.
{
//Headers
fileStamp.AddStamp(GetTextStamp(fileInfo, UpperLeftControlIDText, UpperLeftControlIDWidth, i, GetLeftStartingPoint(), 40));
fileStamp.AddStamp(GetTextStamp(fileInfo, LowerLeftEntityNameText, LowerLeftEntityNameWidth, i, GetLeftStartingPoint(), 60));
fileStamp.AddStamp(GetTextStamp(fileInfo, UpperRightControlIDText, UpperRightControlIDWidth, i, GetRightStartingPoint(fileInfo, i, UpperRightControlIDWidth), 40));
fileStamp.AddStamp(GetTextStamp(fileInfo, LowerRightEntityNameText, LowerRightEntityNameWidth, i, GetRightStartingPoint(fileInfo, i, LowerRightEntityNameWidth), 60));
Aspose.Pdf.Facades.Stamp logoStamp = new Aspose.Pdf.Facades.Stamp();
logoStamp.BindImage(ReportLogPath);
logoStamp.Pages = new int[] { i };
logoStamp.SetOrigin(GetLeftStartingPoint(), ASRFooterMargin);
fileStamp.AddStamp(logoStamp);
}
//Footers - //But always add page numbering.
FormattedText PageNumbering = GetHeaderFooterFormattedText(String.Format(@"Page {0} of {1}", i.ToString("N0"), count.ToString("N0")));
fileStamp.AddStamp(GetTextStamp(fileInfo, PageNumbering, PageNumbering.TextWidth, i, GetRightStartingPoint(fileInfo, i, PageNumbering.TextWidth), fileInfo.GetPageHeight(i) - ASRFooterMargin)); //fileInfo.GetPageHeight(i) + 20
}
}
fileStamp.Close();
return outFile;
}