TransformPDFFields选项在使用SOAP API的CreateEnvelopeFromTemplatesAndForms中不起作用

时间:2015-01-29 14:58:57

标签: vb.net docusignapi

我正在尝试使用CreateEnvelopeFromTemplatesAndForms创建信封以使pdf表单字段可编辑。我正在接受unspecified_error。我还尝试从复合模板中删除文档,并在内联模板信封中添加文档。在这种情况下,它会创建并发送信封,但不会使字段可编辑。请参阅下面的代码

       'compositeTemplate
        Dim envInfo As New EnvelopeInformation
        With envInfo
            .AccountId = c.AccountID
            .Subject = subject
            .EmailBlurb = emailBlurb
        End With

        Dim template As New CompositeTemplate

        'recipients
        Dim recipients As New List(Of Recipient)

        For iRecip As Integer = 1 To packet.Recipients.Count
            Dim recipient As New Recipient
            Dim customfields As New List(Of String) 

            With packet.Recipients(iRecip - 1)
                recipient.Email = .Email
                recipient.SignerName = .Name
                recipient.UserName = .Name
                recipient.ID = .ID
                recipient.RoutingOrder = .RoutingOrder
                recipient.RoutingOrderSpecified = True
                recipient.RequireIDLookup = .RequireIDLookup
                recipient.RequireIDLookupSpecified = True
                recipient.AccessCode = .AccessCode 
                recipient.AddAccessCodeToEmail = False
                recipient.AddAccessCodeToEmailSpecified = True
                recipient.DefaultRecipient = .DefaultRecipient
                recipient.DefaultRecipientSpecified = .IsDefaultRecipientSpecified


                If (Not String.IsNullOrEmpty(.CaptiveInfoClientUserId)) Then
                    recipient.CaptiveInfo = New RecipientCaptiveInfo()
                    recipient.CaptiveInfo.ClientUserId = .CaptiveInfoClientUserId
                End If

                customfields.Add(String.Format("SignerRole={0}", .Role)) 
            End With

            'add customfields list to recipient customfields
            recipient.CustomFields = customfields.ToArray
            recipients.Add(recipient)
        Next


        Dim inlineTemplate As New InlineTemplate
        inlineTemplate.Sequence = 1
        inlineTemplate.Envelope = New Envelope


        inlineTemplate.Envelope.AccountId = c.AccountID


        With inlineTemplate.Envelope
            .Notification = New APIService.Notification
            Dim exp As New APIService.Expirations
            With exp
                .ExpireEnabled = _envelopeExpirationEnabled
                If _envelopeExpirationEnabled Then
                    .ExpireAfter = _envelopeExpirationDays
                    If _envelopeExpirationWarningEnabled Then
                        .ExpireWarn = _envelopeExpirationWarningDaysLeft
                    End If
                End If
            End With
            .Notification.Expirations = exp
        End With

        Dim tabs As New List(Of Tab)

        'add documents
        Dim documents As New List(Of Document)
        Dim matchBoxes As New List(Of MatchBox)
        For iDoc As Integer = 1 To packet.Forms.Count
            Dim theForm As Objects.Form = packet.Forms(iDoc - 1)
            theForm.ID = iDoc

            Dim document As New Document
            document.Name = theForm.FilePath
            document.PDFBytes = theForm.FileBytes
            document.ID = theForm.ID
            document.TransformPdfFields = True

            'add tabs - this will be based on metadata defined in the database for the attached forms
            For Each oTab As Objects.Tab In theForm.Tabs
                Dim tab As New Tab
                If Not String.IsNullOrEmpty(oTab.AnchorText) AndAlso oTab.TabType <> TabTypeCode.Custom Then
                    Dim aTab As New AnchorTab
                    aTab.AnchorTabString = oTab.AnchorText
                    tab.AnchorTabItem = aTab
                ElseIf oTab.TabType = TabTypeCode.Custom Then
                    tab.TabLabel = oTab.AnchorText
                End If
                With tab
                    .DocumentID = document.ID
                    .RecipientID = oTab.Recipient.ID
                    .Type = oTab.TabType

                    .PageNumber = oTab.PageNumber
                    .XPosition = oTab.XPosition
                    .YPosition = oTab.YPosition


                    If .Type = TabTypeCode.InitialHere Then
                        .ScaleValueSpecified = True
                        .ScaleValue = 0.53
                    End If

                End With
                tabs.Add(tab)
            Next

            documents.Add(document)

        Next

        inlineTemplate.Envelope.Recipients = recipients.ToArray
        inlineTemplate.Envelope.Tabs = tabs.ToArray

        template.InlineTemplates = New InlineTemplate() {inlineTemplate}
        template.Document = New Document
        template.Document.ID = 1
        template.Document.Name = "TemplateDoc"
        template.Document.PDFBytes = documents(0).PDFBytes
        template.Document.TransformPdfFields = True
        template.Document.FileExtension = "pdf"


        Dim _apiProxy As APIServiceSoap = CreateApiProxy(c)

        Dim envStatus As EnvelopeStatus = _apiProxy.CreateEnvelopeFromTemplatesAndForms(envInfo, New CompositeTemplate() {template}, True)

非常感谢任何协助。

谢谢, Pulak

1 个答案:

答案 0 :(得分:0)

调试此类问题(有时是DocuSign服务器端的错误)的最佳方法是检查您通过网络发送的原始(基于XML)SOAP请求。如果我是你,我会在你的问题中包含它,因为当我们可以看到请求而不是创建请求的代码时,它更容易诊断。

话虽如此,将标签的Locked属性设置为false,以便它可以编辑?您还需要将CustomTabLockedSpecified属性设置为true才能生效。

基本上,在标签定义代码中尝试以下内容:

With tab
    .DocumentID = document.ID
    .RecipientID = oTab.Recipient.ID
    .Type = oTab.TabType

    ...

    .CustomTabLockedSpecified = True
    .CustomTabLocked = False