Skip to content

Commit

Permalink
Merge pull request #132 from docusign/bugfix/labels-in-html-doc-eg40
Browse files Browse the repository at this point in the history
Fix html doc labels in eg40
  • Loading branch information
paigesrossi authored Mar 27, 2024
2 parents 5020c7f + a1b395d commit 6a3ba8a
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,14 @@
import com.docusign.esign.model.*;

import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.Collections;

import org.apache.commons.io.FilenameUtils;
import org.springframework.core.io.ClassPathResource;
import org.springframework.util.StreamUtils;

public final class SetDocumentVisibilityService {
//ds-snippet-start:eSign40Step3
public static EnvelopeDefinition makeEnvelope(
Expand Down Expand Up @@ -37,6 +42,10 @@ public static EnvelopeDefinition makeEnvelope(
envelopeDefinition.setRecipients(recipients);

envelopeDefinition.setDocuments(Arrays.asList(prepareDocumentsForSending(
signerEmail,
signerName,
ccEmail,
ccName,
documentFileNamePDF,
documentFileNameDOCX,
documentFileNameHTML)));
Expand Down Expand Up @@ -73,12 +82,26 @@ private static Signer[] prepareSigners(
}

private static Document[] prepareDocumentsForSending(
String signerEmail,
String signerName,
String ccEmail,
String ccName,
String documentFileNamePDF,
String documentFileNameDOCX,
String documentFileNameHTML) throws IOException {
Document documentHTML = EnvelopeHelpers.createDocumentFromFile(
documentFileNameHTML,
ClassPathResource resource = new ClassPathResource(documentFileNameHTML);
String documentHTMLContentsString = StreamUtils.copyToString(resource.getInputStream(), StandardCharsets.UTF_8);
documentHTMLContentsString = documentHTMLContentsString.replace("{USER_EMAIL}", signerEmail);
documentHTMLContentsString = documentHTMLContentsString.replace("{USER_FULLNAME}", signerName);
documentHTMLContentsString = documentHTMLContentsString.replace("{CC_EMAIL}", ccEmail);
documentHTMLContentsString = documentHTMLContentsString.replace("{CC_NAME}", ccName);
byte[] documentHTMLContentsBytes = documentHTMLContentsString.getBytes(StandardCharsets.UTF_8);
String extension = FilenameUtils.getExtension(documentFileNameHTML);

Document documentHTML = EnvelopeHelpers.createDocument(
documentHTMLContentsBytes,
"Order acknowledgement",
extension,
"1");

Document documentDOCX = EnvelopeHelpers.createDocumentFromFile(
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/doc_1.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
color: darkblue;">Order Processing Division</h2>
<h4>Ordered by {USER_FULLNAME}</h4>
<p style="margin-top:0em; margin-bottom:0em;">Email: {USER_EMAIL}</p>
<p style="margin-top:0em; margin-bottom:0em;">Copy to: {CC_NAME}, {CC_EMAIL}</p>
<p style="margin-top:3em;">
Candy bonbon pastry jujubes lollipop wafer biscuit biscuit. Topping brownie sesame snaps sweet roll pie. Croissant danish biscuit soufflé caramels jujubes jelly. Dragée danish caramels lemon drops dragée. Gummi bears cupcake biscuit tiramisu sugar plum pastry. Dragée gummies applicake pudding liquorice. Donut jujubes oat cake jelly-o. Dessert bear claw chocolate cake gummies lollipop sugar plum ice cream gummies cheesecake.
</p>
Expand Down

0 comments on commit 6a3ba8a

Please sign in to comment.