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
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;
Copy link to clipboard
Copied
This requires using a script. What settings do you want to change, exactly, and to what values?
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
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});
}
}
}
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
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});
Copy link to clipboard
Copied
Thanks , made my day!!