Hi,
I try to create an OLE Connection between MS Access an Adobe Acrobat 8 to place a free text annotation to a PDF sheet that comes originally from a CAD application. I studied a lot of Acrobat references and SDK examples, but did not come to a solution at a certain point.
Have a look at my code example:
Set acroApp = CreateObject("Acroexch.App")
Set pdDoc = CreateObject("AcroExch.PDDoc")
Set Document = pdDoc.Open ("c:\Temp\Test.pdf")
set jso = Document.getJSObject
If Not jso Is Nothing Then
...
annot = jso.AddAnnot
props = annot.getProps
props.Type = "FreeText"
annot.setProps props
props = annot.getProps
props.page = 0
props.Rect = Rect
props.Contents = "I added this comment from Visual Basic!"
...
annot.setProps props
>> Free Text RTF Content <<
End If
pdDoc.Close
The Section between >> and << is the Problem. By Reading the JS-Reference I see that I have to transfer an array of RichText Objects to the annotation object like it is described in the "Java Script Reference Guide" (the array is named "spans" in the following example):
var annot = this.addAnnot({
page: 0,
type: "Text",
point: [72,500],
popupRect: [72, 500,6*72,500-2*72],
popupOpen: true,
noteIcon: "Help"
});
var spans = new Array();
spans[0] = new Object();
spans[0].text = "Attention:\r";
spans[0].textColor = color.blue;
spans[0].textSize = 18;
spans[1] = new Object();
spans[1].text = "Adobe Acrobat 6.0\r";
spans[1].textColor = color.red;
spans[1].textSize = 20;
spans[1].alignment = "center";
spans[2] = new Object();
spans[2].text = "will soon be here!";
spans[2].textColor = color.green;
spans[2].fontStyle = "italic";
spans[2].underline = true;
spans[2].alignment = "right";
// Now give the rich field a rich value
annot.richContents = spans;
My Problem is now that I don't have any idea how to construct and pass this Array of Objects in Visual Basic respectively in VBA. I even have found a note in the IAC Guide that the construction of objects within Acrobat's Java Script might be impossible from foreign programming.
Can anyone tell me more (maybe with example) how to pass a rich text content to an Free Text Annotation ? My favourite would be to do this all from VBA - if possible.
Thanks in advance
Steff
I was looking at this as well, as I wanted to put in OMR markings (lines that tell an OMR printer how to fold up pages and place them in envelopes) into Adobe documents for posting to clients
Please note, I was doing this in VB.Net not VB but is should be easy enough to transfer the code.
I couldn't get rich text just plain text and I did not use the JSObject but stuck with OLE.
I hope this helps you