Most flexible option is to base your layout on the line items portal. Then each record forms one row of data on your reciept and this will adjust automatically for different numbers of line items.
The invoices starter solution and this demo file created by comment use that method for printing invoices: http://fmforums.com/forum/showpost.php?post/309136/
A less flexible option is to set your portal to be many rows taller and set the portal to "Slide up", "Resize enclosing part". This works, but it can be difficult to set a "maximum number of rows" that will work for every possible invoice in some cases.
Key facts about sliding layout objects:
- It's only visible in preview mode and when you print/save as PDF...
- All layout objects below and in the same layout part as the slide/resize field need to also be set to slide up and resize.
- Objects in headers and footers will not slide.
- Portals will shrink/slide to fit the number of rows of records, but fields within the portal row will not shrink/slide.
- Consistent side borders are difficult to achieve with sliding fields.
Thank you Phil, as I mentionned we don't want to change the layout of the page but more so have the columns shrink or get longer as per the number of entries (being displayed in a portal) If I go to the line item option I wont be able to maintain the header and footer (as far as I know) because the data is being displayed in a portal.
I'd also be open to keeping the layout exactly the same but have page numbers instead.
Please check the demo file over. You'll find that your concerns are handled in the demo. You can add fields from the Invoice table to the header and footer (or grand summary and sub summary) layout parts of this LineItem based layout.
Changing layouts to print the invoice can be a process that is invisible to the user if you want.