Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with document generation (quotes/invoices), margin and pagination #28274

Closed
ipdeveloppement44 opened this issue Feb 19, 2024 · 5 comments
Closed
Labels
Bug This is a bug (something does not work as expected)

Comments

@ipdeveloppement44
Copy link

Bug

On document templates, specifically the one for invoices labeled "crabe," the price of certain lines is written in the footer. The second issue is that the pagination is also incorrect. For a 3-page document, the first page shows "1/2," the second page "2/3," and the last page "3/3."

Environment Version

18.0.3

Environment OS

Linux

Environment Web server

Apache

Environment PHP

8.1

Environment Database

MariaDB 10.3.39

Environment URL(s)

No response

Expected and actual behavior

The PDFs are configured to display the price at the top of the line (MAIN_PDF_DATA_ON_FIRST_PAGE = 1). Therefore, if a line starts slightly at the bottom of the previous page, it writes the prices at that level. There is no issue with the description, but in terms of writing prices, they end up in the footer.

The second problem concerns pagination, where for a 3-page document, the first page displays "1/2," the second page "2/3," and the last page "3/3."

Steps to reproduce the behavior

No response

Attached files

Issue with writing the price:
pdf1
Pagination issue:
pdf2
pdf3
pdf4
pdf5

@ipdeveloppement44 ipdeveloppement44 added the Bug This is a bug (something does not work as expected) label Feb 19, 2024
@badrbouslikhin
Copy link

I'm experiencing the same issue with the cyan propale template on v19.0.0.
The issue comes from this line. The empty($showpricebeforepagebreak) condition leads to not updating the page on pagebreak.
I am still looking for a fix that preserves both a proper formatting and MAIN_PDF_DATA_ON_FIRST_PAGE = 1 option.

@badrbouslikhin
Copy link

Here is a dirty hack I found (knowing that my propale template is derived from cyan):

diff --git a/dolibarr/modeles/propale/pdf_thermigo.modules.php b/dolibarr/modeles/propale/pdf_thermigo.modules.php
index 4ab9c8e..ca9ec4d 100644
--- a/dolibarr/modeles/propale/pdf_thermigo.modules.php
+++ b/dolibarr/modeles/propale/pdf_thermigo.modules.php
@@ -607,6 +607,11 @@ class pdf_thermigo extends ModelePDFPropales
 
               $this->printColDescContent($pdf, $curY, 'desc', $object, $i, $outputlangs, $hideref, $hidedesc);
 
+              // HACK: to handle the case where there is a pagebreak before the description
+              // and the price is written on the previous page.
+              $curYAfterPageBreakWrite = $curY;
+              $getYAfterPageBreakWrite = $pdf->GetY();
+
               $pageposafter = $pdf->getPage();
               $posyafter = $pdf->GetY();
               //var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit;
@@ -646,6 +651,13 @@ class pdf_thermigo extends ModelePDFPropales
             $curY = $tab_top_newpage;
           }
 
+          // HACK: to handle the case where there is a pagebreak before the description
+          // and the price is written on the previous page.
+          if ($pageposafter > $pageposbefore && $getYAfterPageBreakWrite < $curYAfterPageBreakWrite) {
+            $pdf->setPage($pageposafter);
+            $curY = $tab_top_newpage;
+          }
+
           $pdf->SetFont('', '', $default_font_size - 1); // We reposition the default font
 
           // VAT Rate

@fappels
Copy link
Contributor

fappels commented Apr 25, 2024

Progress on fix here: Issue #29458

@fappels fappels closed this as completed Apr 27, 2024
@badrbouslikhin
Copy link

@fappels, I tried the fix that I believe was included in v19.0.2, and the pagination issue is indeed resolved. However, the price of certain lines written in the footer as described by @ipdeveloppement44 is still present for me.

My workaround addresses the issue for proposals with short description items, but it causes the price on the first page to break for items with long descriptions that span multiple pages.

Do you have any suggestions on where I should investigate further to resolve this issue?

@fappels
Copy link
Contributor

fappels commented May 15, 2024

Hello @badrbouslikhin , did not notice there were two issue in this report.
Seems second issue coming from HIDDEN option introduced here: #13005
Think your workaround ignores this option. Needs some debugging for fixing the HIDDEN option so can give no suggestion on this.
Think @ipdeveloppement44 should make new issue on HIDDEN option MAIN_PDF_DATA_ON_FIRST_PAGE.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug This is a bug (something does not work as expected)
Projects
None yet
Development

No branches or pull requests

3 participants