dompdf icon indicating copy to clipboard operation
dompdf copied to clipboard

Suggestion: Create Wiki page for integrating Bootstrap

Open ThomasLandauer opened this issue 8 months ago • 2 comments

While browsing through the issues, I found that most Bootstrap-related issues are referring to the same two things:

  • isRemoteEnabled
  • box-sizing

So I'm suggesting to create a dedicated wiki page for that - even more since adding third-party CSS frameworks into PDF's is probably going to get more popular (not less).

Some more questions I would be interested in:

  • When adding Bootstrap (one way or the other), will the final PDF include the entire Bootstrap code? Or is there some magic in place that removes unused styles? If no, Google (Lighthouse) recommends https://developer.chrome.com/docs/lighthouse/performance/unused-css-rules
  • What's your recommended approach? Do you have a rule of thumb if it's better to copy just the styles you need, or really try to add Bootstrap?

ThomasLandauer avatar Jun 18 '25 16:06 ThomasLandauer

Seems reasonable. It is a wiki so anybody can start the document at any time, though if nobody else steps up I'll see what I can put together. Maybe a more general "CSS Frameworks" page (for example, there have been a few questions related to Tailwind).

As for your questions:

  • Actual CSS isn't included in the output, just the translation of the styling to graphic states in the PDF. Dompdf behaves like a web browser and just like for a web browser the user would need to optimize the CSS. Dompdf will parse and attempt to apply all styles present. The ones that don't target an element in the document won't be applied and thus won't be represented in the PDF.
  • Just utilizing the entirety of the Bootstrap CSS certainly makes for the easiest implementation. But considering the above you would see better performance by stripping down the CSS to the minimum rules required for the document.

bsweeney avatar Jun 19 '25 14:06 bsweeney

I added a section here: https://github.com/dompdf/dompdf/wiki/Common-Use-Cases#using-css-frameworks-like-bootstrap-or-tailwind

Please take a look! I left two questions (and the "Under construction" note on top) in there - please edit/remove them!

ThomasLandauer avatar Jun 20 '25 13:06 ThomasLandauer