vue-html2pdf-demo icon indicating copy to clipboard operation
vue-html2pdf-demo copied to clipboard

Is there any way to show the div into pdf only ?

Open tamanna-makkar opened this issue 5 years ago • 3 comments

Is there any way to show the div into the pdf only not into the actual document Please suggest

tamanna-makkar avatar Nov 05 '20 11:11 tamanna-makkar

You could use a component for that with props lets say is-for-pdf for example. If is-for-pdf is true show that div.

So the template would look like this:

<template>
   <div>
        <your-pdf-component />

        <vue-html2pdf>
             <your-pdf-component :is-for-pdf="true" slot="pdf-content">
        </vue-html2pdf>
   </div>
</template

Also please create your issues in the link below next time, This is the demo repository of the package, thanks. https://github.com/kempsteven/vue-html2pdf/issues

kempsteven avatar Nov 05 '20 22:11 kempsteven

@kempsteven Thanks for the revert I have tried for the same, :is-for-pdf="true" but it is also showing into the document I wanted the component to hide from the actual document and only show into the pdf

tamanna-makkar avatar Nov 06 '20 06:11 tamanna-makkar

Ummm, inside <your-pdf-component>, you have to utilize that is-for-pdf props.

So inside your component it should look like this:

<template>
   <div>
       <div class="only-show-in-pdf" v-if="isForPpdf">
            Show this on pdf only
       </div>

       <div>Show everytime</div>
   </div>
</template

exports default {
    props: {
       isForPpdf: {
           type: Boolean,
           default: false
       }
    }
}

If you are still having problems with it I suggest you read into the vue.js documentation since this is a vue.js question, but feel free to ask more questions to me.

kempsteven avatar Nov 06 '20 08:11 kempsteven