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

Extendscript Doubt - Changing the Font Properties across the document.

Community Beginner ,
Oct 28, 2019 Oct 28, 2019

Copy link to clipboard

Copied

Dear Framers,

I am new to Extendscript and I am writing a script to change the Font properties of all the text in the document to calibri.To accomplish this my plan was to alter the properties of the Paragraph Format and the Character format.

1. Changing the Paragraph Format Properties

My flow of script is like the below:

a) Change the font properties of each paragraph tag and apply to 

  • All the paragraph formats in the body page of the document.
  • All the paragraph formats located in the table of the document.
  • All the paragraph formats located in the master page of the document.

I had succeeded in my attempt.

2. Changing the Character Format Properties

This where I am facing a problem. In the master page Footer, for certain text such as Part Number/IP, a character format is used. I am not sure how to change the font properties of these text to Calibri.

 

Could anyone help me with the logic. And also. could you please let me know if the approach used by me to solve the problem is correct?

TOPICS
Scripting

Views

539

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 , Oct 28, 2019 Oct 28, 2019

The simplest approach is this:

1) Update the font properties of all of the relevant paragraph and character formats in the document. You don't have to touch any of the document's content, just the formats.

2) Import paragraph and character formats, using the current document, removing any format overrides.

This assumes that your documents are "clean" and don't have any local formatting.

Another approach if your document has local formatting:

1) Update the font properties of all of the relevant paragr

...

Votes

Translate

Translate
Community Expert ,
Oct 28, 2019 Oct 28, 2019

Copy link to clipboard

Copied

The simplest approach is this:

1) Update the font properties of all of the relevant paragraph and character formats in the document. You don't have to touch any of the document's content, just the formats.

2) Import paragraph and character formats, using the current document, removing any format overrides.

This assumes that your documents are "clean" and don't have any local formatting.

Another approach if your document has local formatting:

1) Update the font properties of all of the relevant paragraph and character formats in the document.

2) Loop through all of the paragraphs in the document and update the font properties of the paragraphs that have the relevant paragraph formats applied.

3) For each paragraph, loop through the character property changes, test the font and update it if necessary.

Note that this approach requires far more code than the first approach.

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

Copy link to clipboard

Copied

Dear FrameExpert,

 

Thank you so much for the suggestion. Your first approach really helped.

Now, I am trying to change the font properties of Paragraph/Char formats across all the documents in the book.

I iterate over the book.The firstComponentInBook is the document.When i debugged I found that except for Name, none of the properties pertaining to ParagraphFmt/Character formats are available when the doc is accessed as the FirstComponentInBook. Could you please let me know how to resolve this issue?

 

var bk=app.ActiveBook;
var dc;
if(bk.ObjectValid() == true)
{
dc=bk.FirstComponentInBook;
{
while (dc.ObjectValid())
{
alert(dc.Name); // Here the Doc name is displayed.
//doc=app.ActiveDoc;
// alert(doc.Name);
ptagFormat= dc.FirstPgfFmtInDoc; // The ptagFormat is showing undefined
alert(ptagFormat);

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

Copy link to clipboard

Copied

You have to open a book component in FrameMaker to get the Doc object to process. The book component is a pointer to the document on disk, but you have to open the document to get access to most of its properties.

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

Copy link to clipboard

Copied

Fine. Instead of using the components in the book, I am using the following approach:

In the active book, i open all the files.

I iterate over all the open files using the following approach

bk=app.ActiveBook.

if(bk.ObjectValid == true)

{

dc= app.FirstOpenDoc;

while(dc.ObjectValid()==true)

{

//do the para and char formating stuff

dc=dc.NextOpenDocInSession;

}

 

Is this approach correct?

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

Copy link to clipboard

Copied

You have to remember to save and close the documents when you are done.

I wouldn't do it this way; I just process one component at a time. Try searching this forum for "processing all files in a book."

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

Copy link to clipboard

Copied

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 ,
Oct 30, 2019 Oct 30, 2019

Copy link to clipboard

Copied

LATEST

Dear Frameexpert,

 

Thank you so much for your guidance.I saw the logic.I am sorry for bugging you with many questions.I have encountered an issue:

When I declare a variable doc as app.ActiveDoc, I am able to perform paragraph and Character formatting change to it.

However, when I am declaring the variable doc= app.FirstOpenDoc; and iterating over all the open docs in session, I see that the paragraph and character formating properties are not getting changed. Why is it so? What to do to make sure that my script runs on all the open docs? Or in other words what is the Syntax for selecting each open doc and processing. I went through the libraries. But couldn't find one. Please guide me.

 

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