11 Replies Latest reply on Jul 16, 2013 9:30 AM by philmodjunk

    Save as PDF

    Kirk_1

      Title

      Save as PDF

      Post

           I have a batch job that saves 30- 40 reports in a pdf.

           It works perfectly except for one report for the same customer.

           It saves that as a ".dat" file.

           Why?

        • 1. Re: Save as PDF
          schamblee

               Are you using a MAC or PC , what operating system and version, what filemaker version ?  Could be a bug in your script so it would be helpful if you would post your script that you are using to create the pdf. 

          • 2. Re: Save as PDF
            philmodjunk

                 You might want to post your script so we can see the details of how your script produces those PDFs. It sounds like you have a Save As PDF script step that is incorrectly assigning a file name extension to the PDF that it creates.

                 To post a script to the forum:

                   
            1.           You can upload a screen shot of your script by using the Upload an Image controls located just below Post A Answer.
            2.      
            3.           You can print a script to a PDF, open the PDF and then select and copy the script as text from the opened PDF to your clipboard for pasting here. (with this approach, you can get multiple script steps on the same line, please edit the pasted text by inserting some returns to separate those steps.)
            4.      
            5.           If You have FileMaker Advanced, you can generate a database design report and copy the script as text from there.
            6.      
            7.           If you paste a text form of the script, you can use the Script Pretty box in the Known Bugs List database to paste a version that is single spaced and indented for a more professional and easier to read format.
            • 3. Re: Save as PDF
              Kirk_1

                   Here it is, but how could correctly assign 39 but not the 40th?

                   using pc, windows 7 and filemaker 12

                     
              •            
              •      
              •           Set Variable [ $CustID; Value:Intouch::IT_FKCustomer ]
              •      
              •           Go to Layout [ “Customer” (Customer) ]
              •      
              •           Enter Find Mode [ ]
              •      
              •           Set Field [ Customer::CS__PKCustomerID; $CustID ]
              •      
              •           Perform Find [ ]
              •      
              •           Set Variable [ $email; Value:Customer::CSPrimaryEmail ]
              •      
              •           Set Variable [ $secondaryEmail; Value:Customer::CSSecondaryEmail ]
              •      
              •           Go to Layout [ “Shipment Status” (Invoice) ]
              •      
              •           Set Field [ Invoice::INCustomerId; $CustID ]
              •      
              •           // Set Field [ Invoice::INShipmentDeliveryDate; Let ( [ ~dt = Get ( CurrentDate )-1 ; ~dow = DayOfWeek ( ~dt ) ] ; ~dt & "…" & Case ( ~dow = 5 or ~dow = 6 ; ~dt - 5 ; ~dt - 3 ) ) ]
              •      
              •           Set Field [ Invoice::INShipmentDeliveryDate; Let ( [ ~dt = Get ( CurrentDate ); ~dow = DayOfWeek ( ~dt ) ] ; Case ( ~dow = 5 or ~dow = 6 ; ~dt - 6 ; ~dt - 4 ) & "…" & ~dt ) ]
              •      
              •           New Record/Request
              •      
              •           Set Field [ Invoice::INShipmentDeliveryDate; "=" ]
              •      
              •           Set Field [ Invoice::INCustomerId; $CustID ]
              •      
              •           Perform Find [ ]
              •      
              •           Sort Records [ Keep records in sorted order; Specified Sort Order: Invoice::INCustomerName; ascending Invoice::IN__PKFlgsiProNumber; ascending ] [ Restore; No dialog ]
              •      
              •           Show Custom Dialog [ Title: "Print or PDF"; Message: "Do you want to Print or Email this?"; Default Button: “Print”, Commit: “Yes”; Button 2: “Email”, Commit: “No” ]
              •      
              •           If [ Get (LastMessageChoice) = 1 ]
              •      
              •           Print [ ] [ No dialog ]
              •      
              •           Else
              •      
              •           Set Variable [ $path; Value:Get ( DesktopPath ) & Invoice::INCustomerName & "_" & Filter ( GetAsText ( Get ( CurrentDate ) ) ; "0123456789" ) & ".pdf" ]
              •      
              •           // Set Variable [ $email; Value:Customer Invoice::CSPrimaryEmail & ";" & Customer Invoice::CSSecondaryEmail ]
              •      
              •           Save Records as PDF [ File Name: “$path”; Records being browsed ] [ Document - Compatibility: Acrobat 7 and later ] [ Pages - Number Pages From: 1; Include: All pages ] [ Security - Printing: High Resolution; Editing: Any except extracting pages; Enable copying; Enable Screen Reader ] [ Initial View - Show: Pages Panel and Page; Page Layout: Single Page; Magnification: 100% ] [ Restore; No dialog ]
              •      
              •           Send Mail [ Send via E-mail Client; To: $email & ";" & $secondaryEmail; Subject: "Daily Report"; Message: "Here's today's Shipment Status for " & Invoice::INCustomerName & ":"; Attachment: “$path” ]
              •      
              •           End If
              •      
              •           Go to Layout [ original layout ]
              • 4. Re: Save as PDF
                philmodjunk

                     A very good question as I cannot see any way that is possible from the script you have posted as your path variable specifically appends ".PDF" to the end of the file name.

                     Is the rest of the file name consistent with the computed file name that your are assigning to $Path? In other words, do they see a file name of

                     CustomerName_DateDigits.dat?

                • 5. Re: Save as PDF
                  Kirk_1

                       This is the value of $path

                       /C:/Users/Kirk/Desktop/DSM Canister
                       _7152013.pdf

                       As i go through with my debugger, i stopped the program, went to preview hit save as pdf... if i named it my customers name, it saves it as a .dat file.

                       If i do the same thing and save it as a "untitled" it saves it as a pdf.

                       To add fuel to the fire.... it does it on my employees computers... She is in a different location 130 miles away.

                  • 6. Re: Save as PDF
                    philmodjunk
                         

                              This is the value of $path

                         Yes, but when you examine the filename of the actual PDF, what do you see? Do you see the _DateDIgits part of your computed path as part of the filename? or just Customername.dat

                         

                              if i named it my customers name, it saves it as a .dat file.

                         How did you name it with your customer's name? As quoted text for from the customer name field?

                         If you create a small test file with just enough fields to compute this same filepath and save a PDF, do you get the same results?

                    • 7. Re: Save as PDF
                      Kirk_1

                           it never saves it as a pdf, its always .dat on my desktop...

                           As a .dat on my desktop, i can change it to a pdf

                           From my layout, if i use the pop up name of my customer (on the filemaker window save record as a pdf) it saves it as a .dat if i rename it it saves it as a pdf. This happens with or with out a script.

                      • 8. Re: Save as PDF
                        Kirk_1

                             update...

                             From my layout, if i use the pop up name of my customer (on the filemaker window save record as a pdf) it saves it as a .dat if i rename it it saves it as a pdf. This happens with or with out a script, even if ive selected save a a pdf.

                        • 9. Re: Save as PDF
                          philmodjunk
                               

                                    it never saves it as a pdf, its always .dat on my desktop...

                               Yes but is the rest of the file's name consistent with what you script is supposed to produce? I'm still trying to confirm whether the file's name includes the date digits or not.

                               From what you are describing, it sounds like there's an issue with the text in that customer name field for that one record. Am I correct that if you change the path calculation so that you use the customer's name in quotes instead of referring to the field, you get a correctly name PDF file?

                          • 10. Re: Save as PDF
                            Kirk_1

                                 Set Variable [ $path; Value:Get ( DesktopPath ) & Invoice::INCustomerName & "_" & Filter ( GetAsText ( Get ( CurrentDate ) ) ; "0123456789" ) & ".pdf" ]

                                 I Changed the set variable $ path from the above to the following, it  worked and  saved it as a pdf...

                                 [$path: Value:Get ( DesktopPath ) & "DSM Container" & "_" & Filter ( GetAsText ( Get ( CurrentDate ) ) ; "0123456789" ) & ".pdf"

                                 What do i need to change in my record on the customer layout to fix it? I tried to delete the name in the record and typed it in again. That did not work.

                                 My customer records have ID numbers in them and all of the invoices are tied to that id number.

                                 Can i delete the record, create a new one, then put the old ID number into the id field, or is there a better way?

                            • 11. Re: Save as PDF
                              philmodjunk

                                   Frankly, I'm not sure. Everything you've posted now points a finger at the actual text data in that field, but clearing and re-entering that text did not fix the issue. Deleting and recreating that record, as long as you have a back up incase you make an error re-entering the data seems worth a try, but I am now wondering if there is a chance that your file is damaged in some way.

                                   I'd expect there to be more problems than with just this one record if that were the case, but when you've ruled out the other possiblities. What remains however unlikely....

                                   Thus you may also want to run a recover on a copy fo this file and test the recovered copy--even if recover does not report any issues to see if that makes any difference here.

                                   Things to keep in mind about Recover:

                                   While Recover almost always detects and fully corrects any problems with your file...

                                     
                              1.           The recovered copy may behave differently even if recover reports "no problems found".
                              2.      
                              3.           Recover does not detect all problems
                              4.      
                              5.           Recover doesn't always fix all problems correctly
                              6.      
                              7.           Best Practice is to never put a recovered copy back into regular use or development. Instead, replace the damaged file with an undamaged back up copy if this is at all possible. You may have to save a clone of the back up copy and import all data from your recovered copy to get a working copy with the most up to date information possible.

                                    

                                   And here's a knowledgebase article that you may find useful: What to do when your file is corrupt (KB5421).