Have you read the IAC Reference? The properties and methods available
are all documented there. I don't think there is anything on text
boxes, however. Consider the VBJavaScript interface.
Aandi Inston
This is a discussion on ver 6.0 object model - Adobe Acrobat ; Hello, Thank you for a wonderful forum. After milling through, unfortunately I did not find anything in the CAcroPDPage class to expose the methods, properties, and events (as available) for the textbox object. I can manually add a textbox to ...
Hello,
Thank you for a wonderful forum. After milling through, unfortunately I did not find anything in the CAcroPDPage class to expose the methods, properties, and events (as available) for the textbox object. I can manually add a textbox to a .pdf file but cannot locate the class detail to do it programmatically. Possibly this is done within the CAcroPDAnnot class but have had the same results.
I'm trying to programmatically add text to a document before printing it. I'm working within vb6, xp/pro and acrobat 6.0.
Possibly I must retrieve the javascript class object then manipulate but at this point it is speculation.
Can anyone point me in the right direction?
Many thanks in advance,
Eric Abbott
Have you read the IAC Reference? The properties and methods available
are all documented there. I don't think there is anything on text
boxes, however. Consider the VBJavaScript interface.
Aandi Inston
Aandi,
Excerpt from the IAC Ref:
AcroExch.PDPage
●AddAnnot — Adds a specified annotation at a specified location in the page’s annotation array.
●AddNewAnnot — Creates a new text annotation and adds it to the page.
(I)did not locate a definitive definition (or code example) of either of these objects or parameters like the VB object browser lists:
Function AddNewAnnot(nIndexAddAfter As Long, szSubType As String, rect As Object) As Object
Member of Acrobat.CAcroPDPage
Creates a new text annotation and adds it to the page.
For example: what are the different subtypes?
I will continue searching for additional documentation.
Thank you for your assistance,
Eric Abbott
All:
The API Reference does a better job of explaining the details behind the function. Researching it now for thread applicability.
Regards,
Eric
Like a lot of PDF programming, to work effectively you need knowledge
of the PDF format. Annotations are described in section 8.4 of the PDF
Reference. Table 8.16 is particularly relevant.
Aandi Inston
Thanks Aandi,
Thorough reference for the annotation objects but I don't believe this is the information concerning the text box tool. Still looking in the PDF reference document for that. The annotation type "freetext" isn't the correct object either I think. There's a lot of information here and sometimes the "list of contents" page is somewhat confusing to follow.
I'll continue looking.
Best regards,
Eric Abbott
The text box tool creates an annotation with subtype FreeText.
Aandi Inston
Hi Aandi,
Thank you for the above instance information. I was wondering if the JSObject model is the same for version Acrobat 6.0 as it is for version 7.0?
So far the following code gives me a graphic question mark instead of the freetext annotation (I think there needs to be some sort of repaint or re-set event to fire after creating the annotation):
Public Sub main()
'add a text annotation to the current page in Acrobat:
'It will be added as the first annotation in the page's annotation array.
Dim AcroApp As CAcroApp
Dim AVDoc As CAcroAVDoc
Dim AVPage As CAcroAVPageView
Dim PDPage As CAcroPDPage
Dim PDDoc As CAcroPDDoc
Dim Rect As CAcroRect
Dim LinkAnnot As CAcroPDAnnot
Dim strAnnotValue As String
Dim JSObject As Object
Dim annot As Object
Dim props As Object
Set AcroApp = CreateObject("AcroExch.App")
Set Rect = CreateObject("AcroExch.Rect")
Set JSObject = CreateObject("acroexch.pddoc")
Set AVDoc = AcroApp.GetActiveDoc
Set PDDoc = AVDoc.GetPDDoc
Set AVPage = AVDoc.GetAVPageView
Set PDPage = PDDoc.AcquirePage(AVPage.GetPageNum)
'set the location values
Rect.Top = 745
Rect.Left = 203
Rect.Right = 382
Rect.bottom = 712
'retrieve the javascript object
Set JSObject = PDDoc.GetJSObject
'create a new text annnotation and assign text string value
Set LinkAnnot = PDPage.AddNewAnnot(-1, "freetext", Rect)
LinkAnnot.SetContents ("test")
End Sub
>Thank you for the above instance information. I was wondering if the JSObject model is the same for version Acrobat 6.0 as it is for version 7.0?
The JSObject processing is the same, but JavaScript itself has quite a
few changes. The JavaScript Reference, however, is reasonably good at
noting the changes, and the versions where they occurred.
> Set LinkAnnot = PDPage.AddNewAnnot(-1, "freetext", Rect)
See the IAC Reference, this is not what the documentation says.
Aandi Inston
Aandi,
You're right. The Reference says that the subtype is "FreeText".
Thanks for the pointer. Have upgraded to 7.0. Still working the problem.
eric