my problem is to add annotations to a page.For that purpose i am using the below code in C#.
first i extract annotations from a page and try to add another document.
CAcroPDDoc pdDoc;
CAcroAVDoc avDoc;
CAcroPDDoc pdDocDest;
CAcroAVDoc avDocDest;
avDoc = new AcroAVDocClass();
avDocDest = new AcroAVDocClass();
mApp = new AcroAppClass();
//variables
//use single pdf file and select multiple pages of the same file.
string szName;
int iNum =Convert.ToInt16(PDSaveFlags.PDSaveBinaryOK);
string sDestFile = @"E:\Bimal\Executable\simple.pdf";
if (avDoc.Open("E:\\Bimal\\TestFiles\\Sample_Annotations.pdf", "") )
{
avDocDest.Open(sDestFile, "");
mApp.Unlock();
pdDocDest = (CAcroPDDoc)avDocDest.GetPDDoc();
pdDoc = (CAcroPDDoc)avDoc.GetPDDoc ();
iNum = pdDoc.GetNumPages();
szName = pdDoc.GetFileName();
CAcroRect x = new AcroRectClass();
x.Left = 200;
x.right = 600;
x.Top = 200;
x.bottom = 600;
AcroPDPage pg = null;
AcroPDAnnot ant, newAnnot=null;
AcroPDPage pgDest = null;
pg = (AcroPDPage)pdDoc.AcquirePage(0);
pgDest = (AcroPDPage)pdDocDest.AcquirePage(0);
string m="";
for (int i = 0; i < pg.GetNumAnnots(); i++)
{
MessageBox.Show(pgDest.GetNumAnnots().ToString());
ant = (AcroPDAnnot)pg.GetAnnot(i);
pgDest.AddAnnot(i, ant);
pdDocDest.Save(0, "E:\\Bimal\\TestFiles\\Sample_Annotations.pdf");
}
pdDocDest.Save(1, "E:\\Bimal\\TestFiles\\Sample_Ann.pdf");
pdDocDest.Close();
}