Print.js: Option to ignore HTML elements

Created on 27 May 2017  Â·  7Comments  Â·  Source: crabbly/Print.js

Is there a way to ignore certain other HTML elements whilst using the html type?

I'd like to be able to print a DIV however there is one particular element I'd like to ignore.

enhancement

Most helpful comment

Thinking about implementing this.
How about adding an option within the html function to pass an array of ids for the elements that are supposed to be ignored?

All 7 comments

Hey @Aloogy , the library doesn't have this feature. Interesting idea though. Maybe we could implement it.

Same here, this would be a feature I could use.

Either ignoring elements or being able to include multiple elements.

Thinking about implementing this.
How about adding an option within the html function to pass an array of ids for the elements that are supposed to be ignored?

Yes that would work. So this array of ids are children of the element id (to print)?

Correct.

Awesome, let me know and i'll test it.

Just publish this feature to npm. You can run npm update print-js to get it.
I'll be adding it to the documentation page. We now have an extra parameter ignoreElements, which accepts an array of html element ids that we can tell the library to ignore when printing a parent element.
For ex.:

  printJS({
    printable: 'printElementId',
    type: 'html',
    ignoreElements: ['elementIdToIgnore', 'anotherElementIdToIgnore']
  })

Here is a fiddle as a example:
https://jsfiddle.net/crabbly/tr8btp3s/

Was this page helpful?
0 / 5 - 0 ratings

Related issues

GuoSirius picture GuoSirius  Â·  8Comments

Kreativschnittstelle picture Kreativschnittstelle  Â·  8Comments

raymond8080 picture raymond8080  Â·  4Comments

joster-dev picture joster-dev  Â·  8Comments

DouglasOGarrido picture DouglasOGarrido  Â·  3Comments