Question

i am using html2pdf to convert html to pdf... actually i have a large size of html container like 12x12in (inches). and i have used A4 size for the first time then my html content not showing completely till as per the size (12x12 in) then i have look into your site and i found all paper size here.. thanks for that important info... but now, when i have used A3 size i have found, my all html content inside the pdf file....but there are so much space at the bottom of my contents in pdf... So i want to know... IS there any way to reduce this space from the pdf or any other way to convert html to pdf with manually defined page height and width...

Thanks in Advance.

Was it helpful?

Solution

The constructor of the HTML2PDF class says, that the $format parameter is the same as in the tcpdf class. The constructor of the tcpdf class says about the $format parameter:

@param mixed $format The format used for pages. It can be either one of the following values (case insensitive) or a custom format in the form of a two-element array containing the width and the height (expressed in the unit given by unit) ...

With a little bit of calculation, this make it possible to set the page size to 12'' x 12''. The default unit is millimeters.

OTHER TIPS

Here is the solution for this problem:

$html2pdf = new HTML2PDF('P', array($width_in_mm,$height_in_mm), 'en', true, 'UTF-8', array(0, 0, 0, 0));

Width and Height should be in MM. If your using inches convert it to MM.

Formula: $width_in_mm = $width_in_inches * 25.4; $height_in_mm = $height_in_inches * 25.4;

Don't round it off. Used the exact conversion even if it has a decimal point.

Hope this answer will solve your problem.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top