Append % if type is "pct" (WidthType.PERCENTAGE)

This commit is contained in:
Andrey Savin
2021-09-28 15:57:33 +03:00
parent 4c58e3c47d
commit 28233075bd

View File

@ -38,6 +38,10 @@ export class TableWidthElement extends XmlComponent {
constructor(name: string, { type = WidthType.AUTO, size }: ITableWidthProperties) {
super(name);
// super("w:tblW");
this.root.push(new TableWidthAttributes({ type: type, size: measurementOrPercentValue(size) }));
let tableWidthValue = size;
if (type === WidthType.PERCENTAGE && typeof size === "number") {
tableWidthValue = `${size}%`;
}
this.root.push(new TableWidthAttributes({ type: type, size: measurementOrPercentValue(tableWidthValue) }));
}
}