Skip to content

Commit c298d86

Browse files
authored
Merge pull request #76 from LibreSign/feature/send-page-dimension-to-parent
Send page dimension to parent
2 parents 7dd2881 + 5860e7c commit c298d86

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@libresign/vue-pdf-editor",
33
"description": "vue2 pdf editor component",
4-
"version": "1.2.5",
4+
"version": "1.2.6",
55
"author": "LibreCode",
66
"private": false,
77
"main": "dist/vue-pdf-editor.umd.js",

src/VuePdfEditor.vue

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -379,12 +379,6 @@ export default {
379379
fetchFont(this.currentFont)
380380
this.narrowEnlargeShow = true
381381
this.initTextField()
382-
await this.initImages()
383-
this.$emit('pdf-editor:end-init', {
384-
allObjects: this.allObjects,
385-
numPages: this.numPages,
386-
pages: this.pages,
387-
})
388382
} catch (e) {
389383
console.log(e)
390384
}
@@ -508,6 +502,23 @@ export default {
508502
.map((_, i) => this.pdfDocument.getPage(i + 1))
509503
this.allObjects = this.pages.map(() => [])
510504
this.pagesScale = Array(this.numPages).fill(1)
505+
506+
const data = {
507+
allObjects: this.allObjects,
508+
numPages: this.numPages,
509+
pages: this.pages,
510+
measurement: [],
511+
}
512+
// Wait until all pages have been read
513+
const pages = await Promise.all(this.pages);
514+
pages.forEach((page) => {
515+
const measurement = page.getViewport().viewBox
516+
data.measurement[page.pageNumber] = {
517+
width: measurement[2],
518+
height: measurement[3],
519+
}
520+
})
521+
this.$emit('pdf-editor:end-init', data)
511522
}
512523
} catch (e) {
513524
console.log('Failed to add pdf.')

0 commit comments

Comments
 (0)