Replacing all text in book with sample text

Hello fellows,
Is there a way to replace all the textual content in a book with some sample text using Extendscript?
If yes, could you please point me to the relevant APIs?
Thank you for your help in advance!

Yes, the point that Rick was making crossed my mind, too. Using regular expressions, you can easily specify which characters should be replaced. Listing a number of same-width characters and replacing them with an "x" is as easy as this:
sTextString.replace ( /[abcdefghknopqrsuvyz]/g, "x" );
This would leave the non-mentioned characters as they are. Depending a little bit on the fonts that are used, of course, as they might have different character widths for more than the ones I left out. But even if you only replace a couple of characters throughout the doc, it would be enough to get the desired effect.
The difficulty is getting to the text strings and also to replace them. There are many objects for which a GetText method exists, but you have to set the flags such that you actually get the right text strings out of that method. And then you have to figure out where in the doc the text string is, then delete the existing one and add the replacement. All of this has to be done without deleting any markers or anchors.
Another approach might be to set the text location to the first character in the main flow and then walking through the entire document character by character, testing each one and replacing it where required. But I don't think you would get into tables with that method, as those are linked to the running text via an anchor in that running text. So the table cells will have to be processed separately. And if you do have a method to change text in table cells, you can use that method on all paragraphs.
I think Rick has more experience in tweaking text strings. I am usually working on structured documents and only handling the element objects and their hierarchy, not so much changing the text content of documents. Rick, do you have an approach to walk through all text strings in a document and replace them without breaking anything ?
Ciao
Jang

Similar Messages

  • All web page display with lines, text are stretched and not legible

    all pages are displayed with stretched text, and pictures are also not loaded properly when scroll up and down.
    == This happened ==
    Every time Firefox opened
    == Last update to 3.6.3

    I am having similar problems. Ebay was not displaying correctly until I closed down the browser and restarted. Other websites had the same problem. In Facebook, many links are not working.

  • I have a sequence on tcp that is Standard Def. I have a new set of files in High Def that match the old files. I would like to replace all the SD footage with the HD footage. Anyone know of a workflow to do this task?

    I have a sequence on tcp that is Standard Def. I have a new set of files in High Def that match the old SD files. I would like to replace all the SD footage with the HD footage. Anyone know of a workflow to do this task?

    Do a media manage of the sequence converting the files to the appropriate HD format making the clips offline.  Then simply reconnect the offline clips to the HD clips.  There may be issues in the file names, but they can usually be worked out either with the naming options in media manager or renaming your hd files.  There are many utilities that allow you to batch rename files. 

  • Processing multiple files in a directory and merging them with sample text

    Hi,
    I'm trying to use automator (or applescript, or cmd line) to perform a repetitive action on around 5,000 html files.
    Here's the problem, can anyone help with the solution.
    Sample text is in a file called sample.txt
    I want to add the sample txt content to every file in a directory of my choice.
    so the script would need to.
    1. work it's way through the directory content.
    2. For each file it would append the content of the sample.txt and re-save the file to the original file name.

    sorry but in your first message you said you wanted it at the end of the file. also, you didn't really answer my question. an html file in text form usually starts with <html><head>... (it can have other junk there too)
    and ends with ...</body></html>.
    how do you want to handle that?
    cycling through files is not a problem.
    if you are using shell script action you can do the following:
    1. get specified finder items (put the folder with your html files in there)
    2. get folder content
    3. run shell script (pass input as arguments)
    for f in "$@"
    do
    #your shell script here
    done
    In the above "$@" is treated as the ambient folder from step 1 and f as the unix path of an item in that folder.

  • Book with no text

    I just finished laying out my book and looked at it in Preview before ordering. None of the text appears, although I inserted text on the cover and on every page. When I look at the book in iphoto, text is there. Anyone have any suggestions for getting the text to appear in Preview or in a finished book?
    Thank you very much.

    To confirm do a print to pdf and then check the pdf file. Or go thru the ordering process and after the book has been assembled, at the final ordering window, pause and try the following:
    How to Find the iPhoto Generated PDF File:
    1 - Start the ordering process and stop after the book has been assembled and you get to the Order pane where you select the cover color, copies, etc.
    2 - Go to the Finder and select the Go->Go to Folder menu item (CommandShiftG).
    3 - copy the following, “/private/var/tmp/folders.501/TemporaryItems/iPhoto” (for Panther the path is "/private/tmp/501/TemporaryItems/iPhoto“), and paste into the Go to Folder search box.
    4 - the iPhoto folder will be brought up. In it will be the PDF file that was generated by iPhoto. You can copy it (Option-drag) to the Desktop to review and/or save.
    Note: the iPhoto folder will not exist before you start the ordering process and is deleted after the order is completed or after you cancel the order and quit iPhoto.
    Then quit the order process. You can now view the file that would have been sent to Apple for printing.
    Run Font Book and make sure all of the fonts are enabled and available to you. Then run Disk Utility and repair disk permissions. You may also have to reinstall the 10.4.5.COMBO updater followed by a repair of permissions.

  • All the text I write with the text tool is small!

    I am not aware that I did anything weir. Either way, unless I put text size to 1000, the text isnt even visible. I'm not sure what could be wrong, so I took an image of it http://i278.photobucket.com/albums/kk101/notableman/Anotherphotoshopproblem.png
    I don't know what to click on in terms of settings. Can somebody please help?

    Oh, the resolution was set to 1! Must be the image that I opened up in Photoshop or something... Either way, its fixed now. Thanks!

  • Search and replace all spaces between quotes with uderscore

    Hello,
    I'm new on Powershell and I'm trying to make the script that:
    searches over file and replaces all the spaces which have been found between quotes;
    removes all quotes (except these which has not value eg "").
    For example:
    Source file:
    string3=string4 string="string1 string2 string23" string8="" string5="string7 string8"
    Destination file:
    string3=string4 string=string1_string2_string23 string8="" string5=string7_string8
    I have been created script that searches the data correctly
    $file="c:\scripts\mk.txt"
    $data=Get-Content $file
    $1
    $regex = [regex]@'
    (?x) # ignore pattern whitespace option
    (?<test>(["'])(?:(?=(\\?))\2.)*?\1)
    $data |% {
    if ($_ -match $regex){
    new-object psobject -property @{
    test = $matches['test']
    }#when adding "|select-object test" I'm getting the correct data
    I have stopped here on search / replace operation (from space to underscore, and by removing the quotes leaving the empty quotes non touched). Can you help me to finish the script?
    Thanks!

    Try this.  It uses the [Regex] Replace static method, with a script block delegate:
    $file="c:\scripts\mk.txt"
    $data=Get-Content $file
    $regex = '(\S+=[^"\s]+)|(\S+="[^"]+")'
    $delegate = { $args[0].value.replace(' ','_') -replace '"(.+)"','$1' }
    $data |% { [regex]::Replace($_,$regex,$delegate) }
    [string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "

  • Getting text ID and Text object  associated with item texts in PO...

    Hi,
    To print standard text on smartform for a given item in purchase order, I need to find the text ID and object associated with it.
    There are various texts like item text, Info record PO text, Material PO Text, Delievry Text, etc...
    Now when I go to ME22N, and select item detail for any item -> Texts , how do I get text ID, and object associated with it ?

    Hi ,
        Use table stxh,stxl
        FM read_text.
        you can view the text id by following
        this link
         me23->header-text-double click on text->menu goto->
         header        
    Regards
    Amole

  • Mx.controls.Text zoom issue with wrapped text. Is this a bug?

    We have created a diagram drawing tool in Flex, but we are having a serious issue with zooming. Everything zoom fine expect the Text control if it contains wrapped text. At certain zoom levels, some of the text seems to disappear (usually text at the end). I have tried everything, embedding fonts, turning anti-aliasing on and off, setting anti-aliasing to normal or advanced, but it doesn't seem to fix the problem. Is this is a known bug?
    If you check out the pictures (see attachments), you will see that the part of the text ('34') disappears at a certain zoom level.
    There is another blog who suggest to embed the font and set the antiAliasType to ‘animation’ (http://www.mehtanirav.com/2008/08/20/zooming-text-area-in-flex-messes-up-word-wrap-bug%20), but this doesn't seem to work for me either. I don't know if I am doing this correctly though, but I embedded a font and called text.setStyle("fontAntiAliasType","animation"). However, 'animation' is not one of the  AntiAliasType contants. According to the official documentation, the AntiAliasType constants are 'advanced' or 'normal'.
    Any help will be appreciated.

    Try this:
    import javax.swing.*;
    import java.awt.event.*;
    import java.awt.*;
    import javax.swing.text.*;
    class textpaneColor extends JFrame {
       JTextPane tp = new JTextPane();
       JButton button = new JButton("color");
       public static void main(String args[]) {
          textpaneColor obj = new textpaneColor();
          obj.showMe();
       void showMe() {
          button.addActionListener(new buttonListener());
          setSize(200,200);
          getContentPane().setLayout(new BorderLayout());
          getContentPane().add(tp, BorderLayout.CENTER);
          getContentPane().add(button, BorderLayout.SOUTH);
          setVisible(true);
       class buttonListener implements ActionListener {
          public void actionPerformed(ActionEvent e) {
             SimpleAttributeSet set=new SimpleAttributeSet();
             StyleConstants.setForeground(set,Color.BLUE);
             StyledDocument doc=tp.getStyledDocument();
             doc.setParagraphAttributes(0,999999,set,true);
    };o)
    V.V.

  • Old text messages combining with new text messages

    When I send a text message one good message is sent out along with another text message that is a combination of my current message and some random message from months ago that has already been deleted. The message will occasionally also contain CL_IOS. any ideas on why this is happening

        That's definitely an odd combination, caseyhemmes. Are you using the default message application? Did you recently activate this device? What was your previous device? Can you please check the following settings: Select your Message application>Menu>Settings>Uncheck Enable signature if currently checked.
    AndreaS_VZW
    Follow us on Twitter @VZWSupport

  • Replacing all addresses in proxyaddresses with array

    we have local AD that synchronizes to O365
    we are adding a new email address with new domain to all users in two phases.
    1) add new email address and let settle.
    2) make new email address the primary email address (smtp: -> SMTP:)
    I have a script I found where everything seems to work until the last command:
    Set-ADUser -identity $UserName -Replace @{ProxyAddresses=$NewProxyAddresses}
    The error I get with this command is:
    Invalid type 'System.Management.Automation.PSObject'.
    Parameter name: ProxyAddresses
        + CategoryInfo          : InvalidArgument: (user:ADUser) [Set-ADUser], ArgumentException
        + FullyQualifiedErrorId : Invalid type 'System.Management.Automation.PSObject'.
    Parameter name: ProxyAddresses,Microsoft.ActiveDirectory.Management.Commands.SetADUser
    The output of $NewProxyAddresses is:
    smtp:[email protected]
    smtp:[email protected]
    X400:C=us;A= ;P=Company;O=Exchange;S=surname;G=givenname;
    SMTP:[email protected]
    The output of the $newProxyAdderesses is correct, but I am unable to run the set-aduser command

    If I read the existing value into a variable:
    $proxy = get-aduser identity $username -property proxyAddresses | select -expand proxyAddresses
    And try to add or replace using that variable I get the same error.  If I read each of those values into a new variable, I can't add a single one of them without getting the same error:
    $j = @()
    foreach ($y in $proxy){$j+= $y}
    If I copy the individual addresses text on screen and create a new array with those it works:
    $newproxy = @()
    $newproxy += "smtp:[email protected]"
    $newproxy += "SMTP:[email protected]"
    $newproxy += "X400:c=US;a= ;p=company;o=city;s=last;g=first;"
    Both variables are the same type:
    PS C:\Windows\system32> $proxy.gettype()
    IsPublic IsSerial Name                                     BaseType
    True     True     Object[]                                 System.Array
    PS C:\Windows\system32> $newproxy.gettype()
    IsPublic IsSerial Name                                     BaseType
    True     True     Object[]                                 System.Array
    If I output the contents of both variables to text files and compare them with Notepad++ they are the same.  So I am stumped as to a specific explanation, but what I can tell you is how you construct your variable is most likely what's causing
    the problem.
    Also, when you do construct your variable, build it in reverse order.  The address you want listed first should be the last one in the array, as the top of the list shows the most recently added address.
    I hope this post has helped!

  • ICloud saved my daughter's Pages documents and replaced all of my documents with hers. My documents are not on iCloud, how do I get them back?

    My daughter saved her Pages documents to my iCloud account on her iPhone while my documents were apparently saved only to my phone. Never had a problem with that until tonight when iCloud synched so now I have all of my daughter's homework but all of my paperwork is gone! I logged into iCloud and it is only her documents there. How do I get my Pages documents back without a backup?
    iphone 4s, version 6.1.3

    If you took the picture on your iPhone, they are still there on your iPhone, unless you specifically deleted a particular picture from your iPhone. And likewise, if the picture was taken on your iPad, it is still there on your iPad, unless you specifically deleted that picture from the iPad.
    Now ... if you're counting on pictures still "being there" from being on the Photostream ... don't count on that, because that's only a temporary place and it has a time limit and a count limit for how many picture it will have. While the pictures you took on your iPhone and iPad will remain on each one respectively (so you won't lose those), it won't necessarily remain on the Photostream part ... which is only for sharing anyway ... and not meant for storage.
    Whatever pictures you had on your Camera Roll and thus is in the backup in iCloud, will still be there.

  • Missing text in book...

    Hello,
    I'm trying to create a party invitation & created a custom book with the text added over an image. I then exported this as a jpeg & then imported back into Aperture.
    Now when I order the prints from the online service, it arrives without the text & only the image.
    I'm not sure why this is, anyone have any ideas?
    thanks

    I'm not sure I understand what happened; can you clarify?

  • Replace icloud address book with Mac address book?

    I just created my icloud account on my Mac- I already had it set up on my iphone.  When I did this, it pulled my address book from my icloud but my address book On My Mac is most up to date.  How can I replace my icloud address book with my Mac address book on my mac?

    Welcome to the Apple Community.
    Go to users and groups and choose only your On My Mac Contacts to display.
    Ensure that nothing is typed in the search field.
    Click to select the first contact and shift-click the last to select them all.
    Drag the list of contacts to your desktop.
    Delete the contacts from Address Book (using your delete key).
    Now choose only your iCloud Contacts to display
    Ensure that nothing is typed in the search field.
    Click to select the first contact and shift-click the last to select them all.
    Delete the contacts from Address Book (using your delete key).
    Make sure your iCloud account is your default account (preferences > general).
    Select All iCloud contacts from users and groups.
    Drag the file you previously dragged to your desktop back onto Address Book.
    You might want to back up all your contacts before you begin.
    Select All contacts in users and groups
    Click to select the first contact and shift-click the last to select them all.
    Drag the list of contacts to your desktop.

  • Preprocessing xml to replace all xpath references with the referred elements

    Hi,
    Is it possible to sort of pre-process xml before querying such as we replace all internal xpath references with the referred elements?
    So below is the xml and as we see the typeId element of second app.test.module.library.Publisher element refers to the typeId element in the first app.test.module.library.Publisher element through xpath reference . Seems this is done by XStream(which we
    use for xml-java) to reduce the size of resulting xml. This is all fine and in java one can easily traverse through such xpath references, but the challenge i am facing is in sql where i use node() function to get each of app.test.module.library.Publisher
    element and fetch value of selectedText element of both the children of app.test.module.library.Publisher - (typeId, regionCode). 
    declare @publishers xml
    set @publishers = '
    <publishers>
      <app.test.module.library.Publisher>
        <typeId>
          <selectedId>101</selectedId>
          <selectedText>Book</selectedText>
        </typeId>
        <regionCode>
          <selectedId>102</selectedId>
          <selectedText>NWD</selectedText>
        </regionCode>
      </app.test.module.library.Publisher>
      <app.test.module.library.Publisher>
        <typeId reference="../../app.test.module.library.Publisher/typeId" />
        <regionCode>
          <selectedId>101</selectedId>
          <selectedText>UWY</selectedText>
        </regionCode>
      </app.test.module.library.Publisher>
      <app.test.module.library.Publisher>
        <typeId>
          <selectedId>100</selectedId>
          <selectedText>Deposit</selectedText>
        </typeId>
        <regionCode>
          <selectedId>100</selectedId>
          <selectedText>WHU</selectedText>
        </regionCode>
      </app.test.module.library.Publisher>
    </publishers>';
    select typeId = el.e.value('(typeId/selectedText)[1]','varchar(max)')
          ,regionCode = el.e.value('(regionCode/selectedText)[1]','varchar(max)')
    from @publishers.nodes('/publishers/app.test.module.library.Publisher') as el(e)
    If you execute this, the second typeId value will be null but ideally I should be able to reach to the reference, which is typeId of first app.test.module.library.Publisher element and should be able to fetch selectedText of it, which is correct value (Book).
    In other words first two app.test.module.library.Publisher elements are of same type (Book).
    Since I am not able to find the way to do it, I thought I should have some way to process this xml to replace all such references with the referred element and that will eliminate the need to go for tedious xpath reference based access.
    Thanks

    I was able to get a result using dynamic SQL, but my guess is if you have more complicated examples it probably won't work.  I also make an assumption you know the full path of the first reference you want.  Anyway, try this:
    DECLARE @xml XML = '<publishers>
    <app.test.module.library.Publisher>
    <typeId>
    <selectedId>101</selectedId>
    <selectedText>Book</selectedText>
    </typeId>
    <regionCode>
    <selectedId>102</selectedId>
    <selectedText>NWD</selectedText>
    </regionCode>
    </app.test.module.library.Publisher>
    <app.test.module.library.Publisher>
    <!--<typeId reference="../../app.test.module.library.Publisher/typeId" />-->
    <typeId reference="../../app.test.module.library.Publisher/typeId" />
    <regionCode>
    <selectedId>101</selectedId>
    <selectedText>UWY</selectedText>
    </regionCode>
    </app.test.module.library.Publisher>
    <app.test.module.library.Publisher>
    <typeId>
    <selectedId>100</selectedId>
    <selectedText>Deposit</selectedText>
    </typeId>
    <regionCode>
    <selectedId>100</selectedId>
    <selectedText>WHU</selectedText>
    </regionCode>
    </app.test.module.library.Publisher>
    </publishers>'
    -- So you basically need to create and execute this string;
    -- but how do you work out the first bit of the string ?
    --SELECT @xml.query('(publishers/app.test.module.library.Publisher/typeId/../../app.test.module.library.Publisher/typeId)[1]');
    DECLARE @fullPath NVARCHAR(MAX) = 'publishers/app.test.module.library.Publisher/typeId/@reference' -- the full path of the reference
    DECLARE @shortPath NVARCHAR(MAX) = LEFT( @fullPath, CHARINDEX( '@', @fullPath ) - 1 ) -- full path without attribute name
    IF @shortPath IS NULL
    RAISERROR ( 'Unable to get @shortPath.', 16, 1 )
    -- Start processing the XML
    DECLARE @sql NVARCHAR(MAX), @reference NVARCHAR(MAX)
    -- Extract the reference
    SET @reference = @xml.value('(publishers/app.test.module.library.Publisher/typeId/@reference)[1]', 'NVARCHAR(MAX)')
    -- Construct the sql
    SET @sql = 'SELECT @xml.query(''(' + @shortPath + @reference + ')[1]'')'
    -- Execute the SQL
    EXEC sp_executesql @sql, N'@sql NVARCHAR(MAX), @xml XML', @sql, @xml
    Post back any issues you have with that approach and your real data.

Maybe you are looking for