Acrobat SDK IAC修改注释点属性

时间:2018-10-15 04:01:14

标签: javascript vb.net com acrobat-sdk

参考文献:
Acrobat SDK Working With Annotations

项目详细信息:
目标框架:4.5
语言:Visual Basic
Interop.Acrobat版本:1.1.0.0

主机PC规格:
操作系统名称:Microsoft Windows 10 Enterprise
版本:10.0.17134 Build 17134

我目前正在尝试修改我在vb.net中加载的注释的points属性。我可以修改点属性数组以外的所有其他属性。当我尝试修改points属性数组时,出现以下错误“服务器引发异常。(HRESULT异常:0x80010105(RPC_E_SERVERFAULT))”或“值不在预期范围内。”。

我的注释是“线”注释。文档确认此注释类型具有点数组(无论如何,我可以在调试过程中读取它,因此它肯定存在,我只是无法写回它)。

我尝试修改现有的Line注释和添加新的Line注释,在两种情况下都遇到上述错误。

我已经查看了Acrobat SDK中的示例项目,但找不到任何修改了点属性数组的实例。我感觉回写给点数组时我的数据类型不正确,因为Visual Studio调试器说我的点数组数据类型与从注释属性对象返回的数据类型不同。我的数据类型是“ Object()”,而点属性数据类型是“ Object {Object()}”

arr_oCustomPoints是我要分配给props.points的自定义定义点:

data types not the same

根据调试器,数组的子代具有相同的数据类型:

enter image description here
编辑-出现在rpc_e_serverfault错误的Windows事件日志中

enter image description here
我了解到,从javascript的角度来看,points属性实际上是一个对象集合,这使我相信我在vb.net中处理不正确。

所以我的问题很简单,如何写回points属性?我需要我的应用程序能够修改现有的注释点属性。

    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


编辑

我想出了如何使对象数组具有完全相同的数据类型,但是仍然出现rpc_e_serverfault错误。将继续调查oleaut32.dll中引发的错误

0 个答案:

没有答案