Dears,
we have the following code to save image & text over PDF document
the function save image and add text over PDF pages ok
but when we open PDF document on PDF Professional and try to add page or delete page
we get the following exception from PDF Professional Professional
"An incorrect structure was found in the PDF file"
public static bool SaveImageOnPDF(MemoryStream source, MemoryStream dest, MemoryStream image)
{
bool state1 = true;
try
{
int x = 2, y = 2;
PdfFileMend mender = new PdfFileMend(source, dest);
PdfFileInfo info = new PdfFileInfo(source);
for (int i = 1; i <= info.NumberOfPages; i++)
{
// don't generate barcode for small pages
if (info.GetPageWidth(i) < 422 || info.GetPageHeight(i) < 299)
continue;
bool state = mender.AddImage(image, i, x, y, (x + 530), (y + 50));
state = mender.AddText(new FormattedText(DateTime.Now.ToString("dd/MMM/yyyy hh:mm tt")), i, x, y);
if (!state) state1 = false;
}
mender.Close();
info.ClearInfo();
image.Close();
// save image over document
ECMFile.Replace(dest);
}
catch (Exception ex)
{
state1 = false;
throw new Exception("ECMFile:SaveImageOnPDF " + ex.Message, ex);
}
return state1;
}
Regards
Ahmad AbulMagd