DOMPDF with css float

29,255

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

Share:
29,255
Joshua Blevins
Author by

Joshua Blevins

Updated on October 08, 2020

Comments

  • Joshua Blevins
    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
      Explosion Pills about 11 years
      Seems to be missing an =?
  • Joshua Blevins
    Joshua Blevins about 11 years
    I 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
    BrianS about 11 years
    Right 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
    BrianS about 11 years
    FYI, 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
    Joshua Blevins about 11 years
    Awesome I will do some Tinkering with it and see what I can come up with.
  • Joshua Blevins
    Joshua Blevins about 11 years
    I 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/includ‌​e/table_frame_decora‌​tor.cls.php on line 304 and defined in /home/emscompl/public_html/ccems/ccems_reports/dompdf/includ‌​e/frame.cls.php on line 726
  • Joshua Blevins
    Joshua Blevins about 11 years
    and now cant get it to clear even when taking these css values out
  • BrianS
    BrianS about 11 years
    Are you using 0.6.0 beta 3 or the latest code from github. I would recommend the latter, if possible.
  • Joshua Blevins
    Joshua Blevins about 11 years
    Seems 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
    BrianS about 11 years
    Ah, 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
    Joshua Blevins about 11 years
    Assuming this is the correct address to get the github github.com/dompdf/dompdf
  • BrianS
    BrianS about 11 years
    That is correct. You'll have to download php-font-lib separately from github.com/PhenX/php-font-lib
  • Nigel Sheridan-Smith
    Nigel Sheridan-Smith about 8 years
    laravel-dompdf 0.6.1 doesn't seem to handle the bootstrap .col-xs-X grid styles very well, so I just forced them to display: inline-block instead and changed the widths to squeeze them in with the @media print layout.
  • Ted Avery
    Ted Avery about 7 years
    ding ding ding we have a winner!
  • Tim van Uum
    Tim van Uum about 5 years
    Do 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
    Pawan Singh about 4 years
    it tried with 0.8.5 but still not working with float