@@ -276,13 +276,14 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede
276
276
277
277
$ pdf = pdf_getInstance ($ this ->format );
278
278
$ default_font_size = pdf_getPDFFontSize ($ outputlangs ); // Must be after pdf_getInstance
279
- $ heightforinfotot = 50 ; // Height reserved to output the info and total part
279
+ $ pdf ->SetAutoPageBreak (true , 0 );
280
+
281
+ $ heightforinfotot = 40 ; // Height reserved to output the info and total part
280
282
$ heightforfreetext = getDolGlobalInt ('MAIN_PDF_FREETEXT_HEIGHT ' , 5 ); // Height reserved to output the free text on last page
281
283
$ heightforfooter = $ this ->marge_basse + 8 ; // Height reserved to output the footer (value include bottom margin)
282
284
if (getDolGlobalString ('MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS ' )) {
283
285
$ heightforfooter += 6 ;
284
286
}
285
- $ pdf ->setAutoPageBreak (true , 0 );
286
287
287
288
if (class_exists ('TCPDF ' )) {
288
289
$ pdf ->setPrintHeader (false );
@@ -335,6 +336,8 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede
335
336
336
337
$ tab_height = $ this ->page_hauteur - $ tab_top - $ heightforfooter - $ heightforfreetext ;
337
338
339
+ $ nexY = $ tab_top - 1 ;
340
+
338
341
// Incoterm
339
342
$ height_incoterms = 0 ;
340
343
if (isModEnabled ('incoterm ' )) {
@@ -344,7 +347,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede
344
347
345
348
$ pdf ->SetFont ('' , '' , $ default_font_size - 1 );
346
349
$ pdf ->writeHTMLCell (190 , 3 , $ this ->posxdesc - 1 , $ tab_top - 1 , dol_htmlentitiesbr ($ desc_incoterms ), 0 , 1 );
347
- $ nexY = $ pdf ->GetY ();
350
+ $ nexY = max ( $ pdf ->GetY (), $ nexY );
348
351
$ height_incoterms = $ nexY - $ tab_top ;
349
352
350
353
// Rect takes a length in 3rd parameter
@@ -367,6 +370,8 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede
367
370
368
371
$ pagenb = $ pdf ->getPage ();
369
372
if (!empty ($ notetoshow )) {
373
+ $ tab_top -= 2 ;
374
+
370
375
$ tab_width = $ this ->page_largeur - $ this ->marge_gauche - $ this ->marge_droite ;
371
376
$ pageposbeforenote = $ pagenb ;
372
377
@@ -375,8 +380,6 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede
375
380
$ notetoshow = make_substitutions ($ notetoshow , $ substitutionarray , $ outputlangs );
376
381
$ notetoshow = convertBackOfficeMediasLinksToPublicLinks ($ notetoshow );
377
382
378
- $ tab_top -= 2 ;
379
-
380
383
$ pdf ->startTransaction ();
381
384
382
385
$ pdf ->SetFont ('' , '' , $ default_font_size - 1 );
@@ -492,21 +495,11 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede
492
495
// Use new auto column system
493
496
$ this ->prepareArrayColumnField ($ object , $ outputlangs , $ hidedetails , $ hidedesc , $ hideref );
494
497
498
+ $ nexY = $ tab_top + $ this ->tabTitleHeight ;
495
499
496
500
$ pageposbeforeprintlines = $ pdf ->getPage ();
497
501
$ pagenb = $ pageposbeforeprintlines ;
498
502
499
- // Show square
500
- if ($ pagenb == $ pageposbeforeprintlines ) {
501
- $ this ->_tableau ($ pdf , $ tab_top , $ this ->page_hauteur - $ tab_top - $ heightforinfotot - $ heightforfreetext - $ heightforfooter , 0 , $ outputlangs , $ hidetop , 0 , $ object ->multicurrency_code );
502
- $ bottomlasttab = $ this ->page_hauteur - $ heightforinfotot - $ heightforfreetext - $ heightforfooter + 1 ;
503
- } else {
504
- $ this ->_tableau ($ pdf , $ tab_top_newpage , $ this ->page_hauteur - $ tab_top_newpage - $ heightforinfotot - $ heightforfreetext - $ heightforfooter , 0 , $ outputlangs , 1 , 0 , $ object ->multicurrency_code );
505
- $ bottomlasttab = $ this ->page_hauteur - $ heightforinfotot - $ heightforfreetext - $ heightforfooter + 1 ;
506
- }
507
-
508
- $ nexY = $ tab_top + $ this ->tabTitleHeight ;
509
-
510
503
// Loop on each lines
511
504
for ($ i = 0 ; $ i < $ nblines ; $ i ++) {
512
505
$ curY = $ nexY ;
@@ -555,20 +548,20 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede
555
548
}
556
549
557
550
// Description of product line
558
- $ curX = $ this ->posxdesc - 1 ;
559
551
$ showpricebeforepagebreak = 1 ;
560
552
561
553
if ($ this ->getColumnStatus ('desc ' )) {
562
554
$ pdf ->startTransaction ();
563
555
564
556
$ this ->printColDescContent ($ pdf , $ curY , 'desc ' , $ object , $ i , $ outputlangs , $ hideref , $ hidedesc , 1 );
565
-
566
557
$ pageposafter = $ pdf ->getPage ();
558
+
567
559
if ($ pageposafter > $ pageposbefore ) { // There is a pagebreak
568
560
$ pdf ->rollbackTransaction (true );
561
+ $ pageposafter = $ pageposbefore ;
562
+ $ pdf ->setPageOrientation ('' , 1 , $ heightforfooter ); // The only function to edit the bottom margin of current page to set it.
569
563
570
564
$ this ->printColDescContent ($ pdf , $ curY , 'desc ' , $ object , $ i , $ outputlangs , $ hideref , $ hidedesc , 1 );
571
-
572
565
$ pageposafter = $ pdf ->getPage ();
573
566
$ posyafter = $ pdf ->GetY ();
574
567
if ($ posyafter > ($ this ->page_hauteur - ($ heightforfooter + $ heightforfreetext + $ heightforinfotot ))) { // There is no space left for total+free text
@@ -595,8 +588,10 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede
595
588
$ posYAfterDescription = $ pdf ->GetY ();
596
589
}
597
590
598
- $ nexY = $ pdf ->GetY ();
591
+ $ nexY = max ($ pdf ->GetY (), $ posYAfterImage );
592
+
599
593
$ pageposafter = $ pdf ->getPage ();
594
+
600
595
$ pdf ->setPage ($ pageposbefore );
601
596
$ pdf ->setTopMargin ($ this ->marge_haute );
602
597
$ pdf ->setPageOrientation ('' , true , 0 ); // The only function to edit the bottom margin of current page to set it.
@@ -798,6 +793,14 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede
798
793
}
799
794
}
800
795
796
+ // Show square
797
+ if ($ pagenb == $ pageposbeforeprintlines ) {
798
+ $ this ->_tableau ($ pdf , $ tab_top , $ this ->page_hauteur - $ tab_top - $ heightforinfotot - $ heightforfreetext - $ heightforfooter , 0 , $ outputlangs , $ hidetop , 0 , $ object ->multicurrency_code , $ outputlangsbis );
799
+ } else {
800
+ $ this ->_tableau ($ pdf , $ tab_top_newpage , $ this ->page_hauteur - $ tab_top_newpage - $ heightforinfotot - $ heightforfreetext - $ heightforfooter , 0 , $ outputlangs , 1 , 0 , $ object ->multicurrency_code , $ outputlangsbis );
801
+ }
802
+ $ bottomlasttab = $ this ->page_hauteur - $ heightforinfotot - $ heightforfreetext - $ heightforfooter + 1 ;
803
+
801
804
// Affiche zone infos
802
805
$ posy = $ this ->_tableau_info ($ pdf , $ object , $ bottomlasttab , $ outputlangs );
803
806
0 commit comments