Hi there @natucate - Thanks for writing to us! I’m escalating your report to Support. We would like to investigate the matter a little more deeply.
Thanks and stay tuned!
Hi there @natucate - We sent you a message about two days ago in hopes to obtain more information from you to help troubleshoot this. Could you reply to the message from Edcel if you’re still experiencing troubles with this? Thanks!
Hi @natucate!
I wanted to check in with you on this one, since I don’t see a response to the message that our Support team had sent you. Did you still need help here or did their reply to you help you resolve things? Please let us know :)
Hi there!
The line-break issue is very frequent as JSON doesn’t support it. You can clean the data before building your payload using a Code by Zapier step and use the following JS script:
let data = Object.assign({}, inputData);
for (let key in data) {
if (typeof(datatkey]) === "string" && datatkey].length > 0) {
datatkey] = datatkey].replace(/\r?\n/g, "<br>").replace(/\t/g, " ").replace(/"/g, '\"');
}
}
output = =data];
This will clean any input data you send to the script. It will replace line-breaks with HTML line breaks that PDFMonkey will understand and will also replace any tab or quote character to prevent breaking the JSON payload.
Cheers!
@PDFMonkey Thanks so much for chiming in here — very much appreciated :)
Hi everyone,
After using this code in prod I noticed a small issue with the quotes escaping, here is the correct version of the code: (the diff is the triple backslash near the end of the replace line)
let data = Object.assign({}, inputData);
for (let key in data) {
if (typeof(dataakey]) === "string" && dataakey].length > 0) {
dataakey] = dataakey].replace(/\r?\n/g, "<br>").replace(/\t/g, " ").replace(/"/g, '\\\"');
}
}
output = data];
Hi @PDFMonkey,
I’ve ran into the same issue while using Zapier and Ninja Forms. Whenever I use a textarea field and someone adds line breaks the responses don’t flow into PDFMonkey. I tried the Code you’ve given above but it doesn’t work in my case. Do you know how I could adjust it for Ninja Forms?
Actually, @PDFMonkey I’ve just figured out how to implement the code you’ve given correctly and it works great. Thanks!
Do you know how I would adjust so that the code can fix multiple textarea responses in one zapier task?
Hi @cfi_web, I’m sorry I didn’t see your message 10 months back. I hope since then you found out that the code can be set in a single task that can take multiple items as input.
A Code task takes an initial input mapping where you can set the name to use on the left side and the content to clean on the right. You can then pass the cleaned up content to PDFMonkey while only introducing a single extra task.
Also know that since then we have released a new version of the integration that simplifies things a lot by allowing to provide your data as a simple key/value mapping and not needing to write JSON. It eliminates this line-break issue completely when you use it
Thanks for the follow-up and insight here, @PDFMonkey!