Copy link to clipboard
Copied
Hello, I am creating .Jsx script to create automatic text, but i wanted to change font of that Text but i dont know how to do it.
can anyone help with this?
One way to do is just set the font of the content of the textframe and the other way would be to apply a paragraph style to the content of the frame. The paragraph style can be reffered by name, use one of the following
myTextFrame.parentStory.appliedFont = "Arial" //Change with the name of the font you want
Apply paragraph style
myTextFrame.parentStory.appliedParagraphStyle = myDocument.paragraphStyles.itemByName("NameOfParagraphStyle") //Substitute with the name of the paragraph style you want
...
Copy link to clipboard
Copied
Hi,
Share what code you have written so far, the code would depend upon the what references you have in your code. For ex:- if you have to change the font of the text selection on the document, or of all the text in a selection of textframe, or find some pattern of text and change its font etc. Looking at your code we will be able to guide on what will best suit the workflow you are designing so that you learn as well
-Manan
Copy link to clipboard
Copied
Hello Manan,
Thanks for reply,
I write below code to create auto text, but the font of text is as per deafault setting but i have to change its font and size through scripting. could you help me in that what should i do for that
var myDocument = app.documents.add();
var myTextFrame = myDocument.pages.item(0).textFrames.add();
myTextFrame.geometricBounds = ["12p", "40p", "10p", "10p"];
myTextFrame.contents = "®/™ ©2020 . All rights reserved. Used under license in Canada.";
Copy link to clipboard
Copied
Hello Patilg5!
you can try....
myTextFrame = myTextFrame.parentStory.characters.everyItem();
myTextFrame.appliedFont = app.fonts.item("Arial");
myTextFrame.fontStyle = "Bold";
Regards,
Mike
Copy link to clipboard
Copied
One way to do is just set the font of the content of the textframe and the other way would be to apply a paragraph style to the content of the frame. The paragraph style can be reffered by name, use one of the following
myTextFrame.parentStory.appliedFont = "Arial" //Change with the name of the font you want
Apply paragraph style
myTextFrame.parentStory.appliedParagraphStyle = myDocument.paragraphStyles.itemByName("NameOfParagraphStyle") //Substitute with the name of the paragraph style you want to use
The other properties you can use on the story object can be seen from the following link
https://www.indesignjs.de/extendscriptAPI/indesign-latest/#Story.html#d1e530047
-Manan
Copy link to clipboard
Copied
Hello Manan,
Really appriciate your support,
Could you please tell me if I want to change font style and font size what will be script for same
Copy link to clipboard
Copied
How can I do the same but on my computer Adobe PDF App (and not online)?
My font suddenly changes on my Adobe PDF to cursive font, and I cannot revert it to the original print font.
Would appreciate your guidance
Copy link to clipboard
Copied
How can I do the same but on my computer Adobe PDF App (and not online)?
My font suddenly changes on my Adobe PDF to cursive font, and I cannot revert it to the original print font.
Would appreciate your guidance
By @Galit38712909x7cv
Are you exporting PDF from InDesign?
Copy link to clipboard
Copied
Are you exporting PDF from InDesign?
By @Robert at ID-Tasker
Probably not, as it's probably the same question OP posted here:
I guess she searched the forums further for something like "how to change font" and landed here.
If my assumption is correct and you're not exporting your PDF from InDesign, then this is an InDesign forum for InDesign-specific discussions. Just make sure to search - and post to - the Acrobat forum itself, not the entire Adobe community. The search function on the forums can, admittedly, be confusing.
Copy link to clipboard
Copied
That would be the pointSize and fontStyle property, example below
myTextFrame.parentStory.fontStyle = "Italic"
myTextFrame.parentStory.pointSize = 15
You can find all these properties in the link i shared. Also if you use the paragraphstyle method i mentioned you will not have to do all this in code, make all these changes in the style and it will work no need to change the code everytime
-Manan
Copy link to clipboard
Copied
Many thanks Manan for helping me.
Copy link to clipboard
Copied
Hi patilg5,
just to give you a variant of what Manan said.
There are ways to format text in the moment you are creating that text frame.
Just a sample below:
var page = app.documents[0].pages[0];
var newTextFrame =
page.textFrames.add
(
{
geometricBounds : ["12p", "40p", "10p", "10p"] ,
contents : "®/™ ©2020. All rights reserved. Used under license in Canada." ,
parentStory :
{
appliedFont : "Arial" ,
fontStyle : "Bold" ,
pointSize : 15
} ,
textFramePreferences :
{
autoSizingType : AutoSizingTypeEnum.HEIGHT_ONLY ,
autoSizingReferencePoint : AutoSizingReferenceEnum.TOP_CENTER_POINT ,
verticalJustification : VerticalJustification.TOP_ALIGN
}
}
);
Regards,
Uwe Laubender
( ACP )