Reputation: 77
i'm using dompdf in laravel version 8+ and i generated a pdf successfully by first loading the view then extracting its content and saving it as a pdf file. there is only 1 table in my view which is loaded by dompdf and it is not fitting in the page.
anyone knows how to fix this?
Upvotes: 2
Views: 2138
Reputation: 15319
Look Like you need to update dpi in dompdf config
file
Default dpi
is 96
.Better to change it to "dpi" => 196
From dom pdf config file
/**
* Image DPI setting
*
* This setting determines the default DPI setting for images and fonts. The
* DPI may be overridden for inline images by explictly setting the
* image's width & height style attributes (i.e. if the image's native
* width is 600 pixels and you specify the image's width as 72 points,
* the image will have a DPI of 600 in the rendered PDF. The DPI of
* background images can not be overridden and is controlled entirely
* via this parameter.
*
* For the purposes of DOMPDF, pixels per inch (PPI) = dots per inch (DPI).
* If a size in html is given as px (or without unit as image size),
* this tells the corresponding size in pt.
* This adjusts the relative sizes to be similar to the rendering of the
* html page in a reference browser.
*
* In pdf, always 1 pt = 1/72 inch
*
* Rendering resolution of various browsers in px per inch:
* Windows Firefox and Internet Explorer:
* SystemControl->Display properties->FontResolution: Default:96, largefonts:120, custom:?
* Linux Firefox:
* about:config *resolution: Default:96
* (xorg screen dimension in mm and Desktop font dpi settings are ignored)
*
* Take care about extra font/image zoom factor of browser.
*
* In images, <img> size in pixel attribute, img css style, are overriding
* the real image dimension in px for rendering.
*
* @var int
*/
"dpi" => 96,
Ref:https://github.com/barryvdh/laravel-dompdf/blob/master/config/dompdf.php
Upvotes: 2