Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Adding flattenable text to a PDF through Javascript

Guest
Aug 05, 2016 Aug 05, 2016

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

TOPICS
Acrobat SDK and JavaScript
2.7K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Aug 05, 2016 Aug 05, 2016

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...

Translate
Community Expert ,
Aug 05, 2016 Aug 05, 2016

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...

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Aug 05, 2016 Aug 05, 2016

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 05, 2016 Aug 05, 2016

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Aug 05, 2016 Aug 05, 2016
LATEST

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines