使用DocuSign .NET Client库将PDF表单字段解析为DocuSign选项卡

时间:2015-05-06 16:59:05

标签: docusignapi

我们希望使用DocuSign签署合同。我们的工作流程是在文档服务器上创建文档,其中包含用于在此处签名的表单字段选项卡,全名选项卡和日期选项卡。然后将文档发送到DocuSign,我尝试使用transformPdfFormFields将表单字段转换为SignHere,Fullname和DateSigned选项卡。不幸的是,客户端库目前不支持这个,所以我试图更改源代码以提供此功能,遗憾的是文档和错误响应并不能使这太容易。

我遇到了this发布堆栈溢出的帖子,这对我有所帮助,但是我看不出与我发送的内容(哪些不起作用)和正在运行的请求有任何显着差异在SO帖子中。我最初发布在DocuSign forums但是被要求在SO上发帖。

这是我从API返回的其余跟踪,其中一些数据是匿名的。

$ pip install rpy2 Downloading/unpacking rpy2 Downloading rpy2-2.5.6.tar.gz (165kB): 165kB downloaded Running setup.py (path:/tmp/pip_build_my520/rpy2/setup.py) egg_info for package rpy2 Error: Tried to guess R's HOME but no R command in the PATH. Complete output from command python setup.py egg_info: Error: Tried to guess R's HOME but no R command in the PATH.

接头:

POST: https://demo.docusign.net/restapi/v2/accounts/12345/envelopes?api_password=true

请求流:

X-DocuSign-Authentication:<DocuSignCredentials><Username>foo@bar.de</Username><Password>AReallySecurePassword=</Password><IntegratorKey>ABCD-ef1gggg1-111a-1c11-b11e-f1e10111e111</IntegratorKey></DocuSignCredentials>
Content-Type:multipart/form-data; boundary=00000000-0000-0000-0000-000000000000
Host:demo.docusign.net
Content-Length:1052145
Expect:100-continue

响应:

--00000000-0000-0000-0000-000000000000
Content-Type: application/json
Content-Disposition: form-data

{
    "emailBlurb": "Test Blurb for EnvelopeCreateUsingCompositeTemplates",
    "emailSubject": "Test subject for EnvelopeCreateUsingCompositeTemplates",
    "status": "sent",
    "compositeTemplates": [
        {
            "compositeTemplateId": "1",
            "inlineTemplates": [
                {
                    "sequence": "1",
                    "recipients": {
                        "signers": [
                            {
                                "email": "foo@bar.com",
                                "name": "Signer 1: 981274442609345",
                                "recipientId": "1",
                                "tabs": {
                                    "signHereTabs": [
                                        {
                                            "pageNumber": 0,
                                            "documentId": 1,
                                            "xPosition": 0,
                                            "yPosition": 0,
                                            "height": 0,
                                            "width": 0,
                                            "tabLabel": "Signature_LesseeContractSignature",
                                            "anchorXOffset": 0,
                                            "anchorYOffset": 0,
                                            "required": false,
                                            "recipientId": "1"
                                        }
                                    ],
                                    "fullNameTabs": [
                                        {
                                            "pageNumber": 0,
                                            "documentId": 1,
                                            "xPosition": 0,
                                            "yPosition": 0,
                                            "height": 0,
                                            "width": 0,
                                            "tabLabel": "Signature_LesseeContractFullName",
                                            "anchorXOffset": 0,
                                            "anchorYOffset": 0,
                                            "required": false,
                                            "recipientId": "1"
                                        }
                                    ],
                                    "dateSignedTabs": [
                                        {
                                            "pageNumber": 0,
                                            "documentId": 1,
                                            "xPosition": 0,
                                            "yPosition": 0,
                                            "height": 0,
                                            "width": 0,
                                            "tabLabel": "Signature_LesseeContractDate",
                                            "anchorXOffset": 0,
                                            "anchorYOffset": 0,
                                            "required": false,
                                            "recipientId": "1"
                                        }
                                    ]
                                },
                                "emailNotification": {
                                    "emailBody": "Signer 1 Body: Testing the tabs 981274442659854",
                                    "emailSubject": "Signer 1 Body: 981274442659854",
                                    "supportedLanguage": "en"
                                }
                            }
                        ]
                    }
                }
            ]
        }
    ],
    "documents": [
        {
            "documentId": "1",
            "name": "Test Contract With Fields.pdf",
            "transformPdfFields": "true"
        }
    ]
}


--00000000-0000-0000-0000-000000000000
Content-Type: application/pdf
Content-Disposition: file; filename="Test Contract With Fields.pdf"; documentId=1; compositeTemplateId="1"

[file bits go here]

--00000000-0000-0000-0000-000000000000--

1 个答案:

答案 0 :(得分:0)

我已经完成了这项工作。有三件事要改变:

  • 将双引号添加到值
  • 将pageNumbers设置为从1开始
  • 将文档数组更改为文档对象

结果请求(包括PDF表单)位于:https://gist.github.com/ds-jk/a4990cb3e662c90430c0

  
    

编辑:以下原始帖子用于历史目的:     我将继续我们的主题,以便更多地关注它。希望我们也可以安排一个电话。我有一个没有transformPdfFields(下面)的样本。我试图修改你的内容尽可能简单,并且还没有开始工作。到目前为止,我还没有看到任何明显的问题。我将继续努力。

  
--f6e755d3-bbcf-44e5-b276-8ae626f97220
Content-Type: application/json
Content-Disposition: form-data

{
    "emailSubject": "Inline template with transformPdfFields",
    "emailBlurb": "This converts fields from a PDF and assigns them to a signer.",
    "status": "Sent",
    "recipients": {
        "signers": [
            {
                "name": "Korben Dallas",
                "email": "dscomposites@mailnator.com",
                "clientuserid": "12345",
                "recipientId": "1",
                "routingOrder": "1"
            }
        ]
    },
    "documents": [
        {
            "documentId": "1",
            "name": "test doc.pdf"
        }
    ]
}
--f6e755d3-bbcf-44e5-b276-8ae626f97220
Content-Type: application/pdf
Content-Disposition: file; filename="Test Doc.pdf"; documentid=1
Content-Transfer-Encoding: base64

<<Base64 PDF Bytes>>
--f6e755d3-bbcf-44e5-b276-8ae626f97220--