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
Comment #2
markfien commentedComment #3
flashwebcenterHello,
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.
Comment #4
markfien commentedSo 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.
Comment #5
flashwebcenterHello,
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
Comment #6
flashwebcenterHello,
I debugged the page https://d9.schoolboard.net/print/pdf/node/19/debug and I don't see the CSS file.
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.
But when I print example.com/print/pdf/node/57 I don't see the style applied to the exported PDF.
I also was able to customize the view mode to print the body only.
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
Comment #7
markfien commentedIf 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.
Comment #8
flashwebcenterHello,
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
Comment #9
flashwebcenterComment #11
flashwebcenter