Search for text and font

I have an 800 page pdf document to index and so far I have a script that will search for a list of keywords. But the text has large sections of code in a different font, and I think we would like to generate an index of just code examples. Is there a way to search for text of a given font in applescript? Something like
set theSel to find text theText
if the font of theSel is "Times"
write to file, etc.

Please do send a page, I might be able to spot where the font problem is coming from - but no guarantee Address is in my profile.
You asked about the script formatter. red_menace of this forum wrote the script I use. To use it, you copy the script that you want to format to the clipboard and run the formatter. This then places the marked-up text in the clipboard so that you can paste it into the forum page.
<pre style="
font-family: Monaco, 'Courier New', Courier, monospace;
font-size: 10px;
margin: 0px;
padding: 5px;
border: 1px solid #000000;
width: 720px; height: 340px;
color: #000000;
background-color: #FFDDFF;
overflow: auto;">
script formatter - formats the clipboard text for forum posting
last reviewed January 19, 2009   red_menace[at]mac[dot]com
Input: text read from the clipboard
Output: formatted text copied to the clipboard
set AppleScript's text item delimiters to " "
-- some constants and switches
property TextColor : "#000000" -- black  (see http://www.w3schools.com/tags/ref&#95;colornames.asp)
property BackgroundColor : "#FFDDFF" -- a light plum/purple
property BorderColor : "#000000" -- black
property TheWidth : "width: 720px; " -- a width attribute  (deprecated in HTML 4.01)
property UseWidth : true -- use the width attribute?
property LineCount : 25 -- the number of lines before including the height attribute
property TheHeight : "height: " & ((LineCount * 13.6) as integer) & "px; " -- a maximum height for the <pre> box
property Emphasize : false -- emphasise (bold) the script text?
property UseURL : false -- include a Script Editor message link?
property AltURL : false -- use an alternate URL encoding?
property ToolTips : {¬
"this text can be pasted into the Script Editor", ¬
"this text can be pasted into an Automator 'Run AppleScript' action", ¬
"this text can be pasted into an Automator 'Run Shell Script' action", ¬
"this text can be pasted into a HTML editor", ¬
"this text can be pasted into a text editor", ¬
"- none -"}
property TooltipDefault : {item 1 of ToolTips} -- keep track of the last tooltip used
property TempFile : "Script_Formatter_TempFile" -- a temporary work file
try
-- write the clipboard to the temporary file
set TheClipboard to (the clipboard) as text
if TheClipboard is in {"", space, tab, return} then return -- clipboard is (basically) empty
set MyOpenFile to open for access ("/tmp/" & TempFile & ".txt" as POSIX file) with write permission
set eof of MyOpenFile to 0 -- empty any previous temp file
write TheClipboard to MyOpenFile
close access MyOpenFile
if UseURL then
-- encode URL  (see http://developer.apple.com/documentation/Darwin/Reference/Manpages/man1/pydoc.1. html)
do shell script "/usr/bin/python -c 'import sys, urllib; print urllib.quote(sys.argv[1])' " & quoted form of TheClipboard
-- add a link wrapper
set URLtext to "applescript://com.apple.scripteditor?action=new&script=" & the result
if AltURL then -- use an alternate URL encoding
set URLtext to "Click here to [url=" & URLtext & "]open this script in the Script Editor[/url]:<br />"
else -- use HTML anchor tag
set URLtext to "Click here to <a href=\"" & URLtext & "\">open this script in the Script Editor</a>:<br />"
end if
set PromptText to ((count URLtext) as text) & " URL and "
else
set {URLtext, PromptText} to {"", ""}
end if -- UseURL
-- convert to HTML  (see http://developer.apple.com/documentation/Darwin/Reference/ManPages/man1/textutil .1.html)
do shell script "cd /tmp/; /usr/bin/textutil -convert html -excludedelements '(html, head, title, body, p, span, font)' -encoding US-ASCII " & TempFile & ".txt"
-- fix up some formatting and add a pre wrapper  (see http://www.w3schools.com/tags/default.asp)
set HTMLtext to rest of paragraphs of (read ("/tmp/" & TempFile & ".html" as POSIX file))
if (count HTMLtext) is less than LineCount then -- skip the height attribute
set Height to ""
else
set Height to TheHeight
end if
set HTMLtext to FixCharacters from (HTMLtext as text) -- additional character encodings
if UseWidth then
set Width to TheWidth
else
set Width to ""
end if
if Emphasize then set HTMLtext to "<strong>" & HTMLtext & "</strong>"
set HTMLtext to "<pre style=\"
font-family: Monaco, 'Courier New', Courier, monospace;
font-size: 10px;
margin: 0px;
padding: 5px;
border: 1px solid " & BorderColor & ";
" & Width & Height & "
color: " & TextColor & ";
background-color: " & BackgroundColor & ";
overflow: auto;\"
title=\"\">
" & HTMLtext & "</pre>
-- assemble everything on the clipboard
set TheResult to choose from list ToolTips ¬
with title "Script Formatted" with prompt PromptText & ((count HTMLtext) as text) & " HTML characters will be placed on the clipboard (plus the following ToolTip):" default items TooltipDefault OK button name "OK" cancel button name "Cancel" with empty selection allowed without multiple selections allowed
if TheResult is false then -- cancel button
error number -128
else -- add the selected title attribute (tooltip), if any
set TooltipDefault to TheResult as text
set Here to (offset of " title=" in HTMLtext) - 1
set There to (offset of ">" in HTMLtext) - 1
if TheResult is in {{}, "- none -"} then -- no tooltip
set the clipboard to URLtext & (text 1 thru (Here - 1) of HTMLtext) & (text (There + 1) thru -1 of HTMLtext)
else
set the clipboard to URLtext & (text 1 thru (Here + 9) of HTMLtext) & TheResult & (text There thru -1 of HTMLtext)
end if
end if -- TheResult is false
on error ErrorMessage number ErrorNumber
log space & (ErrorNumber as text) & ":" & tab & ErrorMessage
try
close access MyOpenFile
end try
if (ErrorNumber is -128) or (ErrorNumber is -1711) then -- nothing (user cancelled)
else
activate me
display alert "Error " & (ErrorNumber as text) message ErrorMessage as warning buttons {"OK"} default button "OK"
end if
end try
to FixCharacters from TheText
fixes (converts) formatting characters used in some message forums  (see http://www.asciitable.com/)
parameters - TheText [text]: the text to fix
returns [text]: the fixed text
-- this list of lists contains the characters to encode - item 1 is the character, item 2 is the HTML encoding
set TheCharacters to {¬
{"!", "&#33;"}, ¬
{"*", "&#42;"}, ¬
{"+", "&#43;"}, ¬
{"-", "&#45;"}, ¬
{"[", "&#91;"}, ¬
{"\\", "&#92;"}, ¬
{"]", "&#93;"}, ¬
{"^", "&#94;"}, ¬
{"_", "&#95;"}, ¬
{"~", "&#126;"}}
set TempTID to AppleScript's text item delimiters
repeat with SomeCharacter in TheCharacters
if item 1 of SomeCharacter is in TheText then -- replace
set AppleScript's text item delimiters to item 1 of SomeCharacter
set the ItemList to text items of TheText
set AppleScript's text item delimiters to item 2 of SomeCharacter
set TheText to the ItemList as text
end if
end repeat
set AppleScript's text item delimiters to TempTID
return TheText
end FixCharacters
</pre>

Similar Messages

  • Search for texts and logos in smart forms

    Hi there,
    Does anyone know if there is a function module that can search for specific texts and logos in smart forms?
    Any response would be really appreciated.
    Thanks
    HW

    Hi
    I really doubt if there is any FM like that. But, you can always search the existing logos in the Appln Server, the tcode is SE78.
    Regards,
    Vishwa.

  • Search for text and create report

    I have a text file that I need to search through, find specific elements and create a report based off of those findings. The text will have multiple paragraphs, each one needs to be reported on. I need to report on
    Router_XXXX
    Layer 1 Status
    Layer2 Status
    Ces = 1 State='y'
    Ces = 2 State="z"
    Router_0002#show isdn stat
    Global ISDN Switchtype = basic-ni
    ISDN BRI0/2/0 interface
    dsl 4, interface ISDN Switchtype = basic-ni
    Layer 1 Status:
    ACTIVE
    Layer 2 Status:
    TEI = 89, Ces = 1, SAPI = 0, State = MULTIPLEFRAMEESTABLISHED
    TEI = 90, Ces = 2, SAPI = 0, State = MULTIPLEFRAMEESTABLISHED
    TEI 89, ces = 1, state = 8(established)
    spid1 configured, spid1 sent, spid1 valid
    Endpoint ID Info: epsf = 0, usid = 1, tid = 1
    TEI 90, ces = 2, state = 8(established)
    spid2 configured, spid2 sent, spid2 valid
    Endpoint ID Info: epsf = 0, usid = 2, tid = 1
    Layer 3 Status:
    0 Active Layer 3 Call(s)
    Active dsl 4 CCBs = 0
    The Free Channel Mask: 0x80000003
    Total Allocated ISDN CCBs = 0

    More information is required.
    Is there one Router_xxxx entry per file? or can there be multiple Router_xxxx's?
    In your example, I'm guessing that you want the Layer 1 Status to report 'ACTIVE', i.e. the entire contents of the next line, correct?
    What about the Layer 2 Status? It doesn't have a similar line following it. Do you want all the following lines? the next line? the next 2 lines?
    The phrase 'Ces = 1' appears both in the line following Layer 2 Status, and in the line that begins TEI 90, six lines later. What do you want to report?

  • Search file for text and delete the found text.  How?

    I need to know how to search a file for text and delete the found text. I think grep will let you do this but not sure of the syntax.

    Hi Dmcrory,
       In addition to what Camelot and nobody loopback point out, one must also consider the fact that UNIX text tools are largely line based. You also fail to tell us for what kind of text you are searching. If you are looking for multiple words, there's a very good chance of finding the expression wrapped onto different lines. With hyphenation, even single words can wrap to multiple lines. Tools that search line-by-line will miss these unless you use multiline techniques.
       Multiline substitutions require that you write "read-ahead" code for the command line tool that you're using and that you take that into account in the substitution. Given how you want the results to be printed out, you may also want to preserve any newlines found in the match, which is even more difficult. That could bring up the subject of line endings but that's a completely different topic.
       I apologize if this sounds discouraging. Multiline searches aren't needed that often and in most of those cases, exceptions can be dealt with by hand. I just didn't want you to get surprised by it. To give you an idea of how easy basic substitution is, have a look at Tom Christiansen's Cultured Perl: One-liners 102 and One-liners 101. Both have some "in-place" substitution examples.
    Gary
    ~~~~
       MIT:
          The Georgia Tech of the North

  • Problems with searching for text in Preview

    Hi, everyone...I'm hoping someone can help me out with this. I have an old MBP with Tiger installed and Preview 3.0.9. I have attempted to search for words in numerous PDF files and the search function NEVER brings up the words even when I know the words are contained in the document. I read the Preview manual and I know I'm following the correct procedures in searching for text, but nothing seems to work. Can anyone help me out with what I may be doing wrong? Thanks!

    I can't picture what you could possibly be doing wrong, there's not much choice in the matter.
    The only time Searching fails here is if the text in the PDF is actually only a graphic of the text.
    Are these PDFs that you made? If so, what APP?
    If you down load this PDF, does Search work on it?
    http://web.fastermac.net/~bdaqua/TestText.pdf

  • Searching for text containing diacritics (accents)

    iTunes doesn't find titles when searching for texts containing diacritics (like "âàéêèëîïôöûùü", in french). Even when a song title is copied and pasted in the search field, it is still not found. I get the same problem when I call the search from AppleScript. When searching for only the part before or the part after the diacritic, then iTunes does find something. I think it is a bug. Is there someone that knows what to do?

    Too bad the problem is back with the new iTunes 8.0. It is quite annoying since I got a lot of entries with those diacritics...

  • Editor: Annoying pop-up for choosing main programs when searching for text

    Hi,
    We're upgrading to ECC60 and are getting frustrated when searching for text in a source code within the ABAP editor.
    For every include contained in the main program you are searching in there is a pop-up asking to choose the main program for that include.
    This can get crazy when searching in a standard SAP program such as SAPMV45A. You'll have to process through 30-40 of these pop-up windows before your search results appear. I each pop-up you have to scroll though dozens of main programs to find the one you are doing the search in.
    Can this be turned of somehow to have the search functionality work as it did in previous version, where the Editor knows that the program you are launching the search from is the main program you want the results from?
    Thanks,
    Peter

    HI Peter
    Please check if program: <b>RPR_ABAP_SOURCE_SCAN</b> can help you...
    Regards
    Eswar

  • Dreamweaver cs5.5 opening files after searching for text code

    This just occured this afternoon.  I was working on a page and when I went to search for text in the code (ie "/head") dreamweaver would open a previously opened page.  In other words I was working on "walk.php" and when I did the search for "/head", dreamweaver opens "add_rsurvey_data.txt".  I know what the 2nd file is but I haven't opened it in months.  It's just a temp data file that my partner sent me.
    I'm using cs5.5
    Adobe will not help me.
    Thanks
    Glenn

    We don't get attachments from email replies here.  You would need to use the Camera icon in the actual web forum to a post screen shot.
    If this began yesterday, try deleting your Cache & restarting DW.
    http://forums.adobe.com/thread/494811
    Nancy O.

  • "Search for text" Zooms when number keys pressed. Expecting it to FIND text

    For months I have been using (&relying on) the "search for text when I start typing " feature.
    I am a school teacher & this helps me to search for students & record scores in an online grading program.
    The "search for text when I start typing feature" stopped working two days ago.
    Before, whenever I typed the "Find" box immediately opened up, searched the screen,
    and highlighted whatever I had just typed. Now, when I enter a "1", "2" , "6" , "9" or "0" (zero)
    the find box does not come up- so this disrupts all the grade recording process for me.
    Instead, when I type in 6 or 9 (it zooms in the screen instead), 0 (it zooms out instead) and I cannot tell what happens
    when I type in 1 or 2 (nothing appears to happen- but no "Find" box comes up.
    Edit by a moderator to improve the title
    (As suggested by a contributor, flagging the post)
    Was
    *The Firefox "search for text when I start typing feature" has just stopped working correctly
    Now
    *"Search for text" Zooms when number keys pressed. Expecting it to FIND text
    ~J99
    I tried restarting Firefox and turning on/off the Advanced feature ( "search for text when I start typing feature")
    but it did not help. I am using a Mac. I also tried using an external keyboard/keypad but the exact same
    results occur.
    Please help!
    Thanks,
    Barry

    The keyboard shortcut for resetting the zoom level is Command+0, so seeing that kind of response implies that Firefox is misreading the state of the Command key, thinking it is stuck down. Usually tapping the key numerous times will send a signal to all programs that the key has been released (at least on Windows).
    On the other hand, in that case, Command+6 should jump to the sixth tab in the current window, it shouldn't change the zoom level. So... hmm...
    In case a component of the OS has malfunctioned, have you already tried shutting down the system completely and then starting it up again?

  • Spotlight search for text messages not working

    After upgrading to ios8, I discovered that the spotlight search for text messages only "sees" my last two texts but not any of the others I have on my phone. These are all active conversations, not deleted messages.  Any ideas how to fix?  Thanks.

    I Fixed mine by going to setting->General->Sptolight and unchecking "messages", exiting the function then returning and rechecking "messages".

  • I have checked "Search for text when I start typing" but it is not happening since your latest update.

    I have checked “Search for text when I start typing” but it is not happening since your latest update. This is very important to me as I keyboard - not use the mouse. What can I do? Also, before the last update I could leave the window (alt+tab) and return and just type and it would type it is the search box. Now I have to take my hand off the keyboard and get the mouse three times for every search, slowing my work way, way down. What other flag do I need to put this back the way it was? Should I also remove the “Automatically check for updates” so that this will not happen again? Please, please help.

    Hi CynthiaP,
    You should look at the article [http://kb.mozillazine.org/Preferences_not_saved Preferences not saved]. It may just be an issue with the pref file!
    Hopefully this helps!

  • Search for text when I start typing, I want to disable it but it doesn'

    I chat in chat rooms from time to time and I find it bothersome when every time I start to type the computer starts to search for text. I have gone to firefox options and it is not enabled but search it does. Can you suggest a way that I can stop that from happening?
    Thank you
    Sherrie

    See:
    *http://kb.mozillazine.org/Find_bar_opens_when_typing_in_textbox
    *searchhotkeys: http://nic-nac-project.de/~kaosmos/index-en.html#searchkeys

  • I have problem with my wifi in 4 S, i cant connect to any wifi itried resetting network setting and reset all setting but the result was the same, its only keeps searching for wifi and cant find any, itried to use OTHER but also didnt work.please help me

    i have problem with my wifi in 4 S, i cant connect to any wifi itried resetting network setting and reset all setting but the result was the same, its only keeps searching for wifi and cant find any, itried to use OTHER but also didnt work.please help me???

    If Join was on then your home wi-fi must be set to Non-Broadcast.  If you did not set this up (maybe your provider did) then you will need to find the Network Name they used, and any password they used.  The SSID is Security Set ID and to see more try http://en.wikipedia.org/wiki/SSID .  Basically it is the name used to identify your router/network.  A lot of times the installer will leave it set as LinkSys, or Broadcom or whatever the manufacturer set it as for default.  Your best bet is to get whoever installed it to walk you through how they set it up, giving you id's and passwords so you can get in.  HOWEVER, if you are not comfortable with this (if you set security wrong, etc.) you would be well ahead of the game to hire a local computer tech (networking) to get this working for you.  You can also contact the vendor of your router and get help (if it is still in warranty), or at least get copies of the manuals as pdf files.  Sorry I can't give you more help, I hope this gives you an idea where to go from here to find more.

  • Windows Server 2003 R2 Enterprise Edition 32 bits Service Pack 2 never finishes searching for updates and use 100% of CPU.

    Hi everyone, I am having issues updating a clean Windows Server 2003 R2 Enterprise Edition 32 bits Service Pack 2, so any help with be appreciated cause I've already tried all my cards for the past 5 days in this particular issue without success.
    All I did so far is installing Windows Server 2003 R2 Enterprise with Service Pack 2, open IE to update, it keeps searching for updates and never stop, after 20mn to 30mn the process svchost.exe start using 100% of my CPU.
    I already tried the following scenarios:
    1-  Install IE8, install the update KB927891 and the Windows Update Agent 3.0 (I already had this one installed). Reboot and run windows update trough IE8 and the problem did not solved.
    2- Install those 2 software "MicrosoftFixit.wu.MATSKB.Run" and "MicrosoftFixit50777", open IE to update, it still hangs and continues eating my CPU. This is the output of "MicrosoftFixit".
    Windows Update error 0x8007000D(2014-01-06-T-06_06_34A) --> Not Fixed
    Cryptographic service components are not registered (This service is actually running successfully) --> Not Fixed
    3- I found the following script that would register some DLL, deleting the "SoftwareDistribution" and forcing windows update to solve the problem and nothing happened either.
    Link to script:
    http://gallery.technet.microsoft.com/scriptcenter/Dos-Command-Line-Batch-to-fb07b159#content
    Here is a link to the content of my WindowUpdate.log file:
    https://skydrive.live.com/redir?resid=883EE9BE85F9632B%21105
    Thank you in advance for helping.

    All I did so far is installing Windows Server 2003 R2 Enterprise with Service Pack 2, open IE to update, it keeps searching for updates and never stop, after 20mn to 30mn the process svchost.exe start using 100% of my CPU.
    Herein is the root cause of your issue. A topic that's been discussed in several blogs, forums, and even in the media since September regards a known issue with attempting to patch IE6 RTM via Windows Update.
    Aside from that particular issue... browsing the Internet with an unpatched instance of IE6, especially from a Windows Server system, is also asking for a world of hurt.
    Might I suggest the following:
    Download the IE8 for Windows Server 2003 installer to a thumb drive.
    Download the latest Cumulative Security Update for IE8 for Windows Server 2003 to a thumb drive.
    Reinstall Windows Server 2003 with Service Pack 2.
    Upgrade to IE8 from the thumb drive installer and apply the
    Cumulative Security Update.
    Now your machine is capable of safely browsing to Windows Update to install the rest of the updates (well, maybe, there's also all those other Security Updates from the past seven years that your machine still has vulnerabilites for -- even those seven
    years of updates are going to take a Very Long Time to scan for, download, and install).
    Why don't you have a WSUS server? -- noting, wryly, that you've posted in the *WSUS* forum.
    Lawrence Garvin, M.S., MCSA, MCITP:EA, MCDBA
    SolarWinds Head Geek
    Microsoft MVP - Software Packaging, Deployment & Servicing (2005-2014)
    My MVP Profile: http://mvp.microsoft.com/en-us/mvp/Lawrence%20R%20Garvin-32101
    http://www.solarwinds.com/gotmicrosoft
    The views expressed on this post are mine and do not necessarily reflect the views of SolarWinds.

  • My iphone 3g is keep searching for network, and the carrier unable to load network list , wat shall i do?  Read more: My iphone 3g is keep searching for network, and the carrier unable to load network list

    My iphone 3g is keep searching for network, and the carrier unable to load network list , wat shall i do?

    Yes, that kind of tallies with my experience ... after 3 days of useless iPhone 3G (BTW, killing 3G on the phone and relying on acquiring AT&T 2G didn't help, it still locked onto T-Mobile with the result that it was draining battery and rebooting frequently!), I ended up visiting the local Apple Store.
    Although the visit was not to resolve the iPhone problem, whilst there I happened to cycle the phone and due to the store having a local AT&T cell, the strength of the local signal meant that I finally re-acquired a AT&T 3G signal ... once locked on again the phone was fine for the next day.
    Nett outcome of this is that I would prefer to lay most of the blame for this debacle on the poor state of 3G support both by AT&T (and US carriers in general), maybe exacerbated in my case by two related events (the local DNC in Denver, which saturated local AT&T cells including 3G and a proliferation of v2.0.0 and v2.0.1 firmwares on iPhones in town, which dragged cell coverage into the weeds).
    It would be nice for future sanity if AT&T and T-Mobile could at least resolve the ability to acquire/release the iPhone gracefully, otherwise I'll be very sceptical of travelling back to the US with only my iPhone, as a self-employeed consultant I can't afford to be out of touch for three days again!

Maybe you are looking for