Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Add a note to an open pdf

New Here ,
Mar 16, 2016 Mar 16, 2016

I am trying to create my first program to interface with Adobe Acrobat Pro DC. I've got to

where I can create an instance of Adobe Acrobat and open a pdf. I now need to create a

text note, set the font style, color, and size. Then place this note in a particular location

on the pdf. I am using this as a stand alone program interfacing with Acrobat through COM.

I'm coding in VB.Net. Does anyone have any sample code for accomplishing this? I've gone

through the samples included with the SDK, but can't find anything on adding a simple note.

Any help would be greatly appreciated. Thanks.

TOPICS
Acrobat SDK and JavaScript
824
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 16, 2016 Mar 16, 2016

‌ACrobat can do so much that you won't generally find samples for anything you want to do. instead it's all about careful study of the documentation. The API you will want to study us the VB:JavaScript linkage which lets you run most JavaScript. That cracked, you can study the HavaScript API. JavaScript can add comments.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 17, 2016 Mar 17, 2016

Ok, I found an example for adding a comment that does a pop up window. But I don't need a pop up window, I need to add a simple line of text. And the code has all the variables declared as "Object". So I don't get intellisense in Visual Studio. Is there a more in depth API reference that lists all the methods for the Java Script Object?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 17, 2016 Mar 17, 2016

Visual Studio will not help you, there is no autocompletion for these methods. You need the Acrobat JavaScript API, which is part of the Acrobat SDK documentation, and runs to many hundreds of pages.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 17, 2016 Mar 17, 2016

Yeah, I found it finally. Been going through it and have gotten it to where I can add some "FreeText" and place it where I want. But I can't get the methods to work for changing the color and font style and size of the font. Could you point me to a specific page in the SDK reference?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 17, 2016 Mar 17, 2016

It's probably better if you post what you are trying to do this, and we can help you understand whether the problem is that you are using the wrong method, or have the wrong syntax. Be sure to check the console for error messages.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 17, 2016 Mar 17, 2016

Try

  AcroPpage = CType(AcroPdoc.AcquirePage(0), AcroPDPage)

Catch GetAcrobatPageError As Exception

  Debug.WriteLine(GetAcrobatPageError)

End Try

If AcroPpage Is Nothing Then

  MessageBox.Show("Error Trying To Get The Java Script Object")

  Exit Sub

End If

Try

  oJso = AcroPdoc.GetJSObject

Catch GetJsoError As Exception

  Debug.WriteLine(GetJsoError)

End Try

If oJso Is Nothing Then

  MessageBox.Show("Error Trying To Get The Java Script Object")

  Exit Sub

End If

Try

  oPageRect = AcroPpage.GetSize

Catch GetAcroRectError As Exception

  Debug.WriteLine(GetAcroRectError)

End Try

If oPageRect Is Nothing Then

  MessageBox.Show("Error Trying To Get The Acrobat Page Rectangle")

  Exit Sub

End If

Try

  oAnno = oJso.AddAnnot

Catch CreateAnnoError As Exception

  Debug.WriteLine(CreateAnnoError)

End Try

If oAnno Is Nothing Then

  MessageBox.Show("Error Trying To Create A New Annotation Object")

  Exit Sub

End If

Try

  oProps = oAnno.GetProps

Catch GetPropertiesError As Exception

  Debug.WriteLine(GetPropertiesError)

End Try

If oProps Is Nothing Then

  MessageBox.Show("Error Trying To Get Annotation Properties")

  Exit Sub

End If

Try

  iPopUpRect(0) = 5

  iPopUpRect(1) = oPageRect.y - 50

  iPopUpRect(2) = 400

  iPopUpRect(3) = oPageRect.y - 5

  oProps.Type = "FreeText"

  oAnno.SetProps(oProps)

  oProps = oAnno.GetProps

  oProps.page = 0

  oProps.print = True

  oProps.alignment = 0

  oProps.rect = iPopUpRect

  oProps.width = 0

  oProps.contents = "I added this comment from Visual Basic!"

  'The next three methods are the ones that don't work

  oProps.strokeColor = oJso.color.black

  oProps.textFont = "Arial-Black"

  oProps.textSize = 12

  oAnno.SetProps(oProps)

Catch AddTextError As Exception

  Debug.WriteLine(AddTextError)

End Try

All of this code runs through without error. It's just the three methods in red above that don't execute correctly. Any help would be greatly appreciated. Thanks.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 17, 2016 Mar 17, 2016
LATEST

Don't know about colour and size, but the text font looks wrong. The font name to use may not match the name you see in Windows. See the procedure described under JavaScript > JavaScript for Acrobat API Reference > JavaScript API > Field > Field properties > textFont

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