1 2 Previous Next 16 Replies Latest reply on Aug 12, 2017 2:15 AM by sharon

    sub-summary creates individual PDF files

    lauriehughes

      I am using a sub-summary part to create a page break. Is there any way to script FMP so that it creates a new PDF each time the sub-summary creates a page break?

      thanks in advance

        • 1. Re: sub-summary creates individual PDF files
          beverly

          Not directly. Loop and find each group (based on the sort you have now) to "print to pdf" each group.

           

          Or look to plug-ins.

          beverly

          • 3. Re: sub-summary creates individual PDF files
            LadyBear

            Hi Beverly, 

             

            I have the same issue and I'm not sure how to practically apply your advice.  I understand looping, and I understand how to "print to pdf".

             

            What I don't understand is how to "find each group (based on the sort you have now)".   I already have a found set. So if I find a group won't I lose the rest of the records?  Each group has its own records.

            • 4. Re: sub-summary creates individual PDF files
              beverly

              I think typically there is a GTRR (go to related record) in a new window based on the unique groups. If you print the report in the new window, it will be ONLY those for that group. However, in your loop of the found set, you must text the value and only send the report for each unique value. I tend to do this with a variable (set to empty at first).

               

              Set variable ($myGroup ; "")

              Loop

              If ($myGroup ≠ myFieldValue)

              Set variable ($myGroup ; myFieldValue // ready for next test)

              ... here is where you go to the records in a new window and print the pdf ...

               

              End If

              Exit Loop if ( Get (FoundCount) = Get(RecordNumber ) // exit after processing last record )

              Go to Record request next

              End Loop

               

              beverly

              • 5. Re: sub-summary creates individual PDF files
                LadyBear

                Just to clarify myFieldValue is the field you sorted on.  You give $myGroup the the first record's value of myFieldValue.

                You find the related records in the current layout and put them in a new window.  Print the pdf.

                 

                Do we then

                1. get a value for (Get(FoundCount) + 1)

                2. go back to the original found set in the original layout and look at that record and loop back through creating pdfs until we exit?

                Thanks.

                • 6. Re: sub-summary creates individual PDF files
                  beverly

                  no. within your found set and loop, you open a new window based on the records you need for each group. Print the pdf and then close the window. you are then STILL in the list of found records and go to the next one.

                   

                  beverly

                  • 7. Re: sub-summary creates individual PDF files
                    LadyBear

                    So can you explain the myFieldValue field please.

                    • 8. Re: sub-summary creates individual PDF files
                      LadyBear

                      Do you put actual values there? 

                      • 9. Re: sub-summary creates individual PDF files
                        LadyBear

                        I thought it best if I put some of the code I have in order that you are able to see.

                         

                        Please note the file is sorted by student number and fee period.

                         

                        Enter Browse Mode []

                        Go to Layout [“VFH Invoice Notice”(Registrations)]

                        #

                        #  Set up a Student’s set of Units of Study and Save to pdf then loop through to next Student.

                        #

                        Set Variable [$MyStudent; Value;””]

                        Loop

                              If[$My student ≠  Registrations::Student number]

                                        Set Variable [$MyStudent; Value:Registrations::Student number]   ?????

                                        Set Variable [$filename; Value: network pathway/name of file.pdf”]

                                      Go to Related Record [Show only related records; From table: “Registrations”; Using layout;
                        <Current Layout>; New window]

                                        Enter Preview Mode []

                                        Pause/Resume Script [Indefinitely]

                         

                        Etc

                              

                        Paused here to see what was happening and I am getting the identical records as I am in my original found set. Ie nothing has changed.    I Have the same records.  The Go to Related Records didn’t seem to only match the current record as requested.

                        • 10. Re: sub-summary creates individual PDF files
                          beverly

                          That is the name of YOUR field.

                          beverly

                          • 11. Re: sub-summary creates individual PDF files
                            beverly

                            are you Grouping by "Student number"?

                             

                            do you have a relationship to the Group? (self join using the group) Then you should use that as your relationship for GTRR, if I understand what you have.

                             

                            beverly

                            • 12. Re: sub-summary creates individual PDF files
                              LadyBear

                              Yes, Beverly I am grouping by Student number.

                               

                              Thank you for your advice.  I am finding working with sub-summaries and pdf's a little tricky.  Most of the other scripts I have created are far more straight forward.

                              • 13. Re: sub-summary creates individual PDF files
                                beverly

                                Yes, you are trying to create different PDFs from a found set (using the group). There is no way (directly) to do this.

                                 

                                While we have the print option of breaking to a new page based on a sub-summary, this would only PRINT that way.

                                 

                                If you have a way to separate a single PDF printed with the breaking feature, that would be absolutely wonderful. So we just get the found records (by group) into another window and print.

                                 

                                It's a work-around. There may be other ways, but let's get some more responses to your question to see.

                                 

                                beverly

                                • 14. Re: sub-summary creates individual PDF files
                                  lauriehughes

                                  I have been working away on this and I have a working solution based off comments here.

                                   

                                  I am not actually dealing with credit card #s and purchase but I thought it was an easy analogy to understand.

                                  Suppose you had a business and you wanted to see the purchases for each credit card.

                                  there would be a credit card table and a purchases table and they would be related by a field called credit card in both tables

                                  There would only ever be one credit card number record, but many purchases records that relate via the credit card number.

                                   

                                  set variable [$OLDcreditcardnumber; value:””]//this variable is used to test if I have already made a pdf for a particular credit card ##

                                   

                                  loop

                                      set variable [$current_creditcardnumber; value:creditcardtable:creditcardnumber]

                                      if [$OLDcreditcardnumber ≠ $current_creditcardnumber]

                                          set variable [$filepath; value:"file:database_files/test_files/" & $current_creditcardnumber  & ".pdf"]

                                          go to related record [from table: “purchases”; using layout: “purchases layout”; new window]

                                          perform find [restore]//performs a find looking for $current_creditcardnumber

                                          save records as pdf [restore; no dialog, “$filepath”; records being browsed]

                                          set variable  [$OLDcreditcardnumber; value:creditcardtable:creditcardnumber]

                                          close window [current window]

                                      end if

                                      go to record/ request/ page [next; exit after last]

                                  end loop

                                   

                                  hope that helps

                                  1 2 Previous Next