Copy link to clipboard
Copied
Dear Adobe Experts,
I have been trying to add text to a PDF file through JavaScript for the past 4 hours. I have gotten the hang of multiple Adobe JavaScript guides. I have looked thorough fully but cannot solve this problem: adding a text box/text to a PDF page using JavaScript and then being able to flatten it successfully.
I have been using the addField with text as an option but when flattened the text box disappears. I will try to mess around with the button option and try to flatten it but I am weary of possible bugs
Here is my code:
var f = this.addField("info", "text", 0, [5,5, 250,25]);
f.delay = true;f.alignment = "center";
f.fillColor = color.white;
f.lineWidth = 1;
f.strokeColor = color.red;
f.borderStyle = style.s;
f.textSize = 24;
f.textColor = color.black;
f.textFont = font.Arial;
f.defaultValue = "Receive Stamp";
f.editable = false;
f.multiline = false;
f.doNotScroll = true;f.delay = false;
Any help would be appreciated,
Good day
There's a mistake in your code, which prevents the value from being set.
Are you running this code from the JS Console? If so, what happens when you run it?
Edit: There's more than one mistake, actually...
Copy link to clipboard
Copied
There's a mistake in your code, which prevents the value from being set.
Are you running this code from the JS Console? If so, what happens when you run it?
Edit: There's more than one mistake, actually...
Copy link to clipboard
Copied
I test it by executing an action that executes JS code. All of these lines of codes are validated by what I read on the Adobe JS documentation
When I execute it, everything works out but for the defaultValue and the fillColor. I have been trying to test what makes it go wrong by placing a specific line at different spots but to no avail
Copy link to clipboard
Copied
Make the change I described to the preferences and then run the code from the JS Console. You'll see the errors I'm referring to.
Copy link to clipboard
Copied
I am quite happy, I resolved everything in just a few minutes with that neat console. The problem is that I was using a possibly outdated guide or one that required extra things installed.. I am able to flatten it properly. Thank you
Find more inspiration, events, and resources on the new Adobe Community
Explore Now