Highlighted

How do I add Annotations in the existing PDF through C#?

New Here ,
Oct 15, 2018

Copy link to clipboard

Copied

Hi,

I m trying to add the rectangle annotation to the existing PDF but not able to achieve that.Please help to solve this. I m using Adobe Acrobat 9 pro. I tried with the below C# code,

string inputfilepath="C:\\RedLine.pdf"

//Object for Adobe application and Document

AcroApp gApp;

AcroAVDoc acroAVDoc;

//Initialize Acrobat Application

gApp = new AcroApp();

//Open PDf Document

acroAVDoc = new AcroAVDoc();

acroAVDoc.Open(inputfilepath, "output");

//To show the Application

gApp.Show();

CAcroPDDoc acroPDDoc = (CAcroPDDoc)acroAVDoc.GetPDDoc();

//Rectangle bounds

AcroRect acroRect = new AcroRect();

acroRect.Left = 906;

acroRect.right = 815;

acroRect.Top = 377;

acroRect.bottom = 142;

CAcroPDAnnot acroPDAnnot = acroPDPage.AddNewAnnot(2, "Rectangle", acroRect);

acroPDAnnot.SetContents("Testing the Acrobat Redline");

Thanks in advance,

SASIKUMAR

TOPICS
Acrobat SDK and JavaScript

Views

383

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

How do I add Annotations in the existing PDF through C#?

New Here ,
Oct 15, 2018

Copy link to clipboard

Copied

Hi,

I m trying to add the rectangle annotation to the existing PDF but not able to achieve that.Please help to solve this. I m using Adobe Acrobat 9 pro. I tried with the below C# code,

string inputfilepath="C:\\RedLine.pdf"

//Object for Adobe application and Document

AcroApp gApp;

AcroAVDoc acroAVDoc;

//Initialize Acrobat Application

gApp = new AcroApp();

//Open PDf Document

acroAVDoc = new AcroAVDoc();

acroAVDoc.Open(inputfilepath, "output");

//To show the Application

gApp.Show();

CAcroPDDoc acroPDDoc = (CAcroPDDoc)acroAVDoc.GetPDDoc();

//Rectangle bounds

AcroRect acroRect = new AcroRect();

acroRect.Left = 906;

acroRect.right = 815;

acroRect.Top = 377;

acroRect.bottom = 142;

CAcroPDAnnot acroPDAnnot = acroPDPage.AddNewAnnot(2, "Rectangle", acroRect);

acroPDAnnot.SetContents("Testing the Acrobat Redline");

Thanks in advance,

SASIKUMAR

TOPICS
Acrobat SDK and JavaScript

Views

384

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Oct 15, 2018 0
Most Valuable Participant ,
Oct 16, 2018

Copy link to clipboard

Copied

A very old version but the API has not changed and it should work. Please tell us exactly what happens, and what you expected to happen instead, don’t ask us to run your code To find out.

I suggest also also you do NOT use files in the root directory, this may have special restrictions.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 16, 2018 0
New Here ,
Oct 16, 2018

Copy link to clipboard

Copied

With the above code,I tried to draw the rectangle on the given bounds. Code is executing without errors and exceptions but there is no rectangle drawn on the PDF.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 16, 2018 0
New Here ,
Oct 19, 2020

Copy link to clipboard

Copied

Two years later, I am trying to do the same thing. In your code above one issue seems to be that acroPDPage is not defined before you attempt to add the annotation to it.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 19, 2020 0