Examples
Basic
Company | Contact | Country |
---|---|---|
Alfreds Futterkiste | Maria Anders | Germany |
Centro comercial Moctezuma | Francisco Chang | Mexico |
Ernst Handel | Roland Mendel | Austria |
html
<template>
<div id="print">
<table>
...
</table>
</div>
<button class="print-button" @click="print">
Print
</button>
</template>
<script setup lang="ts">
import { usePaperizer } from 'paperizer'
const { paperize } = usePaperizer('print')
const print = () => {
paperize()
}
</script>
With Custom Styling
Company | Contact | Country |
---|---|---|
Alfreds Futterkiste | Maria Anders | Germany |
Centro comercial Moctezuma | Francisco Chang | Mexico |
Ernst Handel | Roland Mendel | Austria |
html
<template>
<div id="print">
<table class="table table-striped">
...
</table>
</div>
<button class="print-button" @click="print">
Print
</button>
</template>
<script setup lang="ts">
import { usePaperizer } from 'paperizer'
const { paperize } = usePaperizer('print', {
styles: [
'https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css'
]
})
const print = () => {
paperize()
}
</script>
With Print Callback
Company | Contact | Country |
---|---|---|
Alfreds Futterkiste | Maria Anders | Germany |
Centro comercial Moctezuma | Francisco Chang | Mexico |
Ernst Handel | Roland Mendel | Austria |
html
<template>
<div id="print">
<table>
...
</table>
</div>
<button class="print-button" @click="print">
Print
</button>
</template>
<script setup lang="ts">
import { usePaperizer } from 'paperizer'
const callback = () => {
alert('This is a callback!')
}
const { paperize } = usePaperizer('print', {}, callback)
const print = () => {
paperize()
}
</script>