Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

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

Recommended Posts

Posted

Hey folks,

I've got a script set up which is generating a PDF of an invoice using a particular layout. It generates itself fine, and i've not specified an output file so that the user is asked where to save the file, and what to name it.

This is also working brilliantly, with one exception; the generated file doesn't have '.pdf' as an extension. This isn't an issue on OSX (because OSX looks at the file to determine what to use to open it), but on Windows machines, these PDFs aren't readable because Windows still handles filetypes stupidly.

I don't really want to force users to have a particular folder set up somewhere on their machine where generated PDFs would sit; partly so that I can try to keep some semblance of cross-platform compatability, but mostly because everybody that uses this database has their own workflow - they save their stuff in different places, and call their generated invoices different things, and I don't want to interfere with that.

So, TL:DR - is there a way of forcing the 'Save Records as PDF' script step to append .pdf to a generated file on OSX?

Running FM9 Pro Advanced. For what it's worth, if I Print the records, the users can use Apple's built-in 'Save as PDF' printer function to generate their PDFs; this isn't ideal, as i've no idea how to specify things like the PDF title or author. It does, however, append a .pdf extension to generated files.

Another side note: it turns out that while Apple's PDF generator can handle both RGB and CMYK colourspace images within filemaker (and filemaker itself can display RGB and CMYK images), FileMaker's built-in 'Save Records as PDF' script step can only handle RGB images. Is that intentional?

Thanks,

Loki.

EDIT: I've been playing around with specifying the output path as well, i'm trying to create something which will effectively spit out filemac:~/Desktop/Invoices::Invoice ID.pdf, but it doesn't seem to be working properly. It says that it cannot create the file on that drive; in the past, it's done this because i've tried to save a file into a folder which doesn't exist. What string should I use to save this PDF to the user's desktop?

I'm currently using a variable with a value of:

"~/Desktop/Information for your Event: " & Sales Orders::Event Name & "Reference: " & Sales Orders::Invoice ID & Sales Orders::Invoice Version & ".pdf"

But this is generating the 'could not create' error detailed above.

Posted

Your path is invalid, you cannot use "~" at the start of the path. The syntax is:

filemac:/volumeName/directoryName/fileName

There is nothing wrong with forcing the .PDF extension.

Posted

The issue with that syntax is that I don't know the user's shortname, which is the name of their home directory, which is where their Desktop folder is. I wanted to be able to put a PDF straight onto somebody's desktop, hence the use of the home directory tilde.

I've just tested again - using 'save records as' and allowing the user to specify the PDF's filename, the .pdf extension isn't created on OSX.

Posted

The issue with that syntax is that I don't know the user's shortname, which is the name of their home directory, which is where their Desktop folder is.

Use the Get (DesktopPath) function.

allowing the user to specify the PDF's filename, the .pdf extension isn't created on OSX.

It depends on whether they specified the filename with the extension or without. Note also that OS X allow you to hide the extension even if it does exist.

Posted

Note also that OS X allow you to hide the extension even if it does exist.

I thought it might be OSX playing silly buggers, so I moved the PDF across to a Windows machine, and it definitely had no extension at all.

I'm going to play with Get (DesktopPath) - I think that might be the best fix for this - thanks very much! I'll mark this thread as solved when I have a working file path.

Posted

I'm having some trouble getting this step to work. It's compounded by the fact that OSX very helpfully doesn't show me what the invalid path was, or what a valid path is. All i'm told is that the file 'could not be created on the system disk. Use a different name, make more room on the disk, unlock it or use a different disk.' There is definitely space on the disk, and the users are able to write to their own desktop.

Currently, the relevant part of my script is:

Set Variable: $Desktoppath; Value: Get (DesktopPath)

Set Variable: $filepath; Value: $Desktoppath & "Information for your invoice: " & Sales Orders::Event Name & "Reference: " & Sales Orders::Invoice ID & Sales Orders::InvoiceVersion & ".pdf"

Save Records as PDF (in this step, I specify the output file as filemac:$filepath)

I'm not sure where i'm going wrong, and I don't really want to spend days and days trying to work out the correct syntax; can anybody tell me what I need to change, or a more efficient way of doing this?

Posted

Unbelievably you picked the one, and only, invalid character in the Mac OS X file name system, the ":" (colon) character. This is used as a path separator in Mac OS X (incidentally, it's not a wise choice in Windows either). I suggest the hyphen character "-" to replace with.

"Information for your invoice: "

"Reference: "

As you said

"Use a different name, make more room on the disk, unlock it or use a different disk.' There is definitely space on the disk, and the users are able to write to their own desktop." - you stopped eliminating problems having only tried 2 of the 3 possibilities.

Other than this I can see nothing wrong.

Posted

Fixed it in one - thanks! I'll mark this thread as solved.

I also found out that you can use Get (Desktoppath) as a part of a calculation, you don't have to assign its value to a variable in order to use it.

EDIT: Can't mark as solved. Oh well.

This topic is 4842 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.