From fb5b44a53b2ab7101043beca177d48846676b300 Mon Sep 17 00:00:00 2001 From: TaTo30 Date: Thu, 17 Oct 2024 21:20:06 -0600 Subject: [PATCH] added an auto-destroy prop and destroy method --- packages/vue-pdf/src/components/VuePDF.vue | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/packages/vue-pdf/src/components/VuePDF.vue b/packages/vue-pdf/src/components/VuePDF.vue index d888c48..f6dbd31 100644 --- a/packages/vue-pdf/src/components/VuePDF.vue +++ b/packages/vue-pdf/src/components/VuePDF.vue @@ -28,6 +28,7 @@ const props = withDefaults(defineProps<{ width?: number height?: number textLayer?: boolean + autoDestroy?: boolean imageResourcesPath?: string hideForms?: boolean intent?: string @@ -42,6 +43,7 @@ const props = withDefaults(defineProps<{ page: 1, scale: 1, intent: 'display', + autoDestroy: false }) const emit = defineEmits<{ @@ -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) } @@ -296,6 +303,7 @@ function cancel() { defineExpose({ reload, cancel, + destroy })