Print.js: ignoreElements are not working when we set scanstyles to false

Created on 4 Oct 2018  Â·  10Comments  Â·  Source: crabbly/Print.js

ignoreElements are not working when we set scanstyles to false. Is there any particular problem with this?

All 10 comments

Hi @KeerthanaNP ,

Thank you for reporting this issue.
What version of the library are you using?

Hi,
I am using v1.0.52 version.
Also, Is there any option to include specific elements? because we need to ignore many id's.

I'm experiencing this same issue. I'm using version 1.0.50.

I still haven't had to the time to test this. It would be helpful is someone could create a fiddle replicating the issue.

@KeerthanaNP The library accepts an array with multiple ids to be ignored. However, you can always expand this by using a CSS print media query. Hiding and showing any elements you may want. The query can be passed directly into the style parameter, or written in your stylesheet file, which then needs to be passed using the css parameter. In fact, until we find and fix this issue, this may be a solution you could implement right away.

Here's a jsfiddle of basically what i've been trying to do. https://jsfiddle.net/wukct8s6/1/

edit: sorry, wrong link.

Thank you, Tyrel.

The issue is because the logic to ignore elements is here:
https://github.com/crabbly/Print.js/blob/master/src/js/functions.js#L43

It needs to be moved out of there, however, we currently can't do that because we use cloneNode to copy the html before printing.
https://github.com/crabbly/Print.js/blob/master/src/js/html.js#L18

I'm planning to get alway from using cloneNode since there are other issues created by it (ex.: #187). Once we do that, and manually copy each element over, we will then be able to move the "ignore" logic here.

Understood.

For now i'm just using the CSS in order to hide elements with display: none;. So that's a work around for now.

Hey guys,
The library has now a custom html processing method which fixed the issue with ignoring element when scanStyles is set to false.
Please run npm update print-js to get its latest version.

Feel free to reopen this if any issues.
Thank you!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

PabloSzx picture PabloSzx  Â·  5Comments

maisumakun picture maisumakun  Â·  5Comments

GuoSirius picture GuoSirius  Â·  8Comments

DouglasOGarrido picture DouglasOGarrido  Â·  3Comments

r3wt picture r3wt  Â·  8Comments