我正在创建一个通用微服务,它接受 PDF 并通过电子邮件发送给多个签名者进行签名。
我正在尝试在签名者需要签名的 PDF 字段上放置黄色框(选项卡)。似乎有3种方法可以做到这一点:
x, y
坐标(不适合该项目,因为要求调用程序测量 PDF 以提供该坐标并不容易)anchorString
, 不理想,因为不建议在 PDF 上进行编辑CompositeTemplate
似乎是唯一的出路。不知道做错了什么,那个黄色标签不会显示。byte[] buffer = readFile( docPdf); String docBase64 = Base64.getEncoder().encodeToString(buffer); // Create the DocuSign document object Document document = new Document(); document.setDocumentBase64(docBase64); document.setName(docPdf); // can be different from actual file name document.setFileExtension("pdf"); document.setTransformPdfFields("true"); // many different document types are accepted document.setDocumentId("1"); // a label used to reference the doc ArrayList<CompositeTemplate> compList = new ArrayList<CompositeTemplate>(); CompositeTemplate compoTemplate = new CompositeTemplate(); //Add to Composite template compoTemplate.setDocument(document); //Create Envelope recipients, including them in the first template ArrayList<Signer> signers= new ArrayList<Signer>(); Signer signer1 = new Signer (); signer1.setEmail("***@***"); signer1.setName("Jane Doe"); signer1.setRecipientId("1"); signer1.setRoleName("Test"); signer1.setRoutingOrder("1"); SignHere signHere1 = new SignHere(); signHere1.setTabLabel("aaa"); signHere1.setRecipientId("1"); signHere1.setDocumentId("1"); signHere1.setPageNumber("6"); Tabs recipientTabs = new Tabs(); recipientTabs.setSignHereTabs(Arrays.asList(signHere1)); signer1.setTabs(recipientTabs); signers.add(signer1); Recipients recipientList = new Recipients(); recipientList.signers(signers); //Create the list for InlineTemplates ArrayList<InlineTemplate> inlineTemplateList = new ArrayList<InlineTemplate>(); InlineTemplate inlineTemplate = new InlineTemplate(); inlineTemplate.setSequence ( "1"); inlineTemplate.setRecipients(recipientList); inlineTemplateList.add(inlineTemplate); //Create the composite template, inline template lists. compoTemplate.setCompositeTemplateId("1"); //compoTemplate.ServerTemplates = templateList; compoTemplate.setInlineTemplates(inlineTemplateList); //Take the Composite Template list, add both compList.add(compoTemplate); //Create the definition for the envelope EnvelopeDefinition envelopeDefinition = new EnvelopeDefinition(); //Add the Composite Template list // envelopeDefinition.setCompositeTemplates(templateList); envelopeDefinition.setEmailSubject("composite ***** "); envelopeDefinition.setCompositeTemplates(Arrays.asList(compoTemplate)); // envelopeDefinition.setRecipients(recipientList); envelopeDefinition.setStatus("sent"); // requests that the envelope be created and sent.