143143 :origin-width =" object.originWidth"
144144 :origin-height =" object.originHeight"
145145 :page-scale =" pagesScale[pIndex]"
146- :page -width =" pageSizes[pIndex + 1].width "
147- :page -height =" pageSizes[pIndex + 1].height "
146+ :canvas -width =" object.canvasWidth "
147+ :canvas -height =" object.canvasHeight "
148148 @onUpdate =" updateObject(object.id, $event)"
149149 @onDelete =" deleteObject(object.id)" />
150150 </div >
161161 :font-family =" object.fontFamily"
162162 :current-page =" object.currentPage"
163163 :page-scale =" pagesScale[pIndex]"
164- :page -width =" pageSizes[pIndex + 1].width "
165- :page -height =" pageSizes[pIndex + 1].height "
164+ :canvas -width =" object.canvasWidth "
165+ :canvas -height =" object.canvasHeight "
166166 @onUpdate =" updateObject(object.id, $event)"
167167 @onDelete =" deleteObject(object.id)"
168168 @onSelectFont =" selectFontFamily" />
176176 :origin-width =" object.originWidth"
177177 :origin-height =" object.originHeight"
178178 :page-scale =" pagesScale[pIndex]"
179- :page -width =" pageSizes[pIndex + 1].width "
180- :page -height =" pageSizes[pIndex + 1].height "
179+ :canvas -width =" object.canvasWidth "
180+ :canvas -height =" object.canvasHeight "
181181 @onUpdate =" updateObject(object.id, $event)"
182182 @onDelete =" deleteObject(object.id)" />
183183 </div >
@@ -332,7 +332,6 @@ export default {
332332 pdfDocument: null ,
333333 pages: [],
334334 pagesScale: [],
335- pageSizes: [],
336335 allObjects: [],
337336 currentFont: ' Courier' ,
338337 focusId: null ,
@@ -483,7 +482,6 @@ export default {
483482 this .pdfDocument = null
484483 this .pages = []
485484 this .pagesScale = []
486- this .pageSizes = []
487485 this .allObjects = []
488486 },
489487 async addPDF (file ) {
@@ -527,7 +525,6 @@ export default {
527525 width: measurement[2 ],
528526 height: measurement[3 ],
529527 }
530- this .pageSizes [page .pageNumber ] = data .measurement [page .pageNumber ]
531528 })
532529 this .$emit (' pdf-editor:end-init' , data)
533530 }
@@ -570,8 +567,6 @@ export default {
570567 originHeight: height,
571568 canvasWidth,
572569 canvasHeight,
573- pageWidth: this .pageSizes [this .selectedPageIndex + 1 ].width ,
574- pageHeight: this .pageSizes [this .selectedPageIndex + 1 ].height ,
575570 x,
576571 y,
577572 isSealImage,
@@ -592,6 +587,12 @@ export default {
592587 addTextField (text = ' Please enter here' , x = 0 , y = 0 , currentPage = this .selectedPageIndex ) {
593588 const id = this .genID ()
594589 fetchFont (this .currentFont )
590+
591+ const { canvasWidth , canvasHeight }
592+ = this .$refs [
593+ ` page${ this .selectedPageIndex } `
594+ ][0 ].getCanvasMeasurement ()
595+
595596 const object = {
596597 id,
597598 text,
@@ -600,8 +601,8 @@ export default {
600601 width: 0 , // recalculate after editing
601602 lineHeight: 1.4 ,
602603 fontFamily: this .currentFont ,
603- pageWidth : this . pageSizes [currentPage + 1 ]. width ,
604- pageHeight : this . pageSizes [currentPage + 1 ]. height ,
604+ canvasWidth ,
605+ canvasHeight ,
605606 x,
606607 y,
607608 currentPage,
@@ -617,6 +618,12 @@ export default {
617618
618619 addDrawing (originWidth , originHeight , path , scale = 1 ) {
619620 const id = this .genID ()
621+
622+ const { canvasWidth , canvasHeight }
623+ = this .$refs [
624+ ` page${ this .selectedPageIndex } `
625+ ][0 ].getCanvasMeasurement ()
626+
620627 const object = {
621628 id,
622629 path,
@@ -627,6 +634,8 @@ export default {
627634 originHeight,
628635 width: originWidth * scale,
629636 height: originHeight * scale,
637+ canvasWidth,
638+ canvasHeight,
630639 scale,
631640 }
632641 this .addObject (object)
0 commit comments