SDi
SDi

Reputation: 11

DocuSign eSignature REST API v2.1 Java : Document in html format with non English language

I am using eSignature REST API v2.1 Java to create envelope. Document is in html format with non English language. On the signing page these non English is not displayed properly. How to handle this case? Thanks,

String htmlDoc = ".... .... <p>Signera arbetsorderavtal för anställningsnummer</p> ......";

Document document = new Document();

document.setDocumentId("1");

document.setName("name");

document.setDocumentBase64(Base64.getEncoder().encodeToString(htmlDoc));

document.setFileExtension("html");

envelopeDefinition.setDocuments(Arrays.asList(document));

Output: enter image description here

Expecting proper display of the foreign language.

Upvotes: 0

Views: 97

Answers (2)

SDi
SDi

Reputation: 11

My code is:

String htmlDoc = "<p>Signera arbetsorderavtal för anställningsnummer</p>"; // removed <html> & <body>
byte[] byteArray = htmlDoc.getBytes(**StandardCharsets.UTF_8**);

Document document = new Document();
document.setDocumentId("1");
document.setName("name");
document.setFileExtension("html");
document.setDocumentBase64(Base64.getEncoder().encodeToString(byteArray));

Output: Signing Page

Upvotes: 1

Inbar Gazit
Inbar Gazit

Reputation: 14050

You are not telling Java that the string is Unicode Transformation Format or UTF-8. Here is your code fixed:

String htmlDoc = ".... .... <p>Signera arbetsorderavtal för anställningsnummer</p> ......";

Document document = new Document();

document.setDocumentId("1");

document.setName("name");

document.setDocumentBase64(Base64.getEncoder().encodeToString(htmlDoc.getBytes(StandardCharsets.UTF_8)));

document.setFileExtension("html");

envelopeDefinition.setDocuments(Arrays.asList(document));

Upvotes: 0

Related Questions