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

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

Recommended Posts

Posted

Hi All

We have a script in our system that generates a PDF which details records and their related details.

Originally this PDF layout was contained within our globals table - it showed, via a relationship based on global fields, the record we want to look at (the version) plus the related lines in portals (the edits), however there was an issue with this...

Sometimes the record we wanted to PDF had over 200 related edits and the portal option restricted us here to a fixed number of records. Also in order to take into consideration large amounts of text in the portal row we had to make the portal row so large that it looked a mess in most circumstances.

So the idea was to amend the report so that it was based on our edits table, display it as a list and use the relationships to show the rest of the version information in the header/footer. This way we can account for an unlimited number of related edits and also use sliding and printing to resize the field size dependant on the amount of text.

Problem here was.... there are some nasty, but necessary, unstored calcs in our edits table... When you went to print the report or save to PDF it started a never ending "find in progress" to the point that in the end our entire server crashed, kicking everyone out and rendering FileMaker unusable for a significant time... I'm pretty certain that this sort of activity should not really trigger this kind of reaction, but hey...

My last resort was to split the PDF report into 3 layouts - header, body and footer. The header and footer based on the globals table and the body based on a new hold table containing a few text fields - I import the related edits into this table on the fly when the report is run.

The script now does the following;

1. Goes to the header layout saves as pdf on users desktop

2. Goes to the body part, import the records for the report and append to the existing PDF

3. Finally goes to the footer part and appends the PDF to the end of the existing PDF and opens the PDF.

Running this through debugger it works fine.... Run it normally and most of the time I get the "The file filenamehere.pdf 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" message at the stage of appending the second PDF, or sometime the last.

I checked all of the other bits and pieces i.e. disk space, naming etc, however I couldn't find anything that could present this problem. So I decided that this was due to the file still being locked from the previous Save as PDF step...

So I added a Pause Script step and paused the script for 1 minute before executing the second and third PDF append...

However this has still not totally fixed the problem...

Anyone know of a sure fire way to either determine how long to wait before touching the file again OR to manually unlock the file via some other kind of scripting i.e. applescript and shell???????

HELP PLEASE THIS IS DRIVING ME NUTS!!!

Posted

Not really following why you needed to split this up. Unstored calcs only recalc when shown on a layout. If your report requires these fields, then you have a problem. However, you seem to have created a layout that has only the text fields that you need, so why didn't you do that from the beginning? In any case, the layout should be based on the child table, (which from your desc is called "edits").

As for the error message, that is usually a badly formed path problem. Use debugger to see exactly what the path is you're expecting Save As PDF to use. I typically use Get (TemporaryPath) & $filename where $filename is set just before the Save As PDF step. See this demo.

Posted

Do it as three separate PDF files, then use Scriptmaster with iText to concatenate the files rather than the append to file method?

OR more daring use iText to build the PDF completely. Means you can throw as many related items as you need at it and will be quite an order of magnitude faster. Grab the data in virtual lists and inject it into the function. Not a simple task, but have enough practice to know it absolutely works.

Are you using 11 or 12?

  • 2 weeks later...
Posted

bcooney

Normally I would agree with you about not splitting this up - however I have tried this, using as you suggest only the fields I need - simple number and text fields only. However when I went to print/PDF after finding the records it took forever and a day to print/PDF and in most instances crashed the users FileMaker and also managed to taker the entire server down on 2 occasions... I'm pretty certain this shouldn't happen but it did! I tried re-creating this layout from every possible angle, but could not make it work "properly"...

I know there's nothing at all wrong with the file paths - the append works fine if I run through the script in debugger, but normally fails at least on the first append as the PDF is still locked from creation... Sometimes it works with the 1 second pause, sometimes it doesn't...

john renfrew

I'm using fm11 - thanks for the idea. I'm going to go and have a stab at this now! You've also given me another idea... We are all on macs here in the office so I can run shell scripts via Applescripts - if I can find a free, simple to code command line tool to merge PDF's I can use this as another option and there might be less in the way of coding

Thanks to you both!!!

Posted

I'm puzzled wny you are getting this file locking problem.

I run a database from which I construct a Club directory. This involves the use of a number of different layouts to produce pages for the directory. Each time the current output is appended to the previous PDF; this happens about 20 times during a 'publishing' run. This works reliably on both PC and Mac FMP Clients, with the database hosted on an FMP10 Adv server.

Make sure that all of your save to PDF steps have the automatically open file option cleared, and I would recommend a commit records step and a refresh window step with flush join and external data options checked before outputting each section of the PDF.

HTH

Brian

Posted

brian rich

Thanks for your post. I totally agree - I have no idea either... I've worked with appending PDFs before and not encountered this issue...

Went back to this and tried adding a Refresh Window step, flushing external data, however I still experience the same problem intermittently.

john renfrew

You gave me the idea to use a command line PDF merger (indirectly :) ) and this worked beautifully till I explained to superiors that the command line utility would need to be installed on all machines and all new ones... They're not so keen on this one!

So the next plan is to go down the road you recommended as we already have a number of FileMaker plugins which all need to be installed on users machines anyway and this doesn't add to the job! However I need to get my head round Groovy first... :)

Posted

Are you hosting this file on FMS? I can't get past your statement that Save As PDF "brought down the server." I hope you're not using a fileserver, but rather hosting the file with FMS.

Posted

Yup using FileMaker Server... And I know it is a difficult statement to swallow as it doesn't really make sense...

I had implemented the changes to the PDF - making it a list view of our edits table with the other related data showing in the header and footer. Then the server went down. Then we rehosted the files, it went down again, and again...

There was one user waiting for the files to come back up, then running the PDF script - each time they did it they got the spinning wheel, then everyone else got the spinning wheel, then everyone was booted out and server went down...

Posted

My other sneaky workaround is out the window... Thought of this as I am required to generate the PDFs for 150 records in a batch so I've looped my original script for this purpose...

If the error code was 800 I was going to enter a loop to basically continually attempt to append until the error is 0 then exit the loop, however error 800 is un-supressable so that's a no-go.

Just sitting here OKing error messages as my script loops through now...

Posted

"3. Finally goes to the footer part and appends the PDF to the end of the existing PDF and opens the PDF."

You can't create a pdf with the same filename as an open pdf. I'm guessing it's an intermittent problem because sometimes the users closes the pdf.

You'll also get that error if the filename is invalid (contains spaces, commas, etc depending on the OS).

"When you went to print the report or save to PDF it started a never ending "find in progress" to the point that in the end our entire server crashed, kicking everyone out and rendering FileMaker unusable for a significant time"

This kind of crash can cause a corrpted (but still temporarily usable) file. You may want to check it with your Recovery options.

DJ

Posted

David Jondreau

Thanks for your response - correct - you cannot create a PDF with the same name as an open file. But my file IS NOT OPEN. I only open the file on the last save (append) which should not be a problem and in fact this works intermittently.

My filename is valid - as mentioned previously this problem is intermittent on the same save - first PDF saves fine, first append fails with error 800 and the last PDF appends successfully. This is all using the same file path saved on the same variable at the beginning of the script. If I run the script slowly through debugger I generally get no errors at all pointing to the fact that FileMaker is still locked in the PDF from creation when it comes round to append to the same file...

And yes the crashing I realise does point to corruption, however there's nowt I can really do about that apart from try to get my script to work using my workaround. I am in no position to rebuild the file and I know for a fact that in the past they have been recovered out of necessity and put back into production.

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

Any other ideas about the file locking and how to stop it?!? Or any way I can test to see if the file is locked?

  • 1 month later...
Posted

Eureka!

Ridiculously simple issue.... We all use networked accounts here - save and append PDFs to the network account and this error will pop up intermittently - I'm guessing because the server is busy backing up the newly created PDF at the same time that FileMaker is trying to append to it.... Or something like that anyway...

Amended script to save everything to the temporary folder (which is local) using Get ( TemporaryPath ) - it works sweet as a nut every time!

Thanks for your help everyone! Hurrah!!!!

  • Like 1

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