Hi team,
I am trying to add a image stamp at every corners using below code. but the pdfDocument.Pages[Page_counter].PageInfo.IsLandscape is always returns false. I do attach both the affected and images used for stamp.
Aspose_tst_Source.zip (166.5 KB)
I do also tried solution in the below link, but the document has both landscape and portrait pages, it dose not gives the exact solution we expect.
var path = directoryName.Replace("file:\\", "");
string chartLoc = path + "\\left.jpg";
string chartLoc1 = path + "\\right.jpg";
string chartLoc2 = path + "\\top.jpg";
string chartLoc3 = path + "\\bottom.jpg";
ImageStamp imgStamp_left = new ImageStamp(chartLoc);
ImageStamp imgStamp_right = new ImageStamp(chartLoc1);
ImageStamp imgStamp_top = new ImageStamp(chartLoc2);
ImageStamp imgStamp_bottom = new ImageStamp(chartLoc3);
imgStamp_bottom.Background = false;
imgStamp_top.Background = false;
imgStamp_right.Background = false;
imgStamp_left.Background = false;
for (int Page_counter = 1; Page_counter <= pdfDocument.Pages.Count; Page_counter++)
{
// adding Image watermark to all pages of PDF file
if (pdfDocument.Pages[Page_counter].PageInfo.IsLandscape)
{
imgStamp_bottom.Height = 30;
imgStamp_bottom.XIndent = 0;
imgStamp_bottom.VerticalAlignment = VerticalAlignment.Bottom;
imgStamp_top.Height = 30;
imgStamp_top.XIndent = 0;
imgStamp_top.VerticalAlignment = VerticalAlignment.Top;
imgStamp_left.Width = 40;
imgStamp_left.XIndent = 0;
imgStamp_left.YIndent = 30;
imgStamp_left.VerticalAlignment = VerticalAlignment.Top;
imgStamp_right.Width = 40;
imgStamp_right.XIndent = 800;
imgStamp_right.YIndent = 30;
imgStamp_right.VerticalAlignment = VerticalAlignment.Top;
}
else
{
imgStamp_bottom.Height = 30;
imgStamp_bottom.XIndent = 0;
imgStamp_bottom.VerticalAlignment = VerticalAlignment.Bottom;
imgStamp_top.Height = 30;
imgStamp_top.XIndent = 0;
imgStamp_top.VerticalAlignment = VerticalAlignment.Top;
imgStamp_left.Width = 40;
imgStamp_left.XIndent = 0;
imgStamp_left.VerticalAlignment = VerticalAlignment.Top;
imgStamp_right.XIndent = 573;
imgStamp_right.Width = 40;
imgStamp_right.VerticalAlignment = VerticalAlignment.Top;
}
pdfDocument.Pages[Page_counter].AddStamp(imgStamp_bottom);
pdfDocument.Pages[Page_counter].AddStamp(imgStamp_top);
pdfDocument.Pages[Page_counter].AddStamp(imgStamp_right);
pdfDocument.Pages[Page_counter].AddStamp(imgStamp_left);
}
pdfDocument.Save(outputFile);
Kindly, help this issues as soon as possible.
Thanks,
Riyas