DOMPDF with css float
Solution 1
Float support is introduced in the 0.6.0 code base, but it is disabled by default since it is still in development. Make sure you have enabled it by setting DOMPDF_ENABLE_CSS_FLOAT to true.
Starting with version 0.7.0 float support is enabled by default.
That being said, since the feature is still in development you're not going to get the results you want. Floats that span more than one page don't currently work as expected because a page break occurs before the non-floated content is rendered.
Solution 2
Guys use display: inline-block; instead of float. I use the older version of dompdf in my project. I enable DOMPDF_ENABLE_CSS_FLOAT true in dompdf_config.custom.inc file. But the float result is overlapping and distorted.The inline-block is the new and better way than using float left every time. Visit the following w3school link to more info. CSS Layout - inline-block
Solution 3
use def("DOMPDF_ENABLE_CSS_FLOAT", true); in dompdf_config.inc.php
it works for your css float
Solution 4
you need use https://github.com/barryvdh/laravel-dompdf
is the plugin dompdf
for Laravel 5.
and change the config in:
vendor/barrryvdh/laravel-dompdf/config/dompdf.php
def("DOMPDF_ENABLE_CSS_FLOAT", true);
Solution 5
use <div style="position: absolute; left: 6px;"></div>
in my case
def("DOMPDF_ENABLE_CSS_FLOAT", true);
is Not Working
Joshua Blevins
Updated on October 08, 2020Comments
-
Joshua Blevins over 3 years
I am not sure why but the html page displays just fine but the dompdf does not utilize the floats.
Code is 2300 + line long so to long to post here.... But it is all inline css.
<div style="float:left;"> </div>
I have tried both wrapping the css in a style tag and inline with no luck.
This is the html page
http://www.ems-complete.com/ccems/ccems_reports/daily_vehicle_check_sheet.php?id=5
This is the dompdf link
http://www.ems-complete.com/ccems/ccems_reports/form_daily_vehicle_check.php?id=5
I am not sure why but the html page displays just fine but the dompdf does not utilize the floats...
Code is 2300 + line long so to long to post here.... But it is all inline css...
-
Explosion Pills about 11 yearsSeems to be missing an
=
?
-
-
Joshua Blevins about 11 yearsI have already set the float command to true prior to posting this... Plus I have put in a page break to help prevent the floats from spanning more than on page... Is there any Ideal when this function will be functional
-
BrianS about 11 yearsRight now, no. We had hoped to have float support completed for the 0.6.0 final release, but it looks like it will probably slip to the next release. Unfortunately we're a small team with limited resources and I don't see the pace of development increasing in the near future.
-
BrianS about 11 yearsFYI, one of the issues you're seeing is because dompdf doesn't currently size a div to its content on float. So the width is still at 100% for your floated divs. If you specify a width for each column (say 25%) you'll get better results, but the layout is still complicated by the floats being larger than a single page.
-
Joshua Blevins about 11 yearsAwesome I will do some Tinkering with it and see what I can come up with.
-
Joshua Blevins about 11 yearsI added some css width:25%; to the columns and now I get this error Catchable fatal error: Argument 1 passed to DOMNode::appendChild() must be an instance of DOMNode, null given, called in /home/emscompl/public_html/ccems/ccems_reports/dompdf/include/table_frame_decorator.cls.php on line 304 and defined in /home/emscompl/public_html/ccems/ccems_reports/dompdf/include/frame.cls.php on line 726
-
Joshua Blevins about 11 yearsand now cant get it to clear even when taking these css values out
-
BrianS about 11 yearsAre you using 0.6.0 beta 3 or the latest code from github. I would recommend the latter, if possible.
-
Joshua Blevins about 11 yearsSeems I had a missing tag... I am using 0.6.0 I will look at getting the github code now.... But I have done some changes in the css and starting to make head way... check out the link above if you like
-
BrianS about 11 yearsAh, nice! Glad you're making progress. Wish I had time to help you hack at it, but if you run into a wall let me know.
-
Joshua Blevins about 11 yearsAssuming this is the correct address to get the github github.com/dompdf/dompdf
-
BrianS about 11 yearsThat is correct. You'll have to download php-font-lib separately from github.com/PhenX/php-font-lib
-
Nigel Sheridan-Smith about 8 yearslaravel-dompdf 0.6.1 doesn't seem to handle the bootstrap
.col-xs-X
grid styles very well, so I just forced them todisplay: inline-block
instead and changed the widths to squeeze them in with the@media print
layout. -
Ted Avery about 7 yearsding ding ding we have a winner!
-
Tim van Uum about 5 yearsDo not change in vendor folder! When you'll do a composer update this change will be gone. Bad practice. Publish the config first.
-
Pawan Singh about 4 yearsit tried with 0.8.5 but still not working with float