unknown
unknown

Reputation: 385

Customized width and height in DOMPDF

Is there anyway i can set the generated PDF's width and height? i want to customized the width and height of the PDF. Normally it would be on a size of a short bond paper but how can i customized it? lets say for example i want it to be 200 x 500 pixel in size?

Any idea would be very much appreciated! cheers!

Upvotes: 5

Views: 33748

Answers (2)

greut
greut

Reputation: 4373

DOMPDF handles the paper size via the configuration.

define ("DOMPDF_DEFAULT_PAPER_SIZE", "letter");

You can referrer to all available sizes there:

https://github.com/dompdf/dompdf/blob/2eaf8fe0f1c95ab76e7a428a39a54dd240e2b2ec/src/Adapter/CPDF.php#L40

Upvotes: 3

Michiel
Michiel

Reputation: 150

You can set your own format, without having to change DOMPDF code, by passing an array when you're calling DOMPDF::set_paper(). Make sure it contains the width and the height in points, like this:

$dompdf->set_paper(array(0, 0, 595, 841), 'portrait');

Upvotes: 9

Related Questions