-
The official example of rendering the entire pdf is a bit slow. I want to use the windowing/list virtualization technique, such that only the visible portion is rendered. To do this, I need to know the dimensions of each page. is there an api for that? Thanks |
Beta Was this translation helpful? Give feedback.
Answered by
TaTo30
Dec 11, 2024
Replies: 1 comment 1 reply
-
Use the The <script setup lang="ts">
import pdf14 from "@samples/45.pdf";
import { usePDF } from "@tato30/vue-pdf";
import { watch } from "vue";
const { pdf, pages } = usePDF(pdf14);
async function getPagesDimensions() {
const pdfDocument = await pdf.value!.promise!;
for (let index = 1; index <= pages.value; index++) {
const pdfPage = await pdfDocument.getPage(index);
const pageBounds = pdfPage.getViewport({ scale: 1 });
console.log(pageBounds);
}
}
watch(pdf, () => {
getPagesDimensions();
});
</script>
<template>
<div>Template</div>
</template>
|
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
shi-yan
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Use the
pdf.js
api directly.The
pdf
value returned byusePDF
is aPDFDocumentLoadingTask
object, so in your case this should works: