Forum


Replies: 1   Views: 171
Invoice with subtotals after page break
Topic closed:
Please note this is an old forum thread. Information in this post may be out-to-date and/or erroneous.
Every phpdocx version includes new features and improvements. Previously unsupported features may have been added to newer releases, or past issues may have been corrected.
We encourage you to download the current phpdocx version and check the Documentation available.

Posted by makeinvoices  · 29-04-2019 - 15:30

Hello,

we are considering to build a new print solution for our ERP based on phpdocx and so far it does look very promising, as it seems to provide all required features. There is just one open question: Is it possible to generate an invoice from a template, which has a table of positions with

  • an arbitrary number of rows,
  • a variable number of rows per page, determined by how many rows can fit the page before a page break would occur, and
  • after each page break: a table row containing the subtotal of all previously listed positions.

The first two are easily achievable with replaceTableVariable and the proper table style, but I'm not sure how one would go about the third one. If you have a clean solution to this, we will probably get a premium license within the week, so I hope you can give us some pointers even though we currently do not have a license.

Best regards,

T.D.

Posted by admin  · 29-04-2019 - 17:21

Hello,

The third item can be done using DOCXPath (https://www.phpdocx.com/documentation/introduction/docxpath).

If you know how many rows fit each page or there's a pagebreak tag/property to generate new pages, DOCXPath allows inserting/cloning a row (or any other content) after that rows with the new information you need to add; this content can be static or generated from the existing values of table/s. Please note, that a DOCX is not 'painted' as PDF, DOCX contents are displayed when the DOCX is open, so phpdocx don't know when a page break will be (unless you force it); but if you know how many table rows fit a page (because they have fixed heights) then the content after each set of rows (after them a new page will be generated) can be changed easily using DOCXPath.

Although DOCXPath is available in Advanced and Premium licenses, for this kind of task we recommend using a Premium, so DOCXCustomizer can also be used (https://www.phpdocx.com/documentation/introduction/docxcustomizer) if needed. If you purchase a license, please send an e-mail to contact[at]phpdocx.com and we'll generate a script to illustrate how to accomplish that task.

Regards.