Jump to content

PCPF_SaveAsPDF (Full Path)


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

Recommended Posts

  • Newbies

I am populating a series of a application forms from the FM database and saving each one to a specified directory with each application form name appended with the name of the applicant (PCPF_SetPDFFieldValue( "VeteranName" ; Veterans::VeteranName )) along with their identification number (PCPF_SetPDFFieldValue( "pkID" ; Veterans::__pkVeteransID )).

My question is how does one use Set Field[ Main::Result ; PCPF_SaveAsPDF ( “Some other PDF file path” ) ] script step to save the file as a name based on the previous two field values.  For instance if VeteranName = John Doe and the pkID = 100 and the saved directory path is Macintosh HD/Users/Robert/Documents/Database how do you combine those attributes to create a Full Path File Name?  i.e I need the file to be stored as:

Macintosh HD/Users/Robert/Documents/Database/pk100 John Doe Application Form.pdf

Or is there a better way to do it?

Many thanks for your help

Duncan

Link to comment
Share on other sites

Hi adgilcan,

That's a pretty straight-forward question. You can use the values of the Veterans::VeteranName and Veterans::__pkVeteransID fields in the calculation for the file name / file path. For example:

Set Variable [ $filePath; Value: Get(DocumentsPath) & "Database/" & Veterans::__pkVeteransID & " " & Veterans::VeteranName & " Application Form.pdf" ]

This should create a variable called $filePath with a value of "/Macintosh HD/Users/Robert/Documents/Database/pk100 John Doe Application Form.pdf", assuming that the key parts are the same as the examples you've provided. You may need to trim off the leading / character at the start when passing it to PCPF_SaveAsPDF, as the function requires a properly-formatted system file path for saving the PDF.

 

Hope this helps!

CT

Link to comment
Share on other sites

  • Newbies

Hi

Thanks so much.  That could be very useful, indeed.  May I trouble you a little further, please?

How do I "trim" the leading / before passing it to PCPF_SaveAsPDF?  Also, if the actual storage directory is not in Documents but elsewhere (for instance /Users/adgilcan/Box Sync/PSRB&H4FA/Applications/Navy Applications), how is that entered into the filePath variable?

 

At present, using your suggestion, I am getting the Acrobat error dialogue:

The file may be read-only, or another user may have it open. Please save the document with a different name or in a different folder.

I am assuming that this is because of an error in the filePath variable?

Very many thanks

 

Duncan

Link to comment
Share on other sites

Hi Duncan,

You can use standard FileMaker text functions to trim the leading slash. In this case, you'd want to use the "Right" function to get the rightmost characters, and pass it the file path and the length of the file path minus 1 ("Right( $filePath ; Length( $filePath ) - 1 )"), that will give you the filepath without the first / character.

For other folders, you'd probably need to hard-code the file path and then append the dynamic file name. So you could do:

Set Variable [ $filePath; Value: "Macintosh HD/Users/adgilcan/Box Sync/PSRB&H4FA/Applications/Navy Applications/" & Veterans::__pkVeteransID & " " & Veterans::VeteranName & " Application Form.pdf" ]

You'd obviously need to make sure that the folders in the path actually exist, so that the system won't experience the error you're receiving. And in this second case with the example step above, you wouldn't need to remove the leading / because there is none to remove.

 

Hope this helps!

CT

Link to comment
Share on other sites

  • Newbies

That is great, thank you.

I am sure both of those would work very well.  Unfortunately I am still getting the error: The file may be read-only, or another user may have it open. Please save the document with a different name or in a different folder.

I am pretty sure this is nothing to do with Filemaker but it is preventing me from saving via the script step.  I can manually save each file but this is pretty tedious and not really practical in the long run.  I know there are problems when files are stored in synced folders, such as Dropbox or Box but I am getting the same problem when attempting to save to my Documents folder.

Do you have any ideas here, or do I need to dig elsewhere?

So many thanks

 

Duncan

 

 

Link to comment
Share on other sites

Hi Duncan,

You might want to check to see if the file permissions on the PDF document allow your user account to make modifications to the file. We've seen situations where a file downloaded to a Mac does not receive the proper file permissions. If this machine was a Windows machine, I'd suspect that another process is trying to use the file at the same time, but based on your file paths, that doesn't seem to be the case here. If you can, try making a copy of the file and reference that file. Also, make sure you're following the standard PDF Manipulator workflow to open the file with PCPF_OpenPDF before calling PCPF_SaveAsPDF.

Thanks!

CT

Link to comment
Share on other sites

  • Newbies

Thanks CT

I've run out of time for the next day or two but I'll do as you suggest and report back.

 

Thanks again for all the help thus far.

 

Duncan

Yahooo!!!!!

Just before I signed off I thought I'd take a look at the PCPF demo file.  I saw there that the file path is prefixed /Volumes   i.e /Volumes/Macintosh HD/.........

This change allows me to save the files in both my Documents and Box Sync directory.

Thank you so very much for sticking with me to sort this out.  I very much appreciate it!

 

Duncan

Link to comment
Share on other sites

This topic is 2016 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
×
×
  • Create New...

Important Information

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