1 2 Previous Next 15 Replies Latest reply on Aug 18, 2013 7:08 PM by AbigailKlinton

    Insert PDF

    MartinKey

      Title

      Insert PDF

      Post

      I'm using FM12 and have a script setup to export to PDF, successfully working and combining all necessary pages.  What I want to do is insert a PDF before the first page.  It will always be the same PDF file.

       

      Please help!

      fm12sscript.jpg

        • 1. Re: Insert PDF
          philmodjunk

          Use Insert FIle to insert a copy of your PDF into a container field. Then use Export FIeld Contents to export it to $filePath. This generates a copy of your pre-existing PDF at the location where you will save your new PDF and with the name of the new PDF file. Do that after the Set variable step and before the first save as PDF step. Then make your first Save as PDF step an "append" save as PDF just like you show in the last step.

          • 2. Re: Insert PDF
            MartinKey

            Many thanks for that.

             

            Could you provide a bit more detail please?

            Are all of those steps done on the script writing section?  It's the container field bit  I don't understand, and I cannot find the Export Field Contents option either.

            • 3. Re: Insert PDF
              MartinKey

              I think that I've got somewhere.  I've managed to set a container field on the page and have inserted pdf and exported fields to $filepath.   It seems to work, but in place of showing the PDF it shows an icon of a PDF file snd the filename below it.

               

              Any ideas?

               

              Thank you, by the way.

              • 4. Re: Insert PDF
                philmodjunk

                That's what it should show if you used insert file and does it really matter? (Insert PDF could be used in FMP12 and if you optimize the container field for interactive content, but the results are the same.) The container field just serves as a temporary holder for your file while making a copy of it.

                • 5. Re: Insert PDF
                  MartinKey

                  I don't think I explained it right.

                  I'm not bothered about it showing an icon inside FM, but it still only shows an icon in the exported PDF.  So, page 1 of the PDF is a blank page with the icon of a PDF file and the filename on it.

                   

                  What am I doing wrong?

                  • 6. Re: Insert PDF
                    philmodjunk

                    Can you post the script you are using?

                    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. 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.
                    3. If You have FileMaker Advanced, you can generate a database design report and copy the script as text from there.
                    4. 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. (Use the HTML option on the database tab panel and paste the text into the forum's HTML editor.)
                    • 7. Re: Insert PDF
                      MartinKey

                           For some unknown reason I didn't get an email saying I had a response, I just stumbled across this through Google.

                            

                           Thank you.

                            

                      Printing: Print | Print Energy Survey Report to pdf

                      Set Variable

                            

                            

                      [ $filepath ; Value: Get ( DesktopPath )

                      & Branches::Energy Survey Title

                      & ".pdf" ]

                      Print Setup

                            

                            

                      [ Orientation: Portrait; Paper size: 8.26" x 11.69" ]

                      [ Restore; No dialog ]

                      Go to Related Record

                            

                            

                      [ From table: “Branches”; Using layout: “Print 01 ES Cover Page” (Branches) ]

                      [ Show only related records ]

                      Save Records as PDF

                            

                            

                      [ File Name: “$filepath” ; Current record ]

                      [

                            

                      Document - Title: /*Branches::Print_report_title*/; Compatibility: Acrobat 5 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 ]

                      Go to Related Record

                            

                            

                      [ From table: “Zones”; Using layout: “Print 02 ES Summary Page” (Zones) ]

                      [ Show only related records ]

                      Save Records as PDF

                            

                            

                      [ File Name: “$filepath” ; Records being browsed ]

                      [

                            

                      Document - Title: /*Branches::Print_report_title*/; Compatibility: Acrobat 5 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; Append; No dialog ]

                      Go to Related Record

                            

                            

                      [ From table: “Zones”; Using layout: “Print 04 ES Quotation” (Zones) ]

                      [ Show only related records ]

                      Save Records as PDF

                            

                            

                      [ File Name: “$filepath” ; Records being browsed ]

                      [

                            

                      Document - Title: /*Branches::Print_report_title*/; Compatibility: Acrobat 5 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; Append; No dialog ]

                      Go to Related Record

                            

                            

                      [ From table: “Zones”; Using layout: “Print 03 ES Lamp Data Sheets” (Zones) ]

                      [ Show only related records ]

                      Save Records as PDF

                            

                            

                      [ File Name: “$filepath” ; Records being browsed ]

                      [

                            

                      Document - Title: /*Branches::Print_report_title*/; Compatibility: Acrobat 5 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; Append; No dialog ]

                      Go to Related Record

                            

                            

                      [ From table: “Zones”; Using layout: “Print 05 ES Appendicies” (Zones) ]

                      [ Show only related records ]

                      Save Records as PDF

                            

                            

                      [ File Name: “$filepath” ; Current record ]

                      [

                            

                      Document - Title: /*Branches::Print_report_title*/; Compatibility: Acrobat 5 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; Append; No dialog ]

                      Go to Layout

                            

                            

                      [ original layout ]

                      7 November 2012 20:21:01 Key Electrical v3.6.fmp12 - Print | Print Energy Survey Report to pdf -1-

                      • 8. Re: Insert PDF
                        philmodjunk

                             Your script differs from my original suggestion--which was to store the cover page in a container field, but it should still work.

                             IF you insert Halt script immediately after the first Save As PDF script step and then examine the PDF, what do you see in the PDF file?

                        • 9. Re: Insert PDF
                          MartinKey

                               Apologies, I pasted the script from before I added the container field to start from a clean point, if that makes sense.

                               I will add that page again and repost.

                          • 10. Re: Insert PDF
                            MartinKey

                                 This is a screenshot of the cover page after adding the other lines.

                            • 11. Re: Insert PDF
                              MartinKey

                              Printing: Print | Print Energy Survey Report to pdf

                              Set Variable

                                    

                                    

                              [ $filepath ; Value: Get ( DesktopPath )

                              & Branches::Energy Survey Title

                              & ".pdf" ]

                              Print Setup

                                    

                                    

                              [ Orientation: Portrait; Paper size: 8.26" x 11.69" ]

                              [ Restore; No dialog ]

                              Insert File

                                    

                                    

                              [ Branches::ExPDF ]

                              [

                                    

                              Storage method: Let user choose ]

                              [

                                    

                              Display content ]

                              [

                                    

                              Compression: Never compress ]

                              Export Field Contents

                                    

                                    

                              [ “$filePath” ]

                              Go to Related Record

                                    

                                    

                              [ From table: “Branches”; Using layout: “Print 01 ES Cover Page” (Branches) ]

                              [ Show only related records ]

                              Save Records as PDF

                                    

                                    

                              [ File Name: “$filepath” ; Current record ]

                              [

                                    

                              Document - Title: /*Branches::Print_report_title*/; Compatibility: Acrobat 5 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; Append; No dialog ]

                              Go to Related Record

                                    

                                    

                              [ From table: “Zones”; Using layout: “Print 02 ES Summary Page” (Zones) ]

                              [ Show only related records ]

                              Save Records as PDF

                                    

                                    

                              [ File Name: “$filepath” ; Records being browsed ]

                              [

                                    

                              Document - Title: /*Branches::Print_report_title*/; Compatibility: Acrobat 5 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; Append; No dialog ]

                              Go to Related Record

                                    

                                    

                              [ From table: “Zones”; Using layout: “Print 04 ES Quotation” (Zones) ]

                              [ Show only related records ]

                              Save Records as PDF

                                    

                                    

                              [ File Name: “$filepath” ; Records being browsed ]

                              [

                                    

                              Document - Title: /*Branches::Print_report_title*/; Compatibility: Acrobat 5 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; Append; No dialog ]

                              Go to Related Record

                                    

                                    

                              [ From table: “Zones”; Using layout: “Print 03 ES Lamp Data Sheets” (Zones) ]

                              [ Show only related records ]

                              Save Records as PDF

                                    

                                    

                              [ File Name: “$filepath” ; Records being browsed ]

                              [

                                    

                              Document - Title: /*Branches::Print_report_title*/; Compatibility: Acrobat 5 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; Append; No dialog ]

                              Go to Related Record

                                    

                                    

                              [ From table: “Zones”; Using layout: “Print 05 ES Appendicies” (Zones) ]

                              [ Show only related records ]

                              Save Records as PDF

                                    

                                    

                              [ File Name: “$filepath” ; Current record ]

                              [

                                    

                              Document - Title: /*Branches::Print_report_title*/; Compatibility: Acrobat 5 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; Append; No dialog ]

                              Go to Layout

                                    

                                    

                              [ original layout ]

                              7 November 2012 20:58:23 Key Electrical v3.6 - Copy.fmp12 - Print | Print Energy Survey Report to pdf -1-

                              • 12. Re: Insert PDF
                                philmodjunk

                                     The script should not need to use Insert File. You should need to only insert the file once manually or in a different script and then you can export from it as many times as you need to generate this report. But then maybe the user needs to be able to select the file to import.

                                Export Field Contents [ “$filePath” ]

                                     is missing the name of the container field into which you inserted the PDF.

                                     It should read:

                                Export Field Contents [ Branches::ExPDF ; “$filePath” ]

                                     Note that Export Field Contents with a file path specified, but no field specified will delete any file of the name and location specified in the file path.

                                • 13. Re: Insert PDF
                                  MartinKey

                                       Thank you  for all this help.

                                        

                                       I've got it working perfectly, only it works two or three times then I have to insert the file into the container field again.   What am I doing wrong?

                                  • 14. Re: Insert PDF
                                    philmodjunk

                                         Can't tell from what you have posted. If you have to insert into the container field again, either something is clearing the container field or you are not always referring to the same record each time.

                                    1 2 Previous Next