feat:adjust margins when paper direction change
This commit is contained in:
@@ -405,8 +405,7 @@ export class CommandAdapt {
|
||||
const { startIndex, endIndex } = this.range.getRange()
|
||||
if (!~startIndex && !~endIndex) return
|
||||
const elementList = this.draw.getElementList()
|
||||
const { width, margins } = this.options
|
||||
const innerWidth = width - margins[1] - margins[3]
|
||||
const innerWidth = this.draw.getInnerWidth()
|
||||
// colgroup
|
||||
const colgroup: IColgroup[] = []
|
||||
const colWidth = innerWidth / col
|
||||
@@ -1460,7 +1459,7 @@ export class CommandAdapt {
|
||||
}
|
||||
|
||||
public getPaperMargin(): number[] {
|
||||
return this.draw.getOriginalMargins()
|
||||
return this.options.margins
|
||||
}
|
||||
|
||||
public setPaperMargin(payload: IMargin) {
|
||||
|
||||
@@ -225,16 +225,20 @@ export class Draw {
|
||||
}
|
||||
|
||||
public getOriginalInnerWidth(): number {
|
||||
const { width, margins } = this.options
|
||||
const width = this.getOriginalWidth()
|
||||
const margins = this.getOriginalMargins()
|
||||
return width - margins[1] - margins[3]
|
||||
}
|
||||
|
||||
public getMargins(): IMargin {
|
||||
return <IMargin>this.options.margins.map(m => m * this.options.scale)
|
||||
return <IMargin>this.getOriginalMargins().map(m => m * this.options.scale)
|
||||
}
|
||||
|
||||
public getOriginalMargins(): number[] {
|
||||
return this.options.margins
|
||||
const { margins, paperDirection } = this.options
|
||||
return paperDirection === PaperDirection.VERTICAL
|
||||
? margins
|
||||
: [margins[1], margins[2], margins[3], margins[0]]
|
||||
}
|
||||
|
||||
public getPageGap(): number {
|
||||
|
||||
Reference in New Issue
Block a user