Jump to content

Opening a file from a layout in its native App. (Opening a .pdf)


This topic is 2316 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Hi All,

I have a container field holding a pdf  and would like to run a script upon a button click that opens it in its native program or app. in this case Adobe Reader.

Can anyone help with writing a script for this? I am lost and very new to FMPro.

Cheers

Simon

Link to comment
Share on other sites

Simple way is to export to temporary path.

Here's one I use to take a letter sent to a customer, saved in a container, for viewing or printing.  These are the basic steps:
 

Set Variable [$path; Value: Get(TemporaryPath) & "Letter_" & Customers::Name_last & ".pdf"]
Export Field Contents [Customer_contact::Letter; "$path.pdf"; Automatically open]

edit:  corrected typo

Edited by Steve Martino
corrected typo in script
Link to comment
Share on other sites

Here is the script that I created using your example.

 

Set Variable [ $path; Value:Get(TemporaryPath) & "Order_" & GeneralAccounts::GeneralAccName & ".pdf" ]
Export Field Contents [ PSWorkflow::PSWF_OrderPDF; “file:File[$path].pdf”; Automatically open ]

Unfortunateley the script will only let me place “file:File[$path].pdf” in double speech marks and not just the one at the start of it as your script indicates. I think therefore my script will only name the file File[$path].pdf and not "Order_" & GeneralAccounts::GeneralAccName & ".pdf" .

Any thoughts?

Link to comment
Share on other sites

I copied that line from the script (has the quotes).  But when I look in  Specify Output File dialog, it looks like this:

file:$path.pdf

PS  I cant get your "like this" button to open, throws an error.

 

pdfSS.png

Edited by Steve Martino
Link to comment
Share on other sites

Agree with webko.

Set Error Capture [ On ]
Set Variable [ $filename; Value:ExportPDF::BaseFileName & ".pdf" ]
Set Variable [ $path; Value:Get( DesktopPath) & $filename ]
Export Field Contents [ ExportPDF::PDFContainer; “$path”; Automatically open ]
Set Variable [ $error; Value:Get( LastError) ]
Set Field [ ExportPDF::ExportResult; $error ]
Commit Records/Requests 

script.png

ExportPDF.fmp12

And if earlier suggestions DID work, you would end up with a file name myFileName.pdf.pdf

Link to comment
Share on other sites

On 19 February, 2016 at 0:50 AM, MutantST said:

I have a container field holding a pdf  and would like to run a script upon a button click that opens it in its native program or app. in this case Adobe Reader.

FYI: I would use FireFox or Chromium as PDF-viewer

Edited by ggt667
Link to comment
Share on other sites

55 minutes ago, comment said:

You are using the same container field being exported to name the exported file. See: http://www.filemaker.com/help/14/fmp/en/html/func_ref1.32.239.html#1075526

Yeah, that is what I am going for.

1 hour ago, webko said:

My guess is because it is an external stored Container field.

So it looks like I have to have the file stored internally to remove the remote part. Oh well, suppose
I can put up with that.

Will this script work if I use a different file type? say a word doc?

Link to comment
Share on other sites

Do this google search 

site:fmforums.com Extracting Filename from Container link

The file "Extracting Filename from Container link” was  posted in Feb 2010 and is very helpful for see the file paths, In addition, there were several other hits that many also come in handy.

Lee

Link to comment
Share on other sites

"Not sure how to do this :/"

Then - for test purposes anyway - just create a new, plain text field and enter text into it and use THAT for your export/open script.

Link to comment
Share on other sites

This topic is 2316 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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.