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

Restrict user from changing Font, Size, weight even when Rich Text is Enabled.

Engaged ,
Apr 24, 2019 Apr 24, 2019

Copy link to clipboard

Copied

Hi,

I want to restrict users from changing font and its size even when the rich text is enabled..... or if they have changed it will be reverted back when the file is opened next time.

Is it possible.

Thanks

TOPICS
Acrobat SDK and JavaScript , Windows

Views

1.0K

Translate

Translate

Report

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 ,
Apr 29, 2019 Apr 29, 2019

Copy link to clipboard

Copied

It is. However, if you just want to use a fixed font and size, just set the field to have a fixed font and size... or did you want them to be able to use other types of rich formatting?

Votes

Translate

Translate

Report

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
Engaged ,
May 03, 2019 May 03, 2019

Copy link to clipboard

Copied

I want that user cannot change the font, font size, but they can do underline, strikethrough, bold etc...

is it possible??

Votes

Translate

Translate

Report

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 ,
May 03, 2019 May 03, 2019

Copy link to clipboard

Copied

You can't prevent them from changing it, but you can use a script to change it back to the desired settings under the Validation event of the field, I believe.

Votes

Translate

Translate

Report

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 ,
May 06, 2019 May 06, 2019

Copy link to clipboard

Copied

Yes - It's possible but not particularly straight forward and would best be run only after the user has committed the field. You'll need to have a good understanding of how JSON objects work and how to write recursive functions to dig through the formatting in its source format. If you are new to this, you might consider hiring someone to do it. Thought, not me at the moment.

Votes

Translate

Translate

Report

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 ,
May 06, 2019 May 06, 2019

Copy link to clipboard

Copied

Why does it need to be recursive? The spans object is a straight forward array, as far as I recall.

Votes

Translate

Translate

Report

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 ,
May 06, 2019 May 06, 2019

Copy link to clipboard

Copied

I believe the recursive bit Joel is referring too to parsing JSON, not specific to the spans object. 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

Translate

Translate

Report

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 ,
May 07, 2019 May 07, 2019

Copy link to clipboard

Copied

LATEST

Spans doesn't give you access to all of the properties that can be set in the Acrobat UI and depending on how the user does their formatting, the formats can get weird nesting. It's best to edit the JSON content directly without going through the spans Object. The Spans Object is a JSON Object but the definition of it in Acrobat has a limited number of properties to get and set. With the JSON content, you can get and set whatever properties are in the JSON.

Always remember... .toSource() can be a frustrated programmer's best friend.

Votes

Translate

Translate

Report

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
Advocate ,
May 07, 2019 May 07, 2019

Copy link to clipboard

Copied

In the line of try67​'s comment, you would save the current span Object array (at latest in the onFocus Event), and compare the edited one with it in the Validation Event. Then you can reset the font sizes etc.

A simplification is when the properties you want to control are all the same within the field; then you simply would reset those values in the span Object.

Votes

Translate

Translate

Report

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