Daisy Rees

Daisy Rees


Add CSS to DomPDF

I've got this code to export some data into a pdf. And I would like to add css from an external css file (which is not mentionned in the html used)

/*********************************** Export PDF ****************************************************/
if($request->query->get('exportPDF')!= null){
    // Configure Dompdf according to your needs
    $pdfOptions = new Options();
    $pdfOptions->set('defaultFont', 'Arial');
    // Instantiate Dompdf with our options
    $dompdf = new Dompdf($pdfOptions);
    // Retrieve the HTML generated in our twig file
    $html = $this->renderView('dashboard/user_table.html.twig', [
        'users' => $users
    // Load HTML to Dompdf
    // (Optional) Setup the paper size and orientation 'portrait' or 'portrait'
    $dompdf->setPaper('A3', 'landscape');
    // Render the HTML as PDF
    // Output the generated PDF to Browser (force download)
    $dompdf->stream("exportUsers.pdf", [
        "Attachment" => true

The user_table.html is only a file with a <table>

who has some class from a css file loaded in an other template. That means for DomPDF the file who contains the css is unkown and, as a result I have a table with no css in my pdf. I've tried to add the stylesheet in my html directly but the import isn't working like that neither. But I don't want to add it in the html anyway, the css is loaded is a more hight level template.

How to add external files (like bootstrap etc etc) from this structure ? I do not know if this is even possible. Thanks for the help ;)

#php #symfony

What is GEEK

Buddha Community

Lyly Sara


the css file must be referenced in the HTML you give to DomPDF.

If you don’t want to change your twig template, you can use a workaround like this :

$dompdf = new Dompdf();
$html = $this->renderView('dashboard/user_table.html.twig', [
    'users' => $users
$html .= '<link type="text/css" href="/absolute/path/to/pdf.css" rel="stylesheet" />';

note that adding a link tag to the body is not valid. with the current dompdf version, it works but it may not work in future versions.

Hire CSS Developer

Want to develop a website or re-design using CSS Development?

We build a website and we implemented CSS successfully if you are planning to Hire CSS Developer from HourlyDeveloper.io, We can fill your Page with creative colors and attractive Designs. We provide services in Web Designing, Website Redesigning and etc.

For more details…!!
Consult with our experts:- https://bit.ly/3hUdppS

#hire css developer #css development company #css development services #css development #css developer #css

Alayna  Rippin

Alayna Rippin


Creating a CSS Visual Cheatsheet

The other day one of our students asked about possibility of having a CSS cheatsheet to help to decide on the best suited approach when doing this or that layout.

This evolved into the idea of making a visual CSS cheatsheet with all (most) of the common patterns we see everyday and one of the best possible conceptual implementation for them.

In the end any layout could and should be split into parts/blocks and we see every block separately.

Here is our first take on that and we would be happy to keep extending it to help us all.

Please, send you suggestions in the comments in community or via gitlab for the repeated CSS patterns with your favourite implementation for that so that we will all together make this as useful as it can be.

#css #css3 #cascading-style-sheets #web-development #html-css #css-grids #learning-css #html-css-basics

Aisu  Joesph

Aisu Joesph


CSS Alignment Made Simple

CSS is seen as an impediment in web development for many of us. Most of the time it looks like even when you follow the rules and everything seems clear, it still doesn’t work the way you want it to.

Therefore, the purpose of this article is to make some features of CSS much easier to understand.

The thing I want to address now is the alignment of the elements.

Without further ado, here are some of the most common scenarios one might encounter when it comes to this topic and how they can be approached.

#css-center #css-position #css-flexbox #css-center-image-in-a-div #css

This CSS Cut Out Effect is Guaranteed to Blow Your Mind 🤯

This effect is so cool and just fun to see. What it comes down to is having a background image show through the text.

How it works is that we will have a div that will have the image as a background. On that, we put our text element, using blend-mode it will show through the image.

The result you can see and touch on this Codepen.

#css #css3 #html-css #css-grids #learning-css #html-css-basics

CSS Animation: translate3d, backdrop-filter, and Custom Tags

In this tutorial, we are going to learn:

  • how to create a smooth animation using the CSS transform translate3d prop.
  • why we’d want to use the cubic-bezier transition timing function and this function’s benefits.
  • how and why we use custom tags.
  • if you watch the video to the end, I also provide a bonus tip on using backdrop-filter to style some frost/blur style on background.

#css #css animation #css / style sheets #css animations #css background