different page format for different pdf

webmarco

Member
I need to print in different page formats.
My application will be used in main office for production planning and in the production plant for label printing.
I use _settings.php files for each template.
What is the proper way to make the pdf generated on specific paper format?
In the office we need to print in A4 paper, in production we will use A5 paper.

Thank you

Your current DaDaBIK version​

You are using DaDaBIK version 11.12-Elba enterprise, installed on 25-03-2024 (installation code: 194506601bb58bf10c), the latest version of DaDaBIK is 11.12-Elba released on 30-11-2023

You are running the latest release of DaDaBIK

System info​

PHP Version: 7.3.31-1~deb10u5

mysql version: 5.5.5-10.3.39-MariaDB-0+deb10u2

Web server: Apache/2.4.38 (Raspbian)

Client: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36
 

eugenio

Administrator
Staff member
Hello,
you have to check the TCPDF documentation to see how to change the page size and then add the proper code in your set_standard_pdf_parameters_custom() function (see the documentation for further details). For example this line in the set_standard_pdf_parameters_custom() function set custom margins:

$pdf->SetMargins(4, 10, 4);

Best,
 

webmarco

Member
I tried to find a way to change the page size BEFORE pdf generation.
I have been able in having A5 format pages only using

$pdf->AddPage('L','A5', false, false);

in my set_standard_pdf_parameters_custom()

in this way I get A5 pages, properly oriented but of course I have a blank first page.
I suppose that page format (A5 in my case) is passed somewhere else to the pdf creator.

I didn't find a way of changing page size using mytemplate_settings.php files

Any suggestion?

Maybe is it possible using the same way of changing page orientation in the _settings.php ? I think this would require some modification in dadabik code used for pdf generation calling tcpdf constructor.
 

webmarco

Member
in the hcangelog of tcpdf I found:
5.0.012 (2010-05-19)
- The access to method setPageFormat() was changed to 'protected' because it is not intended to be directly called.


I removed protected from the method setPageFormat() and now I can use this method in my template_settings.php in order to get the desired page format.

Can someone see problems in this "hack"?
 

eugenio

Administrator
Staff member
Hello,
you are right, the A4 format is passed by default by DaDaBIK when a new instance of the class MYPDF is created. It could be transformed into a config parameter, I'll add this to the todo list.
About changing the tcpdf code, I would say it shouldn't be a problem but it's hard to say for sure, I don't know so well the tcpdf code.

Best,
 
Top