References:
Acrobat SDK Working With Annotations
Project Details:
Target framework: 4.5
Language: Visual Basic
Interop.Acrobat version: 1.1.0.0
Host PC Specs:
OS Name: Microsoft Windows 10 Enterprise
Version: 10.0.17134 Build 17134
I'm currently trying to modify the points property of an annotation that I have loaded in vb.net. I am able to modify all other properties except for the points property array. When I try modifying the points property array I get the following error "The server threw an exception. (Exception from HRESULT: 0x80010105 (RPC_E_SERVERFAULT))" or "Value does not fall within the expected range.".
The annotation I have is a "Line" annotation. Documentation confirms this annotation type has a points array (I can read it during debugging anyway so it's definitely there, I just can't write back to it).
I have tried both modifying an existing Line annotation and adding a new Line annotation, I encounter the aforementioned errors in both scenarios.
I have looked over the sample projects in the Acrobat SDK and I can't find any instances where the points property array is modified. I have a feeling that I have the incorrect datatype when writing back to the points array, since the visual studio debugger says my point array data type is different than that of which is returned from an annotation property object. My data type is "Object()" and the points property data type is "Object {Object()}"
arr_oCustomPoints is my custom defined points that I want to assign to props.points:
The children of the array have the same data type according to the debugger:
Edit - This appears in windows event log on rpc_e_serverfault error
I understand that from javascripts perspective that the points property is actually an object aggregate, making me believe that I am handling it incorrectly in vb.net.
So my question is simple, how can I write back to the points property? I need my application to be able to modify an existing annotations points property.
Dim oPDDocTarget As Acrobat.CAcroPDDoc
Dim oJSOTarget As Object = Nothing
Try
oPDDocTarget = CreateObject("AcroExch.PDDoc")
Dim sPathPDTarget As String = Me.txtTargetPDF.Text
If Not IO.File.Exists(sPathPDTarget) Then
MessageBox.Show("File [" & sPathPDTarget & "] does not exist.")
Exit Sub
End If
If Not oPDDocTarget.Open(sPathPDTarget) Then
MessageBox.Show("Failed to open PDF file [" & sPathPDTarget & "]")
Exit Sub
End If
oJSOTarget = oPDDocTarget.GetJSObject
oJSOTarget.syncAnnotScan()
Dim arr_oAnnotsCopyFrom As Object() = oJSOTarget.GetAnnots(CInt(nudTargetPage.Value))
Dim iAnnotsCopyCount = arr_oAnnotsCopyFrom.Length
For i As Integer = 0 To iAnnotsCopyCount - 1
If arr_oAnnotsCopyFrom(i).type = "Line" Then
Dim props = arr_oAnnotsCopyFrom(i).getProps()
Dim arr_oCustomXY1 As Object() = New Object(1) {CDbl(100.23), CDbl(143.23)}
Dim arr_oCustomXY2 As Object() = New Object(1) {CDbl(245.2), CDbl(423.43)}
Dim arr_oCustomPoints As Object() = New Object(1) {arr_oCustomXY1, arr_oCustomXY2}
props = arr_oAnnotsCopyFrom(i).getProps()
props.points = arr_oCustomPoints
End If
Next
If Not oPDDocTarget.Save(Acrobat.PDSaveFlags.PDSaveFull, sPathPDTarget) Then
MessageBox.Show("Failed to save PDF document [" & sPathPDTarget & "]")
Else
MessageBox.Show("Saved PDF document [" & sPathPDTarget & "]")
End If
If Not oPDDocTarget.Close() Then
MessageBox.Show("Failed to close PDF document [" & sPathPDTarget & "]")
End If
Catch ex As Exception
MessageBox.Show(ex.Message)
Finally
KillAcrobat()
End Try
End Sub
EDIT
I figured out how to make the object arrays the exact same data types, but I still get the rpc_e_serverfault error. Going to continue investigating the error raised in oleaut32.dll
User contributions licensed under CC BY-SA 3.0