Jump to content
Salesforce and other SMB Solutions are coming soon. ×

save to PDF with field name as filename


flybriguy
 Share

Recommended Posts

Can anyone here post an exact script step for saving to pdf with field name as filename? I think it can be done by setting the filename as a variable, but I'm only a novice and can't figure this one out.

 

 

-brian

Link to comment
Share on other sites

Hi Brian,

 

I'm not a Mac guy so I could really lead you astray if I tried to answer this. I will however suggest that you take a look at the topic called "Creating file paths" in Filemaker help. This page really helped me understand what is going on.

Link to comment
Share on other sites

Hi Brian

You are on the right track using a variable.

 

First you set a variable (say $filename) with the Set Variable script step:

 

Set Variable[$filename; Value:tablename::fieldname & ".PDF"]

 

Then you use the Save Records as PDF script step:

 

1. Turn on the option to "Perform without dialog"

2. Specify an output file such as filemac:/Macintosh HD/PDF/$filename or filewin:/C:/PDF/$filename

3. Specify options for either Current record or Records being browsed

 

As long as the spcified path exists, it whould work. Works for me! :cool:

Link to comment
Share on other sites

Thanks David,

 

 

hmmm, seems to not work I get an error message:

"Documents" could not be created on this disk. Use a different name, make more room on the disk, unlock it or use a different disk.

 

My Path is as follows:

 

file:/Macintosh HD/Documents

 

Here is my Script exactly as follows:

 

Set Variable [$filename; Value:INVOICES TO:: id invoice & ".pdf"]

Save Records as PDF [Restore; No dialog; "Documents"; Current Record]

 

 

fyi I tried running the script without the save records script and it just automatically saved it in it's default state (I'm assuming) on the desktop as "untitled.pdf"

 

 

-brian

Link to comment
Share on other sites

oops . . . . I didn't realize I needed to add $filename after Documents.

 

 

works totally fine now!

 

* here is the correction for those other novices reading this:

 

file:/Macintosh HD/Documents/$filename

 

 

** it's hard to decipher scripting steps (as I've also seen elsewhere) with all it's symbols and nomenclature . . . if what is written should be taken exactly literally or just assumed, etc.

Link to comment
Share on other sites

  • 1 year later...

David,

 

Thanks for all the helpful responses on FM Cafe, your tips have been great!

 

I am still struggling with this particular issue of naming my "save as PDF" to a unique variable.

 

My goal is to have my file names automatically saved as the 'CURRENT DATE'.PDF, as in 11/14/2007.pdf

 

I've tried every approach including the exact instructions on this thread, but still get the error: "cannot save on disc," etc.... I suspect my filepath is incorrect but i have NO IDEA why.

 

Here is my script:

 

Set variable [&census; Value: Get(current date) & ".PDF]

Save Record as PDF [Restore; No Dialogue; "$census"; Records being browsed]

 

My filepath:

 

filemac:/Macintosh HD/Users/Chris/Documents/$census

 

 

Do you have any ideas?

 

Thanks,

Chris

Link to comment
Share on other sites

Ted,

 

Yeah, just a typo- it is actually "$census"

 

Anyone with thoughts on how to do this? I've been working on it without resolution. Came close though:

 

I got this message:

 

"2007.PDF" cannot be saved on this disc....etc

 

1) Why is the Get (date) only pulling in the year? Shouldn't it be the full date (month/day/year)

 

2) The file path issue is driving me crazy!!! I am entering exactly what my file path onto my desktop is, and it seems to insist that it can't do it!!!

 

I know it is something simple i am missing....

Link to comment
Share on other sites

You can't put the "/" in a date into a path--the system thinks those are deeper folders in the path.

 

You have to change the "/" in the date to something else, like "-" in a calc field moddate=substitute(date;"/";"-") result text.

 

--Doug

Link to comment
Share on other sites

  • 1 month later...
You can't put the "/" in a date into a path--the system thinks those are deeper folders in the path.

 

You have to change the "/" in the date to something else, like "-" in a calc field moddate=substitute(date;"/";"-") result text.

 

--Doug

I would set another variable like this:

$path; Get ( DesktopPath ) & "/InsertFolderNamehere"

 

So your finale path would be File:$path/$filename

 

As for the date, you could do something like

 

Day(Get ( CurrentDate )) & "-" & Month(Get ( CurrentDate )) & "-" & Year(Get ( CurrentDate ))

 

This would allow you to control what order they are in, day, month or year, and if you don't want dashs, you could eliminate them from the calculation.

Link to comment
Share on other sites

  • 6 months later...

okay, this was so cool reading this thread. I am a novice, but learning and having fun! I made it work for windows OS, so my question is this:

 

How can we check for which OS when we go to save? that way, this script will work, and error check for windows or mac, making it pretty doggone cool"!!

 

thanks to those who've posted before me, and if I missed another link that explains this, my apologies in advance!

 

smiley-laughing

Link to comment
Share on other sites

Abs(Get(SystemPlatform))

 

returns 1 for Macs

returns 2 for Windows PCs

 

 

Historical stuff — why the Abs () part: the original platform was the 'classic' Mac platform. That was "1". Windows, which meant Windows 3.11 for Workgroups and then Windows 95, was "2". When Windows NT came along, it was really a different architecture than the Windows 3.x/95 (and eventually Windows 98 and ME) were, so NT was given the platform value of "-2", so you could trap for either Windows platform using Abs(Get(SystemPlatform)) but still differentiate between Windows NT (and 2000 and XP) as -2 and the other older Windows architecture by using 2.

 

Then of course along came MacOS X and it became platform -1.

 

After awhile someone noticed that no version of FileMaker since version 6 would run under MacOS 9 (8, 7, etc, the old classic Mac platform), so all Macs that could possibly be running the current version of FileMaker were OS X; and coming out were the new Intel Macs. So I think they repurposed platform 1 to mean MacOS X on PowerPC, leaving MacOS X on Intel to have -1 unto itself.

 

It's been awhile also since anyone was running modern FileMaker versions on anything in the Windows 98/ME PC platform, either, but unless I missed the announcement, NT and 2000 and XP and now Vista are still -2

 

What seems consistent is that Macs are Abs(Get(SystemPlatform)) = 1 and Windows PCs are Abs(Get(SystemPlatform)) = 2

Link to comment
Share on other sites

Thanks so much for posting this informative explanation!

 

so, not being a code person, what is the correct syntax for:

 

If the platform is MAC, then run this script, else,

if the platform is PC then run this script instead.

 

Logic I can mostly write, but the translation to code gives me the blues! smiley-cry

 

thanks again for your efforts, which are much appreciated!

 

smiley-laughing

Link to comment
Share on other sites

Also, in terms of saving to a safe place, for both windows and mac, what is a literal file path that will guaranteed the script will save the pdf to someplace that will always exist, whether or not a pc person has a C drive or a mac person has a Macintosh HD?

 

filemac:/Macintosh HD/PDF/$pdfname

 

filewin:/c:/PDF/$pdfname

 

neither of which exist for sure on everyones computer....

 

thoughts?

Link to comment
Share on other sites

What is the correct syntax for:

If the platform is MAC, then run this script, else,

if the platform is PC then run this script instead.

 

 

If [Abs(Get(SystemPlatform)) = 1

... Perform Script "Mac Script"

Else If [Abs(Get(SystemPlatform)) = 2

... Perform Script "Win Script"

End If

 

 

If it were me I would not have separate scripts but would just diverge behavior right here in the current script, but that's just a matter of taste and preference. It would certainly work to have separate scripts.

 

what is a literal file path that will guaranteed the script will save the pdf to someplace that will always exist, whether or not a pc person has a C drive or a mac person has a Macintosh HD?

 

 

Instead of a literal path, use:

 

Get(DocumentsPath) or

Get(DesktopPath)

 

You are entirely correct that not every Mac user's hard disk is named "Macintosh HD" (mine is not), and the Windows boot drive is not always C either. But everyone has a Desktop and everyone generally has a ["My "] Documents folder.

 

Assemble your path as a variable first, like so:

 

Set Variable [$Path, Get(DocumentsPath) & "/"&$pdfname

 

Export Records as PDF [$Path]

Link to comment
Share on other sites

okay, so something isn't working when I try to use the getdesktop path.

 

here is the script, as exported to a PDF, then cut and pasted. couldn't seem to find a way to copy and paste! (am I missing something - version 9 advanced)? I see that the pdf export is a bit more detailed.

 

where is it going wrong? suggestions? Oh Really!

-------------------------------

 

Set Variable [ $pdfname; Value:VFX Shots::save as pdf name ]

Copy [ VFX Shots::VFX ID ]

[ Select ]

Go to Layout [ “LINEUP SHEET FOR PRINT from SCANS” (Scans) ]

Enter Find Mode [ ]

Go to Field [ Scans::VFX ID ]

[ Select/perform ]

Paste [ Scans::VFX ID ]

[ Select ]

Perform Find [ ]

Enter Browse Mode

Set Variable [ $path; Value:Get(DesktopPath) & "/"& $pdfname ]

If [ Calculations::OS Check = 2 ]

Save Records as PDF [ File Name: “$path”; Records being browsed ]

[ Document - Title: VFX Shots::VFX ID; Subject: PROJECT INFORMATION::Project Name; Author: "Ryan R. Moos"; Compatibility: Acrobat

5 and later ]

[ Pages - Number Pages From: 1; Include: All pages ]

[ Security - Password to print/edit; Printing: High Resolution; Editing: Not Permitted; Enable Screen Reader ]

[ Initial View - Show: Pages Panel and Page; Page Layout: Single Page; Magnification: 100% ]

[ Restore; No dialog ]

Else If [ Calculations::OS Check = 1 ]

Save Records as PDF [ File Name: “$path”; Records being browsed ]

[ Document - Title: VFX Shots::VFX ID; Subject: PROJECT INFORMATION::Project Name; Author: "Ryan R. Moos"; Compatibility: Acrobat

5 and later ]

[ Pages - Number Pages From: 1; Include: All pages ]

[ Security - Password to print/edit; Printing: High Resolution; Editing: Not Permitted; Enable Screen Reader ]

[ Initial View - Show: Pages Panel and Page; Page Layout: Single Page; Magnification: 100% ]

[ Restore; No dialog ]

End If

Go to Layout [ original layout ]

-------------------------

Link to comment
Share on other sites

I see you are using a field OS Check.

 

Calc field? Is the storage of OS Check set to "do not store, calculate as needed"? Otherwise it will store a value at rec creation time and not notice when someone else logs on on the other platform.

 

I usually just make the assessment right there in the script, not in a calcfield.

 

 

PS: I am missing whatever you're telling Macs to do that's not identical to what you're telling PCs to do. What's the difference in behavior?

 

PS: I just remembered.... PCs are different! You need to adjust the $path if you're on a PC, they "think different" (ahem)

 

Add this clause after you' have set $Path:

 

If [Abs(Get(SystemPlatform)) = 2]

.. Set Variable [$Path, "filewin:/"&Middle($Path; 2; Length($Path))]

End If

 

For some reason FileMaker on Windows really wants that "filewin" formulation to save PDFs properly on a Windows PC.

Link to comment
Share on other sites

AHunter,

 

I would like to perform all of my calculations in a script so that I don't have to create fields in a table. Being that I am a novice, I haven't yet figured out how to do this....

 

I'll check the calculation, but it does return a 2 correctly right now. yet, still I don't get an export to the desktop.

 

It DOES export if I make an explicit file path, which can only mean something in my path name isn't right...

 

thoughts? sorry for the basic nature of my questions!

Link to comment
Share on other sites

this is the result of Get(DesktopPath)

 

/C:/Documents and Settings/Ryan R Moos/Desktop/TE120_224.pdf

 

it leads with a / which is incorrect. that must be why its not making it right?

 

or, perhaps something else?

Link to comment
Share on other sites

Hah! I went back and looked and I didn't remember seeing that! I thought I had overlooked something! so I've given it a try, and its successful on the pc, so i just have to try it on a mac!

Link to comment
Share on other sites

You could also use...

 

Case ( Abs ( Get ( SystemPlatform ) ) = 1 ; "filemac:" ; "filewin:" ) & Get ( DesktopPath )

 

HTH

Chris Cain

Extensitech, Inc.

Link to comment
Share on other sites

  • 2 years later...

sorry to be a dolt, I'm just not getting the variable to appear as the filename for the pdf

the database is named "courses test set 6-16"

the field name i'd like to appear as the pdf filename is "number"

 

the value of the field named "number" is currently "605"

 

so my desired result would be a pdf file named "605.pdf"

 

I've set a variable $filename with this value "courses test set 6-16::number"

 

I've set the save records as pdf as "$filename.pdf"; records being browsed

 

and the result is a file named $filename.pdf

 

what am I doing wrong?

Link to comment
Share on other sites

I've set a variable $filename with this value "courses test set 6-16::number"

 

Assuming your table occurrence is actually named "courses test set 6-16" (a bad idea, with that minus sign in there!!!!!), this is correct so far.

 

I've set the save records as pdf as "$filename.pdf"

 

Get those quotation marks out of there! You want the name to be the contents of the $Variable not "$filename.pdf". When you put quotation marks around something, it gets treated as a literal text string.

 

and the result is a file named $filename.pdf

 

Yep, sure would be.

Link to comment
Share on other sites

Thanks for your reply, filemaker itself adds the quotes around "$filename"

 

when i am in the "specify output file" dialog, and click the "add file" button, then navigate to the folder "filemakerpdftests" there is a blank space next to the words "save as" and thats where i type $filename

 

If i don't type $filename, and leave it as "untitled", then i get "untitled" as the name of the file when I run the script.

 

If i try to type the path in manually, I get the "filemaker cannot create" message

 

I did change the name of the database to "courses test set 617" and got rid of the "-" from the name as you suggested.

 

what else might i be doing wrong?

I appreciate your help

Link to comment
Share on other sites

  • 10 years later...

Hello all,

I need your help debugging a script I created.(Filemaker Pro 11) The premise of the script is create an unique folder with a sub-folder on my "c:" drive and save the current record as a pdf in the sub-folder and save the current record as a pdf. The maybe multiple unique pdf's records being saved to the same sub-folder. I also need the script to over write any existing pdf file with a new one if the pdf file name is the same in the same sub-folder.

 

Below are the field names included in the script and their definitions:

Main::AA File Path (Text Calculation)= "Dynatect/T&M's/" & Main::AA Product Code & "/PDF/" & Main::AA Quote No & "/" & Main::AA Quote No & "-" & If(Main::AA Quote Rev="";"";Main::AA Quote Rev & "-") & Main::AA Quote Line No & ".pdf"

Main::AA Quote No (Text Field)

Main::AA Quote Rev (Text Field)

Main::AA Quote Line No (Number Field)

 

The dreaded script structure that is giving me problems:

V 

When I run the script, I'm getting the following error:

F 

The premise of this script and what I need it to do:

New Folder/Record:

1. Create a new folder & sub-folder based on the field above "Main:: File Path" when it's brand new record.

2. Save the current record only as a pdf into the subfolder. If I have multiple records with the same "Main::AA Quote No" & "Main::AA Quote Rev" but a unique "Main::AA Quote Line No", I need these records to saved in the same sub-folder. 

3. Open the current pdf in my adobe pdf viewer and bring the pdf to the top for viewing (for proofing purpose).

Existing Folder/Record:

1. If the folder & sub-folder already exist, I would just like to over ride the existing pdf file within the existing folder and sub-folder with the updated/current pdf record.

2. Open the pdf in my adobe pdf viewer and bring the pdf to the top for viewing (for proofing purpose).

 

Based on the script steps above, it currently/does create the folder & sub-folder but not the pdf file with in the sub-folder. There are no container fields

on the layout to deal with, only a couple calculated text fields. Below a couple of screen shots:

pdf file layout example:

1Folder path example:

2 

Sub-Folder Path with pdf file example:

 3 

I hope I explained this enough for what I need. If I'm setting this up wrong or if there is a better way of doing this, I'm open to other options.

Thanks,

Tracy

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share



×
×
  • Create New...

Important Information

Terms of Use