We have an option to include custom css file at admin/config/user-interface/printable, I have provided path as "sites/default/files/test.css", the physical file can be accessed by hitting direct path in the browser. But the file is not getting loaded on print page.

Following is the debug information found:

The function buildContent at printable/src/Plugin/PrintableFormatBase.php is responsible for getting content to be printed. The css file path is getting added correctly in my case at below line 173 :

    if ($include_path = $this->printableCssInclude->getCssIncludePath()) {
      $build['#attached']['css'][] = $include_path;
    }

and include_path variable has correct path (sites/default/files/test.css) as provided in config settings.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

sumanthkumarc created an issue. See original summary.

sumanthkumarc’s picture

Issue summary: View changes
sumanthkumarc’s picture

Issue summary: View changes
sumanthkumarc’s picture

FileSize
1.36 KB

I was not sure why the css didn't get included with the default code, but i used following patch and the css got included in both print and pdf.

sumanthkumarc’s picture

Re-uploading the same patch with correct file name standard.

sriharsha.uppuluri’s picture

Status: Active » Needs review

  • 9e9d7db committed on 8.x-1.x
    Issue #2792323 by sumanthkumarc: Unable to include custom css file...
Nigel Cunningham’s picture

Status: Needs review » Fixed

Thanks for your patch. I've applied it, together with some extra work after testing with updated versions of the 8 libraries. The combined code has been pushed to -dev and will be included in the next release.

mPDF doesn't work perfectly, but my investigation of mPDF this morning has made me realise it has ... issues, so I'll see if anyone cares before spending more time on it. It might be wiser just to remove support for mPDF.

Thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

iancawthorne’s picture

@NigelCunningham Re "mPDF doesn't work perfectly, but my investigation of mPDF this morning has made me realise it has ... issues, so I'll see if anyone cares before spending more time on it. It might be wiser just to remove support for mPDF."

I just wanted to air that this appears to be the best library to use for right to left language support such as Arabic, so I'd put a +1 on keeping mPDF support in that respect.

Nigel Cunningham’s picture

Thanks very much for the feedback. Printable hasn't received a lot of attention for a while now. I'm trying to find the time to get back to it and would have read the above again and applied what was written. Thanks for the extra feedback. Perhaps things have changed since then!

boby_ui’s picture

Priority: Normal » Major

unable to load css and js running inside the page for the current module I tested.