0

I have a Pdf XFA document populating from my system. When I extract X and Y positions for the signature field in XML it's in millimeter. DocuSign uses pixels for X and Y coordinates. When I convert Millimeter to a pixel in DocuSign it won't position correctly. Do anyone knows how to convert it correctly for DocuSign? Thanks in Advance.

Adobe XFA XML for Signature field

C# Code

 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;
Frederic
  • 2,015
  • 4
  • 20
  • 37
Tuan
  • 19
  • 6
  • does your Pdf XFA document have field name? and if required can you change the field names so that transformation to DocuSign is easy? – Amit K Bist Mar 26 '18 at 20:50
  • Not sure if this is part of your issue but be aware that DocuSign has [offsets for SignHere tabs](https://stackoverflow.com/questions/24170573/absolute-coordinate-positioning-of-signhere-tabs/24998864#24998864) – Frederic Mar 27 '18 at 00:25
  • Yes XFA has field names but changing field names how does it control X and Y positions of the document. – Tuan Mar 28 '18 at 13:40
  • Frederic this will help dip72 but there is no answer to Y offset position issue. – Tuan Mar 28 '18 at 13:47
  • @Tuan Can you share your code so I can look at it ? – Frederic Mar 28 '18 at 20:46
  • Frederic I have included the code. In this code, I'm reading XML data and getting X and Y positions form XFA PDF document it's in mm. Need a way to convert it to DocuSign Pixel. – Tuan Mar 29 '18 at 15:31
  • X location in mm I multiply by 3.77 to convert to a pixel. Thanks – Tuan Mar 29 '18 at 15:44
  • @Tuan: If PDF has field names, then you can use [Adobe Fields to DS Tabs](https://www.docusign.com/p/RESTAPIGuide/RESTAPIGuide.htm#REST%20API%20References/Document%20Parameters.htm#Transfor) to convert PDF Fields to DS Tabs automatically if the field names as per DS Standards. This way you do not need to worry about correct X/Y positioning. – Amit K Bist Mar 29 '18 at 16:44
  • @Amit how do I do that when DS won't allow XFA PDF formats. What I do I flatten the PDF and send it to DocuSign with X and Y positioning. – Tuan Mar 29 '18 at 17:26
  • I am not familiar with XFA, so just think if it is possible for you to convert to PDF, and retain same field names and then send to DocuSign with PDF Fieldnames as per DS Standards – Amit K Bist Mar 29 '18 at 17:37
  • @Tuan Can you add your XFA document with the name of the elements that contain the X and Y signature locations ? – Frederic Mar 30 '18 at 16:56

0 Answers0