Problem/Motivation

We have integrated Entity Print with the theme. It works and expands a JQuery UI nested paragraphs content and creates a PDF. However, this PDF is not formatted. We created a print.css as described in another thread.

@media print {}

.views-accordion-item .accordion-content {
    display: block !important;
  }

.d8-fade {
    opacity: 1!important;
  }
.main-navigation-wrapper,
#header,
#welcome-text,
#highlighted,
#top-container,
#footer-container,
#bottom-container,
#footer-menu,
#copyright,
.second-sidebar,
.first-sidebar{
  display: none!important;
 }

.w3css-content p {
    margin: 0;
    color: #000!important;
    background-color: #fff!important;
  }
.links li {
    font-weight: bold!important;
  }

However, none of the theme styles are carried over to the print display. How can we integrate the theme with entity print module?

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Comments

markfien created an issue. See original summary.

markfien’s picture

StatusFileSize
new115.07 KB
flashwebcenter’s picture

Assigned: Unassigned » flashwebcenter
StatusFileSize
new37.17 KB
new36.1 KB

Hello,
I created two sub-themes. One for D8w3CSS theme and the second for Bartik. Both sub-themes are not picking any styles. Feel free to download them and test.

markfien’s picture

So you are getting the same result as I am. Does this mean I need to create a .twig file to accomplish that? If so, which D8w3CSS file(s) should I copy to edit as node--contenttype--pdf.html.twig?

If it helps this is the original node - https://d9.schoolboard.net/node/19
and this what I'm trying to style - https://d9.schoolboard.net/print/pdf/node/19/debug

Thank you in advance.

flashwebcenter’s picture

StatusFileSize
new36.84 KB

Hello,

Should I copy to edit as node--contenttype--pdf.html.twig? This will modify the output for the PDF template.
No need for https://www.drupal.org/node/2706755#s-modifying-entity-content
or https://www.drupal.org/node/2706755#s-modifying-pdf-template

I followed the https://www.drupal.org/node/2706755#s-example-themeinfoyml to build a sub-theme for Bartik. The style does not show.
You can contact the module contributor and upload the sub-theme https://www.drupal.org/files/issues/2021-05-08/entity_print_test_theme.zip.

Best wishes,
Alaa

flashwebcenter’s picture

StatusFileSize
new36.09 KB
new177.32 KB
new142.26 KB
new108.81 KB
new134.87 KB

Hello,

I debugged the page https://d9.schoolboard.net/print/pdf/node/19/debug and I don't see the CSS file.

Debug no link

Something is wrong with the entity_print css to the sub-theme.https://www.drupal.org/node/2706755#s-example-themeinfoyml
You can use the sub-theme https://www.drupal.org/files/issues/2021-05-08/markfien.zip and test with.

On my local I have the sub-theme https://www.drupal.org/files/issues/2021-05-08/markfien.zip installed. When I debug the page on my local example.com/print/pdf/node/57/debug I can see the css file.

Debug link

But when I print example.com/print/pdf/node/57 I don't see the style applied to the exported PDF.

Print link

I also was able to customize the view mode to print the body only.

PDF view mode

The style is shown in debug and it is not exported in the pdf. This is happening with Bartik theme and D8w3css theme.

Best wishes,
Alaa

markfien’s picture

StatusFileSize
new146.11 KB

If I might ask a different idea to resolve this. We are considering http://printfriendly.com which used to have a Drupal module and is now an online service. They have custom classes which can be added to control what prints and what does not. Where would we add these classes (see attached)? In the page.html.twig file or do we create a custom twig and if so from what base file?
Thank you.

flashwebcenter’s picture

StatusFileSize
new3.64 KB

Hello,
For the old issue there is similar issue https://www.drupal.org/project/entity_print/issues/3103885.
For the new idea, you can add the classes in page.html.twig. This image will help you to add the css classes to the regions. https://www.drupal.org/files/project-images/drupal8-w3css-theme-color-gu...

Example: The uploaded page.html.twig file will have:

* - page.primary_menu_vertical: print-no
* - page.header: print-no
* - page.primary_menu: print-no
* - page.welcome_text: print-no
* - page.top_first: print-no
* - page.top_second: print-no
* - page.top_third: print-no
* - page.highlighted: print-no
* - page.page_title: print-yes
* - page.breadcrumb: print-yes
* - page.content: print-yes
* - page.sidebar_first: print-no
* - page.sidebar_second: print-no
* - page.bottom_first: print-no
* - page.bottom_second: print-no
* - page.bottom_third: print-no
* - page.bottom_forth: print-no
* - page.footer_first: print-no
* - page.footer_second: print-no
* - page.footer_third: print-no
* - page.footer_menu: print-yes

Best wishes,
Alaa

flashwebcenter’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

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

flashwebcenter’s picture