saranyc Posted June 22, 2007 Posted June 22, 2007 I am trying to have FMP open a file from a server. The name of the file is contained in a field in each record. This should be simple, but I'm not sure how to go about it. Here's what I have: tell application "Finder" activate open "Shared Items:Agreements_scans:.pdf" end tell After the 2nd colon, before the .pdf, I need to insert the field contents of that record. How can I do this? I'm sure this is simple, I've just never worked with applescript before. Any advice would be great!
AudioFreak Posted June 22, 2007 Posted June 22, 2007 Why not just use a container field to store the location of the file or store the actual file in the container field. Then open using Filemaker Scripting and avoid AppleScript alltogether? Michael
aholtzapfel Posted June 22, 2007 Posted June 22, 2007 Will the web viewer display pdf files if given the path? I havn't tried this yet but it is worth a shot. (I would try it but I don't have 8.5 at my desk yet)
AudioFreak Posted June 22, 2007 Posted June 22, 2007 I don't think so but I may be wrong. But if you make a container field and right click on it and insert the file itself or choose Reference only you can open the pdf in Adobe using Filemaker scripting. I think on Mac Send Event script step opens the file.
Lee Smith Posted June 23, 2007 Posted June 23, 2007 The Web Viewer is not available in v8.x, it is a new feature of 8.5. Lee
Genx Posted June 23, 2007 Posted June 23, 2007 (edited) Yeh, but 8.x technically includes 8.5 -- i mean 5 is x. That was the point of the tongue smiley... Though i suppose I should've put more emPHAsis on the 0. Edited June 23, 2007 by Guest
Lee Smith Posted June 23, 2007 Posted June 23, 2007 Hi Genx, Sorry, if using 8.x to represent any version of 8 mislead you, I should not have included it. even though, the Reply went on to state "[color:blue]it is a new feature of 8.5." BTW, wouldn't x = 10, and not 5. Lee :giggle:
aholtzapfel Posted June 23, 2007 Posted June 23, 2007 I lied a pdf WILL open in a web viewer (I had trouble with assigning a local path but I got it to display a pdf posted on the web). Does anyone know how to point the web viewer to a local or network path? BTW doesn't it say that saranyc has 8.5
Lee Smith Posted June 23, 2007 Posted June 23, 2007 Hi aholtzapfel, BTW doesn't it say that saranyc has 8.5 Yes, but I was responding to your Reply, which you don't show 8.5 in your Profile. Your Reply sounded like you were trying to open it in version 8. BTW, you can see who the person is replying to by looking at the "[color:blue]In response to" that shows in body of the Reply. Note, in this case, it was addressed to you. Lee
aholtzapfel Posted June 23, 2007 Posted June 23, 2007 (I've got it in the office on one machine and many more coming soon, just not at my desk. : ) Oh, I've had adobe reader crash when Internet exprorer and filemaker were both tring to use it. (ALOT more testing is required before I try to display a pdf in a webviewer in a distributed solution. Maybe it works better on th mac OS)
saranyc Posted June 25, 2007 Author Posted June 25, 2007 Thanks everyone, I do have 8.5. I am just getting started today, but will try the container thing and the webviewer. Hey if the webviewer works, would it maybe be possible to scrape the contents of the pdf- so you could search the text of the doc? Is this possible any other way? The docs are contracts and I'd like to avoid using keywords in fields- I thought maybe I could somehow search the pdfs themselves...Ideas? I know this is in the wrong place, but it is related to my earlier question (kindof)... thanks! sara
mr_vodka Posted June 25, 2007 Posted June 25, 2007 I dont think that you would be able to scrape the text from the webviewer for a PDF because it will not return the text in a HTML or XML format. Instead you will need to extract the text out of the PDF using a plugin. See HERE
Fenton Posted June 25, 2007 Posted June 25, 2007 (edited) Since we're in the AppleScript forum, there is a way to do this with a free open source command line tool, pdftotext. It is not perhaps as user-friendly as a plug-in (nor cross-platform), but it is not bad. I depends on the PDF whether you get nicely blocked text, or whether it all runs together. But you certainly get searchable text. I had a little trouble getting the "man" page to be accessible. So once I did, I saved it as html and included with the example. I'm am not a Unix geek, by any means, but somehow manage. There's also an example AppleScript. The "real" AppleScript is in a Perform AppleScript step in the FileMaker file. There are 3 examples in the file, which you'd use depending one whether you just want to read some pdf file, whether you want to also Insert it, or whether you've already got it Inserted (embedded) and want to extract the text. This is all local files so far, but I imagine it would work on a remote file, if you specify the full path. It is fairly simple to convert a Mac path<->Unix path<->FileMaker path. But they are not the same. [Moved upgraded file to a later post.] Edited June 26, 2007 by Guest
saranyc Posted June 25, 2007 Author Posted June 25, 2007 thanks fenton, forgive my ignorance, but i can't seem to get the scripts in the attached file to work properly. The third one (reading a pdf already in a container field) would actually be great, but when I try to run it, i get a message that the file cannot be created in that location, and then the applescript fails. I do have hopes for this pdftotext thing though because it is reading existing pdfs from my desktop really well. Any suggestions? Is the file you attached meant to work with a mac? I don't quite understand what I need to convert (Mac path<->Unix path<->FileMaker path....) I tried to change the field defs to exp to a folder on my desktop, but that didn't work either... please advise!
Fenton Posted June 25, 2007 Posted June 25, 2007 It's a FileMaker error. And I'm not quite sure why it happens. The file path is valid. I tried it once, got an error. I thought "What the heck!". I opened the TemporaryItems folder (4th script will do that). Nothing there. I tried the script again. It worked. So, I can only guess that FileMaker for some reason does not think it can write to the folder, but then decides that it can. Try it again. It is definitely written for a Mac. As far as filepaths, I've already done the conversions needed. I was just trying to say that they can be converted back and forth. If you can't get FileMaker to write to the temporary items folder, there is another option. Which is to just write the file to the Desktop, then either remove (command line "rm") or delete (AppleScript) it. The former deletes the file immediately, the latter just puts it in the trash. Either of which will work, but is not as slick as the temporary items folder. Let me know.
saranyc Posted June 26, 2007 Author Posted June 26, 2007 Hi again, Been struggling with this all day! I can't get FM to write to my desktop either- it says the file needs to be renamed or unlocked or saved elsewhere. I tried renaming it, but that didn't work either. The other scripts are malfunctioning as well. The second one says "object not found" and gives me another error message (-1006?) when i select a file, but then inserts the file name, and leaves the container field blank. Then it prompts me to select a file again, which it does insert in the container field. For some reason, the File_Path_Mac field is not populating, which I'm guessing is another major source of the problem... Thoughts? Thanks, Sara
Fenton Posted June 26, 2007 Posted June 26, 2007 (edited) Good catch on File_Path_Mac. I'd added the "_Mac" to the FileMaker field, but forgot to rename it in the AppleScript; always a problem with "hard-coded" languages. But I still don't know why can't Export. Try it without using any script. Just use Export Field Contents. [moved file again, to next post] Edited June 26, 2007 by Guest
Fenton Posted June 26, 2007 Posted June 26, 2007 Ah ha! I just ran into a message on another list, where I was also talking about this. Bear in mind that the mac path here will fail if it isn't running under the very first user account created on the Mac. the '501' in the path is the user id, and 501 is the one that gets created when you first set up your mac. If you add more users, they will each have their own folders (502, 503, 504, etc...) and they won't be able to write to (or read from) the 501 folder. Could this be your problem with the "temporary items folder"? To find out run the following AppleScript: path to temporary items as text I original used this and set it into a global field. Then I didn't think that was necessary, and removed it; apparently it is needed. Or, as I said earlier, if the Temp path is going to be so much trouble, we could just write to the Desktop, then remove the file. This example file has that, as the last script. PDFtoText.zip
saranyc Posted June 27, 2007 Author Posted June 27, 2007 Thanks so much for your help- we've finally got this working- almost. It seems that the pdftotext shell script will only translate those docs which were created electronically, and then saved as pdfs, versus scanned docs. I wonder if this is the case for all such programs... If we do find one that will read our (mostly) scanned contracts, this script will work beautifully- the thought of using keyword fields to search in thousands of contracts is devastating! Thanks again. I'll be searching for software now- if you happen to know of a different one we might try, please let me know!!! Take Care, Sara
saranyc Posted June 27, 2007 Author Posted June 27, 2007 UGH! I realize that our scans are all JPGS! Is there any possible way you know of an OCR program from which we could take the executable file (like you did before) and just replace the do shell script line? I know that is unlikely, but I thought I'd ask! Thanks, Sara
Fenton Posted June 27, 2007 Posted June 27, 2007 A PDF created from text, using post script (or whatever exactly they use) is entirely different from a bit-map picture. As you say, only an OCR program can try to read and interpret "text" in what is basically just a picture. I know next to nothing about OCR, not being a "paper" kind of guy :-] Also, JPEG is a not a good format for images with lines, which is what bit-map text is. PNG is much better. TIFF is good, but can create large files. PDF is good also. But I guess it's a little late to point this out now -|
Recommended Posts
This topic is 6360 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now