Jquery print page in not adding css

  jquery, laravel, printing

I’m trying to print with jquery, the thing is that the css is not getting applied into the pdf file.

This is my code, i’m using Laravel 7 by the way.

Jquery inside blade.php

        $('button[name="print"]').click(function () {
          var stylesheet = '{{ asset("assets/css/print.css") }}';

          var pageTitle = 'CierresReporte',
                      win = window.open('', 'Print', 'width=500,height=300');
                  win.document.write('<html><head><title>' + pageTitle + '</title>' +
                      '<link rel="stylesheet" type="text/css" href="' + stylesheet + '">' +
                      '</head><body>' + $('.table')[0].outerHTML + '</body></html>');
                  return false;

Css file:

@media print {

    th, td {
        font-family: Verdana, Arial, Helvetica, sans-serif;
        font-size: 18px;
        color: #000000;
    tr {
        border: 1px solid gray;
    td {
        width: 200px;
        padding: 3px;
    th {
        background-color: #D2E0E8;
        color: #003366
    table {
        border: 1pt solid gray;
        text-align: center;

I’m even printing the path in the console.log and the path is right. I don’t know what could it be.


Source: Laravel

Leave a Reply