Reputation: 27
I've got html2pdf working nicely to attach a pdf to an email However, I need to adjust the page width to 606px I can do this in the html but the html is 606px and the pdf itself is standard letter width in portait. Is there any way to constrict the doc to the width I need? Thanx
Mark
Upvotes: 0
Views: 18568
Reputation: 654
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.
Upvotes: 2
Reputation: 8463
Constructor of HTML2PDF CLass
public function __construct($orientation = 'P', $format = 'A4', $langue='fr', $unicode=true, $encoding='UTF-8', $marges = array(5, 5, 5, 8))
{
Adjust the $format variables by defining your page size
$format =array('user_defined_height','user_defined_width'); //for user-defined sizes accepts only in millimeter
In your case 606px = 160.3375mm
$format =array('160.3375','160.3375');
Upvotes: 0
Reputation: 1751
You can change the output of the PDF to more suit your purpose when constructing HTML2PDF.
http://www.prepressure.com/library/paper-sizes
Here are some compatible page sizes.
Upvotes: 0