Skip to content

Commit

Permalink
Merge pull request #157 from TaTo30/fix/issue-156
Browse files Browse the repository at this point in the history
Added an auto-destroy prop and destroy method
  • Loading branch information
TaTo30 authored Oct 18, 2024
2 parents 86a0a69 + fb5b44a commit bf25020
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions packages/vue-pdf/src/components/VuePDF.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const props = withDefaults(defineProps<{
width?: number
height?: number
textLayer?: boolean
autoDestroy?: boolean
imageResourcesPath?: string
hideForms?: boolean
intent?: string
Expand All @@ -42,6 +43,7 @@ const props = withDefaults(defineProps<{
page: 1,
scale: 1,
intent: 'display',
autoDestroy: false
})

const emit = defineEmits<{
Expand Down Expand Up @@ -281,10 +283,15 @@ onMounted(() => {

onUnmounted(() => {
// Abort all network process and terminates the worker
props.pdf?.destroy()
if (props.autoDestroy)
props.pdf?.destroy()
})

// Exposed methods
// Exposed method
function destroy() {
props.pdf?.destroy()
}

function reload() {
renderPage(props.page)
}
Expand All @@ -296,6 +303,7 @@ function cancel() {
defineExpose({
reload,
cancel,
destroy
})
</script>

Expand Down

0 comments on commit bf25020

Please sign in to comment.