Adding text to indesign pages with specific font ,size,and color using javascript

Hello,
Using javascript i am able to add some text to each page of an indesign file.
myNewText = "SOME TEXT"
myTextFrame = myPage.textFrames.item(0);
tempframe = myTextFrame.contents;
myTextFrame.contents =  myNewText + tempframe ;
But i want to specify the font used,size and color for that text.
When i try the code mentioned in indesign javascript scripting guide
myNewText .appliedFont = app.fonts.item("Times New Roman");
myNewText .fontStyle = "Bold";
nothing gets changed and font family already used stays the same.
How can i do that only for the added text and not for the whole content?I dont want to add the text to a new text frame I want to append it to the existing text frame.
And is there a way to specify font size too?
thank you

There's a mixup going on here. Let's see if we can sort out some of it
at least.
If you just want to add new text to an already existing text frame,
that's easy:
myTextFrame.contents += "Hello";
But if you want the new text to have unique formatting, it's a little
more complicated.
There are two simple ways to do it, I think:
1. Create a temporary text frame, as you have done, and add the text,
and format everything in there. Then move() that formatted text to the
end of myTextFrame and delete the temporary frame:
tempFrame = app.activeDocument.textFrames.add();
tempFrame.contents = "New Text";
tempFrame.paragraphs[0].appliedFont = app.fonts.itemByName("Times New
Roman"); // etc...
tempFrame.paragraphs[0].move(myTextFrame.insertionPoints[-1],
LocationOptions.AFTER);
tempFrame.remove();
2. The other option, is to add the text directly to your textFrame. But
if you want to format only that text, you have to store where the text
started:
myTextFrame = app.selection[0];
firstInsertionPoint = myTextFrame.insertionPoints[-1].index;
myTextFrame.contents += "New Text";
myAddedText =
myTextFrame.characters.itemByRange(myTextFrame.insertionPoints[firstInsertionPoint],
myTextFrame.insertionPoints[-1]);
myAddedText.appliedFont = app.fonts.itemByName("Trajan Pro"); // etc.
What you've done in your sample script, however, is to try to apply a
font to a simple JavaScript string. It won't work, but the way you did
it, it won't throw an error either, because in fact you've created a new
property of your string. (myString = "Hello"; myString.appliedFont =
"Times"; // myString now has a Javascript property called appliedFont --
but that's nothing to do with InDesign!)
HTH,
Ariel

Similar Messages

  • Is there a way to change the font size and color of text in the calendar app?

    Does anyone know a way of changing the font size and color of text in the calendar app that comes with the iPad 2?  It is very hard to see the small gray numbers on the calendar.  Thanks

    Looks like you didn't get a reply on your post, but it is still a problem.  Font size is supposedly changeable via "Accessibility" in Settings, but it doesn't work.  You can turn on "Zoom".

  • How do I change the font size and color in a text box?

    How do I change the font size and color in a text box?

    Really frustrating to find the first time but simple once you figure it out. I think I spent hours trying to find this. Simply right click on a blank spot in the toolbar up top and select Properties Bar. There it is! The available properties will change depending on whether you have the content (text) selected or the box itself.
    I haven't found a way yet to make it show up as a regular part of the toolbar. It floats around and gets in the way so I don't leave it on and then have to open it again when I need it. Again - frustrating; but at least it's there!

  • Set-up custom font, font size, and color for writing new and reply e-mails in Thunderbird

    I know that I can select the font, size, and color for writing each new and reply e-mails in Thunderbird, but I don't want to have to do this each time. I want to set-up the default font, size, and color for all new and reply e-mails. It already comes up with a default one, but I want to change it, but can't figure out how to do this. I'm sure it is quite simple, but I don't know how to do this. Thank you in advance for help.

    Tools > Options > Display > Formatting tab
    Default font: select font
    Select size : eg; 14
    Click on 'Advanced' button and set all the sizes to 14
    Select : 'allow messages to use other fonts'
    click on OK
    Click on 'Composition'
    Under the 'General' tab
    Suggest you set HTML font to 'Variable width' and Size : 'Medium'
    Select the 'Text colour' you would like to compose email using
    Select the 'Background colour' you would like to use when composing emails.
    click on OK to save all changes.
    This will set the display email list to the selected font.
    It will allow received emails to use the font the sender used.
    When you compose an email it will also use the same font settings.
    The message 'Display' settings in the above section also apply to messages that you compose. The settings are not sent, so they do not affect how your messages appear to recipients.
    The settings in the ''Composition' section can affect how messages are sent. If you make unusual choices, then people who receive messages from you might find them difficult or impossible to read. Hence, why I suggest you leave it as 'Variable width' and allow the 'Display' settings to set the default used for composing emails.
    More info:
    * http://kb.mozillazine.org/Font_settings_in_Thunderbird

  • How do i change font sizes and colors in ical in OS Lion.  Everything is greyed and too small.   And how do I changed the color of the scroll bars, which are now invisible?

    how do i change font sizes and colors in ical in OS Lion. Since upgrading,  all fonts are grey, instead of black,  and too small.   And how do I changed the color of the scroll bars, which also are grey and almost invisible?  And if you can asnwer this, can you tell me how to get back the email format I had before the upgrade?  I no longer have column headings and I'd like them.  Thank you. 

    Do you know about changing the font colors for ical, and the color of the scroll bars?
    No, I don't. I don't use that program; I fiddled with it just now, and could not find a way to do that.
    Perhaps someone else will have an idea.

  • Font size and color

    can I change the font size and color of the items in a list?Font size can be changed and it is working in emulator but not in phones.I am using Nokia 6630 for testing purpose. I can't find any options to change color.

    graphics can change color ( in later versions off wtk)

  • How do I change the font size and color in my e-mail?

    I'm using the regular MAIL application on my Macbook (OSX 10.5.5) and I'm wondering how to change the font size and color of my incoming and outgoing mail.
    Any suggestions?
    thanks!

    I'm using the regular MAIL application on my Macbook (OSX 10.5.5) and I'm wondering how to change the font size and color of my incoming and outgoing mail.
    For outgoing email you the Fonts and Colors buttons found in the New Message pane (note that settings you make in Mail > Preferences do not affect outgoing messages).

  • How to change the font, the font size, and color text

    How to change the font, the font size, and the color for a selected text in C++.
    David

    Look at the documentation in the SDK about how to build a plugin and then the PDEdit APIs available to them.

  • Font size and color will not change in emails, blogs, forums etc.

    I can no longer change the style or color of fonts in emails, blogs, forums etc. I can change the font size and nothing else. Everything works when I am connected using explorer so it is a setting or update in firefox that is causing the problem. If I cut/copy and paste into a word document from a web site I still cannot make a change. If I copy from a word document into a web site the colors and fonts revert to some default setting. I have tried changing the setting in Options for the fonts and colors, they make changes but they don't solve the problem.

    Hi,
    Please check if this happens in a [https://support.mozilla.org/en-US/kb/Managing-profiles new profile]. If it's okay, you can later [https://support.mozilla.org/en-US/kb/Recovering%20important%20data%20from%20an%20old%20profile?s=profile&r=1&e=sph&as=s copy the personal data] from the old profile. Firefox stores your personal data and settings in another location separate from its [http://kb.mozillazine.org/Installation_directory files/folder]. A new profile would have the default Firefox settings ('''Tools''' ('''Alt''' + '''T''') > [https://support.mozilla.org/en-US/kb/Options%20window '''Options'''] and [http://kb.mozillazine.org/About:config '''about:config'''] ) and usually would also be empty of any '''Extensions''' and themes ('''Appearance''') in '''Tools''' > '''Add-ons''') and their settings. Also, a new profile would have no previous stored website data/settings etc. ('''Tools''' > '''Clear Recent History''').
    [https://support.mozilla.org/en-US/kb/Profiles?s=profile&r=2&e=sph&as=s Profiles Howto]
    [http://kb.mozillazine.org/Profile_folder_-_Firefox Profile Folder & Files]
    [http://kb.mozillazine.org/About:config_entries about:config Entries]

  • The tool bar is missing for font,size and color for lettering in elements 9

    Iam missing tool bar for font, style and size and color. where is it?

    Are you sure you have the regular horizontal or vertical type tool and not one of the type masks selected? If you choose the type mask tools you see a dotted outline around the T icon instead of a solid T.

  • Is there any way to turn off the auto formatting in Pages?  I just want to type a letter and add pictures and titles, and Pages keeps changing font sizes and doesn't let me "Do it my way".  I HATE this!

    Is there any way to turn off the auto formatting in Pages?  I'm using a blank document, so I figured I could write my letter and add pictures any way I wanted to.  But NO!  Pages keeps changing the font size!  I typed a large heading as a title, and when I try to change to a smaller font for the body of the letter, it changes the size back to the larger size!  I am getting SO FRUSTRATED!  I've spent over an hour trying to get the stupid program to let me just type my letter!  Can anyone help?

    The only one left is the "unsubmitted text" dialogue, which would not be a problem if I were not a Facebook user; after updating the "Richard is..." field (which does not require a manual submit to actually send) I get the above message. This is obviously Safari just not realising that the info has been sent and is therefore (I imagine) one for Apple themselves to answer!!
    You're welcome Rich. Glad to help.
    Not being a Facebook User, I'm not sure how to respond to the error situation. However, this would be something to report to Apple as a bug via the Safari Menu. First, open to the page in question, then select "Report Bugs to Apple".
    Mahalo for the and Aloha from Big Island.

  • How do I change the font size and color in a text box in Adobe Acrobat 9 Pro (ctrl e does not work)?

    I need to mark up scanned pdf documents with text box comments. I can insert the text box and type text but I cannot change the font or color. When I press Crtl E, no tool bar appears in the menu bar. What does appear in the menu bar is "No current selection". Please advise.

    I am already doing that: creating the text box, typing the text, selecting the text i.e. highlighting the text. This morning, for a scant minute, the properties tool bar appeared and I was able to refine the text in a text box. Then it disappeared never to be activated again this morning.
    I work half of my weekly hours at this client office and I only have this problem on their pc and adobe software (version 9 pro). When I am home, my laptop and the adobe software (version 10 pro) is fine. I can create the text boxes and refine the format at will with no issues. Could it be a software version and/or update issue? Thanks for any assistance.

  • Customize Font size and color of text

    Hey guys,
    Sorry if this is basic, as I am new to this, and did a search but see anything,
    I am sometimes having a bit if tough time reading some of the fonts on the phone.
    I tried the black to white/white to black option under settings/general settings/accessability, and liked the look of the contacts since it made the fonts even clearer to read without the white background. Problem is that it changed everything else including photos, video, icon screen...everything. Kind of stupid.
    I was wondering if there was an app or a way to further adjust specific fonts and colors on the phone. If it doesn`t exist it would be a great must have free app from apple, for those of us who want the font size to be a little bigger or change the colors in specific areas of the phone to be a little more clear to read.By the way I have the 3GS.
    Again if this is a old idea/topic I apologize.
    Any thought is greatly appreciated,
    thanks,
    Jay2K

    Looks like you didn't get a reply on your post, but it is still a problem.  Font size is supposedly changeable via "Accessibility" in Settings, but it doesn't work.  You can turn on "Zoom".

  • How do I change header/footer print options for font, font size, and color?

    I know how to change the text for web page print of footers/headers. I can see no option to change font, font color, or font size (such as available on IE). I want to change the font, font color and font size of the footer/header when I print a web page. I read the FAQs, found nothing that seems to fit. Can you assist? or is this option available on Mozilla. I have the latest/greatest version (set to auto update).

    OK, my question was about how to change font/color in headers/footers... This suggestion changes the font/color in the text, but NOT in the footers, unless I want everything in the same font/color. I need footers/headers in RED BOLD. I can do this on IE, but there does not seem to be an option for Mozilla.

  • Default font, size and color for email

    I would dearly enjoy having the same font, of my choice, appear on each e-mail that I type, without having to reset each time. Specifically, Times Roman, Bold Italic, 20, Blue. When I set this for any one outgoing mail, it is gone the next time, and often even before I begin to type. Given the astounding capabilities of OS X, I would think that the mail program could be tweaked to achieve this, but my ProCare Creative at the local Apple Store says, "Not possible".
    Can anyone offer me hope?

    I'll cross fingers that Leopard will allow
    user to set a chosen default font for e-mails.
    Leopard has lots of templates:
    http://www.apple.com/macosx/leopard/features/mail.html
    I think "that other computer" allows it.
    Nothing to do with the "computer." Different apps have different features. Here's one list of other mail apps for Mac:
    http://www.pure-mac.com/email.html

Maybe you are looking for

  • Unable to see iTunes libraries bi-directionally on MBP 17"

    Ok, I've got an odd situation that I can't figure out. (I also posted this in the Bonjour Windows forum as well, but figured I might get help here as well) Here's the background information: 1) Home network consists of 2 routers. Router 1 (a Buffalo

  • Upgrade 10.2.0. 3 to upgrade 10.2.0.4

    While applying the patch set for 10.2.0.4 there is screen for Oracle Configuration Manager Registration,If I do not enable that at upgrade time ,how can I regiser later? Thanks

  • Suddenly my text entry is lagging/very slow in Mail

    This only happens entering text in Mail, not in text edit (or here). I'm using 10.5.8. Cause?

  • Can I use iMessage/FaceTime without a serial number on my Mac?

    I have a iMac that hade work done on it years ago. It no longer has a serial # in theabout this mac window. I just upgraded to Mountain Lion in part to use iMessage and especially FaceTime. I cannot get either program to work. I read online that thes

  • Controllin​g Kistler Quattro Jump Force Plate

    Hi everyone, Our lab recently acquired a Kistler Quattro Jump force plate (model #9290AD). Supposedly a great plate, but so far I've been unable to set up any sort of communication with it. From a company software side, they don't yet support Windows