112112 @mousedown =" selectPage(pIndex)"
113113 @touchstart =" selectPage(pIndex)" >
114114 <div style =" display : inline-block ;"
115- class =" relative shadow-lg"
115+ class =" relative shadow-lg page "
116116 :class =" [pIndex === selectedPageIndex ?'shadowOutline':'']" >
117117 <PDFPage :ref =" `page${pIndex}`"
118118 :scale =" scale"
127127 <slot name =" custom"
128128 :object =" object"
129129 :pagesScale =" pagesScale[pIndex]"
130- :canvas-width =" object.canvasWidth"
131- :canvas-height =" object.canvasHeight"
132130 @onUpdate =" updateObject(object.id, $event)"
133131 @onDelete =" deleteObject(object.id)" />
134132 </div >
143141 :origin-width =" object.originWidth"
144142 :origin-height =" object.originHeight"
145143 :page-scale =" pagesScale[pIndex]"
146- :canvas-width =" object.canvasWidth"
147- :canvas-height =" object.canvasHeight"
148144 @onUpdate =" updateObject(object.id, $event)"
149145 @onDelete =" deleteObject(object.id)" />
150146 </div >
163159 :font-family =" object.fontFamily"
164160 :current-page =" object.currentPage"
165161 :page-scale =" pagesScale[pIndex]"
166- :canvas-width =" object.canvasWidth"
167- :canvas-height =" object.canvasHeight"
168162 @onUpdate =" updateObject(object.id, $event)"
169163 @onDelete =" deleteObject(object.id)"
170164 @onSelectFont =" selectFontFamily" />
178172 :origin-width =" object.originWidth"
179173 :origin-height =" object.originHeight"
180174 :page-scale =" pagesScale[pIndex]"
181- :canvas-width =" object.canvasWidth"
182- :canvas-height =" object.canvasHeight"
183175 @onUpdate =" updateObject(object.id, $event)"
184176 @onDelete =" deleteObject(object.id)" />
185177 </div >
@@ -520,15 +512,17 @@ export default {
520512 measurement: [],
521513 }
522514 // Wait until all pages have been read
523- const pages = await Promise .all (this .pages );
524- pages .forEach ((page ) => {
525- const measurement = page .getViewport ().viewBox
526- data .measurement [page .pageNumber ] = {
527- width: measurement[2 ],
528- height: measurement[3 ],
529- }
530- })
531- this .$emit (' pdf-editor:end-init' , data)
515+ Promise .all (this .pages )
516+ .then (pages => {
517+ pages .forEach ((page ) => {
518+ const measurement = page .getViewport ().viewBox
519+ data .measurement [page .pageNumber ] = {
520+ width: measurement[2 ],
521+ height: measurement[3 ],
522+ }
523+ })
524+ this .$emit (' pdf-editor:end-init' , data)
525+ })
532526 }
533527 } catch (e) {
534528 console .log (' Failed to add pdf.' )
@@ -555,20 +549,13 @@ export default {
555549 const id = this .genID ()
556550 const { width , height } = img
557551
558- const { canvasWidth , canvasHeight }
559- = this .$refs [
560- ` page${ this .selectedPageIndex } `
561- ][0 ].getCanvasMeasurement ()
562-
563552 const object = {
564553 id,
565554 type: ' image' ,
566555 width: width * sizeNarrow,
567556 height: height * sizeNarrow,
568557 originWidth: width,
569558 originHeight: height,
570- canvasWidth,
571- canvasHeight,
572559 x,
573560 y,
574561 isSealImage,
@@ -590,20 +577,13 @@ export default {
590577 const id = this .genID ()
591578 fetchFont (this .currentFont )
592579
593- const { canvasWidth , canvasHeight }
594- = this .$refs [
595- ` page${ this .selectedPageIndex } `
596- ][0 ].getCanvasMeasurement ()
597-
598580 const object = {
599581 id,
600582 text,
601583 type: ' text' ,
602584 size: this .textDefaultSize ,
603585 lineHeight: 1.4 ,
604586 fontFamily: this .currentFont ,
605- canvasWidth,
606- canvasHeight,
607587 x,
608588 y,
609589 currentPage,
@@ -620,11 +600,6 @@ export default {
620600 addDrawing (originWidth , originHeight , path , scale = 1 ) {
621601 const id = this .genID ()
622602
623- const { canvasWidth , canvasHeight }
624- = this .$refs [
625- ` page${ this .selectedPageIndex } `
626- ][0 ].getCanvasMeasurement ()
627-
628603 const object = {
629604 id,
630605 path,
@@ -635,8 +610,6 @@ export default {
635610 originHeight,
636611 width: originWidth * scale,
637612 height: originHeight * scale,
638- canvasWidth,
639- canvasHeight,
640613 scale,
641614 }
642615 this .addObject (object)
0 commit comments