text annotation format

Forum for the PDF-XChange Editor - Free and Licensed Versions

Moderators: TrackerSupp-Daniel, Tracker Support, Vasyl-Tracker Dev Team, Sean - Tracker, Paul - Tracker Supp, Chris - Tracker Supp, Tracker Supp-Stefan, Ivan - Tracker Software

Post Reply
lukepayton
User
Posts: 1
Joined: Thu Mar 05, 2020 3:58 am
Contact:

text annotation format

Post by lukepayton » Thu Mar 05, 2020 4:49 am

Hello,

I have a lot of PDF files with countless free text annotation. I try to use Javascript to batch modify the format of the annotation to make it bold and set the font to Times New Roman.
I tried these code in PDF-XChange-editor. I checked the API mentioned in PDF-XChange-editor (https://www.tracker-software.com/knowle ... nge-Editor) And I refer the more detail API information in this (https://www.adobe.com/content/dam/acom/ ... erence.pdf).
Although the detail API info is for acrobat, the info works in PDF-XChange-editor also.

I tried the following method:

Code: Select all

var annt = this.getAnnots(1)[0]
app.alert(annt.textFont)
annt.textFont = "TimesNewRomanPSMT"
var spans = new Array();

spans[0] = new Object();
spans[0].text = annt.contents;
spans[0].textColor = color.red;
spans[0].textSize = 24;
spans[0].alignment = "center";
spans[0].fontWeight = 800;  //set bold
spans[0].textFont = "TimesNewRomanPSMT"
annt.richContents = spans
This gave me the bold text, but the font changed to Arial and cannot set the font back to Times New Roman...
So, I tried another way...

Code: Select all

var annt = this.getAnnots(1)[0]
var span = annt.richContents
span[0].fontWeight = 800  //set bold
annt.richContents = span
However, this does nothing...
Can anyone suggest good methods to do this? It is difficult to change the format one by one... Thank a lot!

User avatar
Tracker Supp-Stefan
Site Admin
Posts: 14020
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: text annotation format

Post by Tracker Supp-Stefan » Thu Mar 05, 2020 12:48 pm

Hello lukepayton,

Please try with:

Code: Select all

 spans[0].textFont = font.Times;
And see if that helps!

Kind regards,
Stefan

Post Reply