<template>
<UCard >
<div class="h-full space-y-5">
<div ref="pdfSection" class="bg-white h-full">
<p class="text-gray-900">{{ props.data }}</p>
</div>
<UButton @click="createPDF(pdfSection as HTMLElement)" size="lg" label="Baixar PDF" block />
</div>
</UCard>
</template>
<script setup lang="ts">
const pdfSection = ref<HTMLElement | null>(null)
interface Props {
data: any,
}
const props = defineProps<Props>()
const createPDF = (HTMLElement: HTMLElement) => {
exportToPDF('pdf_protected_export.pdf', HTMLElement,
{
encryption: {
ownerPassword: 'test',
userPassword: 'test2',
userPermissions: ['print']
}
}, {
html2canvas: {
scale: 0.7,
useCORS: true
}
})
}
</script>
I created this code based on the test environment present at "https://github.com/sidebase/nuxt-pdf/blob/main/playground/pages/client.vue"