DocuSign X和Y职位

时间:2018-03-26 19:38:01

标签: docusignapi

我有一个从我的系统填充的Pdf XFA文档。当我在XML中提取签名字段的X和Y位置时,它以毫米为单位。 DocuSign使用X和Y坐标的像素。当我将毫米转换为DocuSign中的像素时,它无法正确定位。有谁知道如何正确转换为DocuSign?提前致谢。

Adob​​e XFA XML for Signature字段

C#代码

 EnvelopeDefinition envDef = new EnvelopeDefinition();
                    envDef.EmailSubject = "[DocuSign C# SDK] - Please sign this doc";

                    // Add a document to the envelope
                    DocuSign.eSign.Model.Document doc = new DocuSign.eSign.Model.Document();
                    doc.DocumentBase64 = System.Convert.ToBase64String(docuSignfileBytes);
                    doc.Name = FullFileName;
                    doc.DocumentId = "1";

                    envDef.Documents = new List<DocuSign.eSign.Model.Document>();
                    envDef.Documents.Add(doc);

                    // Add a recipient to sign the documeent
                    Signer signer = new Signer();
                    signer.Name = recipientName;
                    signer.Email = recipientEmail;
                    signer.RecipientId = "1";

                    signer.Tabs = new Tabs();
                    signer.Tabs.SignHereTabs = new List<SignHere>();
                     //Loading XML data to string builder
                    string[] delim = { Environment.NewLine, "\n" }; // "\n" added in case you manually appended a newline
                    string[] lines = sb.ToString().Split(delim, StringSplitOptions.None);
                    foreach (string line in lines)
                    {
                        if (line.Contains("SignatureField") == true)
                        {
                            if (line.Contains("x=") == true)
                            {
                                string[] readX = line.Trim().Split(' ');
                                for (int i = 0; i < readX.Length; i++)
                                {
                                    if (readX[i].Contains("x=") == true)
                                    {
                                        strXLocation = readX[i].Substring(3, readX[i].Length - 7);
                                        if(strXLocation.Length > 1)
                                        {                                           
                                            double iXLoc = 0;
                                            iXLoc = Convert.ToDouble(strXLocation) * Convert.ToDouble("3.77");
                                            strXLocation = iXLoc.ToString();
                                            strXLocation = strXLocation.Substring(0, strXLocation.IndexOf('.', 0));
                                        }

                                    }
                                }

                            }
                            if (line.Contains("y=") == true)
                            {
                                string[] readY = line.Trim().Split(' ');
                                for (int i = 0; i < readY.Length; i++)
                                {
                                    if (readY[i].Contains("y=") == true)
                                    {
                                        strYLocation = readY[i].Substring(3, readY[i].Length - 7);
                                        if(strYLocation.Length > 1)
                                        {                                            
                                            double dYLoc = 0;
                                            dYLoc = Convert.ToDouble(strYLocation) * Convert.ToDouble("3.77");
                                            strYLocation = dYLoc.ToString();
                                            strYLocation = strYLocation.Substring(0, strYLocation.IndexOf('.', 0));
                                        }

                                    }
                                }

                            }

                            if (strXLocation.Length > 1 && strYLocation.Length > 1)
                            {
                                // Create a |SignHere| tab somewhere on the document for the recipient to sign

                                SignHere signHere = new SignHere();
                                signHere.DocumentId = "1";
                                signHere.PageNumber = "2";
                                signHere.RecipientId = "1";
                                signHere.XPosition = strXLocation;
                                signHere.YPosition = strYLocation;
                                signer.Tabs.SignHereTabs.Add(signHere);

                                strXLocation = string.Empty;
                                strYLocation = string.Empty;
                            }
                        }
                    }

                    // =======================================

                    envDef.Recipients = new Recipients();
                    envDef.Recipients.Signers = new List<Signer>();
                    envDef.Recipients.Signers.Add(signer);

                    // set envelope status to "created" send to Draft envelop 
                    envDef.Status = "sent"; //Draft Envelop  //"sent";

                    // Use the EnvelopesApi to send the signature request!
                    EnvelopesApi envelopesApi = new EnvelopesApi();
                    EnvelopeSummary envelopeSummary = envelopesApi.CreateEnvelope(accountId, envDef);
                    EnvelopeID = envelopeSummary.EnvelopeId;

0 个答案:

没有答案