<script setup>
import { VuePDF, usePDF } from '@tato30/vue-pdf'
import '@tato30/vue-pdf/style.css'

const props = defineProps({
  url: String
})

const { pdf } = usePDF(props.url)

const pdfPreviewRef = ref(null)
const pdfPreviewWidth = ref(900)
onMounted(() => {
  if(pdfPreviewRef.value) {
    pdfPreviewWidth.value = Number(pdfPreviewRef.value.offsetWidth || 900)
  }
})
</script>

<template>
  <div ref="pdfPreviewRef" class="w-100pct">
    <VuePDF :pdf="pdf" :width="pdfPreviewWidth" />
  </div>
</template>