12 Replies Latest reply on Aug 28, 2013 4:01 PM by mperley

    Saving a PDF to a Container Field

    DrDave

      Title

      Saving a PDF to a Container Field

      Post

      I have a layout (ReportCard) that I want to turn into a PDF, then save that PDF to a container field (zReportCard_cf).

       

      Do I have to write the PDF to the hard drive and then replace the container field with that file?

       

      I though I could do something like this (but cannot figure exactly how to do it)

       

      go to layout reportcard

      enter preview mode []

      save record as pdf into the container field.

       

      Suggestions are appreciated. 

        • 1. Re: Saving a PDF to a Container Field
          Orlando
            

          Hi DrDave

           

          You are right, you will need to store the PDF on your hard disk and then insert it into your container field.

           

          This is how i would go about doing it.

           

            #

            Set Variable [$FilePath ; "filemac:" & Get ( TemporaryPath ) & "FileName.pdf"]

            Got to Layout ["Reportcard"]

            Save Record as PDF [No dialog; "$FilePath", Current record]

            #PDF has been created, now insert into container

            Go to Layout ["ContainerLayout"] 

            Insert File [TABLE::ContainerField; "$FilePath"] 

            # 

           

          I set the $FilePath variable and use the Get ( TemporaryPath ) function which will store the PDF in your Temp folder, which gets cleared when the machine is turned off. Double check you untick "Store only a reference" on the Insert File when using the Temp folder.

           

          You can also set the modify the calculation to change the filename to be relevant to the record:

           

            "filemac:" & Get ( TemporaryPath ) & TABLE::FilenameCalc & ".pdf" 

           

          Also modify the "filemac:" to "filewin:" if your on windows. You can also modify this is you just want to insert a reference and store in on you hard drive or network 

           

          Also note when using the Insert File function the Container field must be on the layout the scritp is in, otherwise it will not insert the PDF.

           

          I hope this helps.

          • 2. Re: Saving a PDF to a Container Field
            DrDave
              

            Yes, this REALLY helps. 

             

            As I was reading through your comments I realized that I didn't realize :-) that I had to be on a layout with a container field, before I could write to it.

             

            This is a great email that really helps me out. Thank you.

             

            I'm required "by the rules" to get these report cards out by Friday and since I promoted FM for this job, I'm sort of "under the gun" to get it done. I'm thinking that I might make it now!

             

            Thanks again.

             

            P.S. I'll click the "solved" icon once I get this working. :-) 

            • 3. Re: Saving a PDF to a Container Field
              DrDave
                
              Here is my script. Everything works great, except the Insert File command. I get a 102 error, which is "field is missing."
               
              I checked the name of the $FullName field and it is correct. 
               
                
               
              As indicated in a previous message, I am on the proper layout.  
               
              Can you see the problem here? 
              • 4. Re: Saving a PDF to a Container Field
                DrDave
                  

                In debugging this, I simply say

                 

                Go to field [Competitor::zReportCard_cf] and I get the 102 error.

                 

                even if I specify the Street2 field, I get the 102.

                 

                Does this provide some insight? 

                • 5. Re: Saving a PDF to a Container Field
                  Orlando
                    

                  Sorry its not working for you DrDave

                   

                  Unfortunately I cant see the image you posted, any chance you can post it again?

                  • 6. Re: Saving a PDF to a Container Field
                    DrDave
                      

                    Here you go

                     

                     
                    Set Variable [ $FilePath; Value:"filemac:/" & "Drive-1/Users/MyFolder/" ] 
                    Set Variable [ $FileName; Value:"dxFileName.pdf" ] 
                    Set Variable [ $FullName; Value:$FilePath & $FileName ] 


                    Go to Layout [ “Report Card” (Competitor) ] 
                    Enter Preview Mode []

                     

                    Save Records as PDF [ File Name: “$FullName”; Current record ] 
                     
                    Go to Layout [ “zContainerLayout” (Competitor) ] 

                     

                     
                    #the script work sup to this point, then I get the 102 error. 
                     

                     Insert File [ Competitor::zReportCard_cf; “$FullName” ] 

                     

                     

                    Thoughts? 


                    • 7. Re: Saving a PDF to a Container Field
                      Orlando
                        

                      Get rid of the Enter Preview Mode step.

                       

                      Not needed in the script and is the reason you cannot enter into the container field.

                       

                      Let me know how you get on. 

                      • 8. Re: Saving a PDF to a Container Field
                        DrDave
                          

                        Orlando wrote:

                        Get rid of the Enter Preview Mode step.

                         

                        Not needed in the script and is the reason you cannot enter into the container field.

                         

                        Let me know how you get on. 


                        Done...and same error I'm afraid. Error 102 

                         


                        • 9. Re: Saving a PDF to a Container Field
                          DrDave
                            

                          Works! Whew....

                           

                          I removed the Enter Preview Mode and got the error. However, I added, Enter Browse Mode and that worked!

                           

                          Thank you so much for your help AND I figured out  -- finally -- how to enter my code into this forum. When I'm in the script editor, I print to preview mode and then do a cut-and-paste from the preview window.

                           

                          Thank you so much for your help...and determination to help! 

                          • 10. Re: Saving a PDF to a Container Field
                            Orlando
                              

                            Glad you got it working DrDave.

                             

                            It sounded to me like you were running this on a large batch of records so here is the script in a loop incase you need it.

                             

                              # 

                              Enter Browse Mode []

                              Set Variable [ $FilePath; Value:"filemac:/Drive-1/Users/MyFolder/" ] 

                              #

                              Go to Layout [ “zContainerLayout” (Competitor) ] 

                              Go to Record Request Page [First]

                              #

                              # Loop through generating cards for each competitor

                              Loop

                                Set Variable [ $FileName; Value:"dxFileName.pdf" ] 

                                Set Variable [ $FullName; Value:$FilePath & $FileName ] 

                                Go to Layout [ “Report Card” (Competitor) ] 

                                Save Records as PDF [ File Name: “$FullName”; Current record ] 

                                # 

                                Go to Layout [ “zContainerLayout” (Competitor) ] 

                                Insert File [ Competitor::zReportCard_cf; “$FullName” ]

                                Go to Record Request Page [Next; Exit after last]

                              End Loop

                              # 

                             

                            Good call on the print to preview, I have been typing all this time.

                             

                            Good luck getting your reports out for Friday.

                            • 11. Re: Saving a PDF to a Container Field
                              RGoyette

                              This worked well until the Insert File step.  What was inserted was a small pdf icon with the correct file name, but nothing that could be clicked on and opened.  This is different that what happens if you simply drag the file into the container, which has a document in the container that can be clicked on and opened via Acrobat Reader.  And ideas?

                              • 12. Re: Saving a PDF to a Container Field
                                mperley

                                     I know this is an old thread, but I am experiencing the same problem as RGoyette. I'm trying to save a multi page PDF and would like to use the interactive features of this container. 

                                     In playing around I tried to use the "Insert PDF" script step in place of "Insert File", but I received an error that the file could not be found when doing that (I never received this error when using the "Insert File" step).