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

Change Font type and size for all the comments in a pdf file with multiple pages

Community Beginner ,
Feb 09, 2018 Feb 09, 2018

Copy link to clipboard

Copied

Dear Experts

I have a pdf file with multiple pages, and each page has many comments made via Text boxes but not at uniform font style. Is there a way to change font type and size for all the comments in all the pages at once.

If there is no integrated command that can you help with some script.

Appreciate your guidance and help.

Regards

Mahesh

TOPICS
Create PDFs

Views

1.5K

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

correct answers 1 Correct answer

Community Expert , Feb 09, 2018 Feb 09, 2018

OK, you can use this code to set the font to "Times-Roman", the font size to 10 and the font color to black, for all the "Text Box" comments in the file:

this.syncAnnotScan();

var annots = this.getAnnots();

if (annots!=null) {

    for (var i in annots) {

        var annot = annots;

        if (annot.type=="FreeText") {

            annot.setProps({textFont: "Times-Roman"});

            var contents = annot.richContents;

            for (var j in contents) {

                contents.textSize = 10;

          

...

Votes

Translate

Translate
Community Expert ,
Feb 09, 2018 Feb 09, 2018

Copy link to clipboard

Copied

This requires using a script. What settings do you want to change, exactly, and to what values?

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 Beginner ,
Feb 09, 2018 Feb 09, 2018

Copy link to clipboard

Copied

thanks for your reply, I would like to change the following, Font style and size, font color is optional (may be  required in special cases).

-Mahesh

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 ,
Feb 09, 2018 Feb 09, 2018

Copy link to clipboard

Copied

OK, you can use this code to set the font to "Times-Roman", the font size to 10 and the font color to black, for all the "Text Box" comments in the file:

this.syncAnnotScan();

var annots = this.getAnnots();

if (annots!=null) {

    for (var i in annots) {

        var annot = annots;

        if (annot.type=="FreeText") {

            annot.setProps({textFont: "Times-Roman"});

            var contents = annot.richContents;

            for (var j in contents) {

                contents.textSize = 10;

                contents.textColor = color.black;

                contents.fontFamily = [];

            }

            annot.setProps({richContents: contents});

        }

    }

}

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 Beginner ,
Feb 09, 2018 Feb 09, 2018

Copy link to clipboard

Copied

thanks that was very quick and perfect..!

I was hoping that if we can have an option to provide page no. so that unnecessary it doesn't run through all the pages.. Kindly suggest.

Regards

Mahesh

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 ,
Feb 09, 2018 Feb 09, 2018

Copy link to clipboard

Copied

Sure, that's easily done.

Just change this line:

var annots = this.getAnnots();

To:

var annots = this.getAnnots({nPage: this.pageNum});

This will process the comments on the current page. You can also specify a specific page number, just keep in mind it's 0-based.

For example, this will process all the comments on page 10:

var annots = this.getAnnots({nPage: 9});

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 Beginner ,
Feb 09, 2018 Feb 09, 2018

Copy link to clipboard

Copied

LATEST

Thanks , made my day!!

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