Unicode charsets issue with AWS Lambda
I am using AWS Lambda for generating pdf where html-pdf is the npm package. everything works flawless but the problem is with Hindi character. the characters appear gibberish and understandable something like as shown in attached image.
Packages used
- html-pdf
- ejs
Things i tried:
i used same nodejs based code on my local machine and it was working as expected. but not working on Lambda (nodejs v6.10/8.10)
node.js amazon-web-services aws-lambda aws-sdk html-pdf
|
show 3 more comments
I am using AWS Lambda for generating pdf where html-pdf is the npm package. everything works flawless but the problem is with Hindi character. the characters appear gibberish and understandable something like as shown in attached image.
Packages used
- html-pdf
- ejs
Things i tried:
i used same nodejs based code on my local machine and it was working as expected. but not working on Lambda (nodejs v6.10/8.10)
node.js amazon-web-services aws-lambda aws-sdk html-pdf
1
How are you outputting the PDF? Upload to S3? return directly from lambda? How is the lambda invoked? Directly? Via apigateway? other Event?
– cementblocks
Nov 14 '18 at 18:02
Is the string you are using for the file name returned from a lambda function? Try parsing it as JSON e.g.name = JSON.parse(filename)before using it.
– bwest
Nov 14 '18 at 18:10
@cementblocks i am creating a stream using ejs and directly uploading the stream to S3
– Deepak Mallah
Nov 15 '18 at 9:53
@DeepakMallah square blocks typically appear when you use a font that doesn't include the character you want.
– Panagiotis Kanavos
Nov 20 '18 at 8:40
1
@DeepakMallah you are. Otherwise you wouldn't see any text. If you see text, you are using a font even if it's a default one
– Panagiotis Kanavos
Nov 20 '18 at 8:42
|
show 3 more comments
I am using AWS Lambda for generating pdf where html-pdf is the npm package. everything works flawless but the problem is with Hindi character. the characters appear gibberish and understandable something like as shown in attached image.
Packages used
- html-pdf
- ejs
Things i tried:
i used same nodejs based code on my local machine and it was working as expected. but not working on Lambda (nodejs v6.10/8.10)
node.js amazon-web-services aws-lambda aws-sdk html-pdf
I am using AWS Lambda for generating pdf where html-pdf is the npm package. everything works flawless but the problem is with Hindi character. the characters appear gibberish and understandable something like as shown in attached image.
Packages used
- html-pdf
- ejs
Things i tried:
i used same nodejs based code on my local machine and it was working as expected. but not working on Lambda (nodejs v6.10/8.10)
node.js amazon-web-services aws-lambda aws-sdk html-pdf
node.js amazon-web-services aws-lambda aws-sdk html-pdf
asked Nov 14 '18 at 17:26
Deepak MallahDeepak Mallah
1,64311324
1,64311324
1
How are you outputting the PDF? Upload to S3? return directly from lambda? How is the lambda invoked? Directly? Via apigateway? other Event?
– cementblocks
Nov 14 '18 at 18:02
Is the string you are using for the file name returned from a lambda function? Try parsing it as JSON e.g.name = JSON.parse(filename)before using it.
– bwest
Nov 14 '18 at 18:10
@cementblocks i am creating a stream using ejs and directly uploading the stream to S3
– Deepak Mallah
Nov 15 '18 at 9:53
@DeepakMallah square blocks typically appear when you use a font that doesn't include the character you want.
– Panagiotis Kanavos
Nov 20 '18 at 8:40
1
@DeepakMallah you are. Otherwise you wouldn't see any text. If you see text, you are using a font even if it's a default one
– Panagiotis Kanavos
Nov 20 '18 at 8:42
|
show 3 more comments
1
How are you outputting the PDF? Upload to S3? return directly from lambda? How is the lambda invoked? Directly? Via apigateway? other Event?
– cementblocks
Nov 14 '18 at 18:02
Is the string you are using for the file name returned from a lambda function? Try parsing it as JSON e.g.name = JSON.parse(filename)before using it.
– bwest
Nov 14 '18 at 18:10
@cementblocks i am creating a stream using ejs and directly uploading the stream to S3
– Deepak Mallah
Nov 15 '18 at 9:53
@DeepakMallah square blocks typically appear when you use a font that doesn't include the character you want.
– Panagiotis Kanavos
Nov 20 '18 at 8:40
1
@DeepakMallah you are. Otherwise you wouldn't see any text. If you see text, you are using a font even if it's a default one
– Panagiotis Kanavos
Nov 20 '18 at 8:42
1
1
How are you outputting the PDF? Upload to S3? return directly from lambda? How is the lambda invoked? Directly? Via apigateway? other Event?
– cementblocks
Nov 14 '18 at 18:02
How are you outputting the PDF? Upload to S3? return directly from lambda? How is the lambda invoked? Directly? Via apigateway? other Event?
– cementblocks
Nov 14 '18 at 18:02
Is the string you are using for the file name returned from a lambda function? Try parsing it as JSON e.g.
name = JSON.parse(filename) before using it.– bwest
Nov 14 '18 at 18:10
Is the string you are using for the file name returned from a lambda function? Try parsing it as JSON e.g.
name = JSON.parse(filename) before using it.– bwest
Nov 14 '18 at 18:10
@cementblocks i am creating a stream using ejs and directly uploading the stream to S3
– Deepak Mallah
Nov 15 '18 at 9:53
@cementblocks i am creating a stream using ejs and directly uploading the stream to S3
– Deepak Mallah
Nov 15 '18 at 9:53
@DeepakMallah square blocks typically appear when you use a font that doesn't include the character you want.
– Panagiotis Kanavos
Nov 20 '18 at 8:40
@DeepakMallah square blocks typically appear when you use a font that doesn't include the character you want.
– Panagiotis Kanavos
Nov 20 '18 at 8:40
1
1
@DeepakMallah you are. Otherwise you wouldn't see any text. If you see text, you are using a font even if it's a default one
– Panagiotis Kanavos
Nov 20 '18 at 8:42
@DeepakMallah you are. Otherwise you wouldn't see any text. If you see text, you are using a font even if it's a default one
– Panagiotis Kanavos
Nov 20 '18 at 8:42
|
show 3 more comments
1 Answer
1
active
oldest
votes
By default, Lambda does not output in binary. It base64 encodes all of your output.
If your PDF is served back via the API Gateway, you can reverse this with a change in the API Gateway in order to get binary with the following steps below the first image:

- Go to the corresponding API Gateway for your Lambda function (mine was Generate Calendar)
- Select Settings
- In the Binary Media Types enter
*/*
- Click the blue Save Changes button.
Then re-deploy the API. See following image and steps:

- Click Resources.
- Under the Action button, select Deploy API
- Under deployment stage, select Prod
- Then click blue Deploy button,
Here is a AWS forum post with a similar PDF problem to yours. Hope this helps.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53305710%2funicode-charsets-issue-with-aws-lambda%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
By default, Lambda does not output in binary. It base64 encodes all of your output.
If your PDF is served back via the API Gateway, you can reverse this with a change in the API Gateway in order to get binary with the following steps below the first image:

- Go to the corresponding API Gateway for your Lambda function (mine was Generate Calendar)
- Select Settings
- In the Binary Media Types enter
*/*
- Click the blue Save Changes button.
Then re-deploy the API. See following image and steps:

- Click Resources.
- Under the Action button, select Deploy API
- Under deployment stage, select Prod
- Then click blue Deploy button,
Here is a AWS forum post with a similar PDF problem to yours. Hope this helps.
add a comment |
By default, Lambda does not output in binary. It base64 encodes all of your output.
If your PDF is served back via the API Gateway, you can reverse this with a change in the API Gateway in order to get binary with the following steps below the first image:

- Go to the corresponding API Gateway for your Lambda function (mine was Generate Calendar)
- Select Settings
- In the Binary Media Types enter
*/*
- Click the blue Save Changes button.
Then re-deploy the API. See following image and steps:

- Click Resources.
- Under the Action button, select Deploy API
- Under deployment stage, select Prod
- Then click blue Deploy button,
Here is a AWS forum post with a similar PDF problem to yours. Hope this helps.
add a comment |
By default, Lambda does not output in binary. It base64 encodes all of your output.
If your PDF is served back via the API Gateway, you can reverse this with a change in the API Gateway in order to get binary with the following steps below the first image:

- Go to the corresponding API Gateway for your Lambda function (mine was Generate Calendar)
- Select Settings
- In the Binary Media Types enter
*/*
- Click the blue Save Changes button.
Then re-deploy the API. See following image and steps:

- Click Resources.
- Under the Action button, select Deploy API
- Under deployment stage, select Prod
- Then click blue Deploy button,
Here is a AWS forum post with a similar PDF problem to yours. Hope this helps.
By default, Lambda does not output in binary. It base64 encodes all of your output.
If your PDF is served back via the API Gateway, you can reverse this with a change in the API Gateway in order to get binary with the following steps below the first image:

- Go to the corresponding API Gateway for your Lambda function (mine was Generate Calendar)
- Select Settings
- In the Binary Media Types enter
*/*
- Click the blue Save Changes button.
Then re-deploy the API. See following image and steps:

- Click Resources.
- Under the Action button, select Deploy API
- Under deployment stage, select Prod
- Then click blue Deploy button,
Here is a AWS forum post with a similar PDF problem to yours. Hope this helps.
edited Nov 21 '18 at 9:09
answered Nov 20 '18 at 16:07
TaterheadTaterhead
3,10621423
3,10621423
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53305710%2funicode-charsets-issue-with-aws-lambda%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
How are you outputting the PDF? Upload to S3? return directly from lambda? How is the lambda invoked? Directly? Via apigateway? other Event?
– cementblocks
Nov 14 '18 at 18:02
Is the string you are using for the file name returned from a lambda function? Try parsing it as JSON e.g.
name = JSON.parse(filename)before using it.– bwest
Nov 14 '18 at 18:10
@cementblocks i am creating a stream using ejs and directly uploading the stream to S3
– Deepak Mallah
Nov 15 '18 at 9:53
@DeepakMallah square blocks typically appear when you use a font that doesn't include the character you want.
– Panagiotis Kanavos
Nov 20 '18 at 8:40
1
@DeepakMallah you are. Otherwise you wouldn't see any text. If you see text, you are using a font even if it's a default one
– Panagiotis Kanavos
Nov 20 '18 at 8:42