| | |
| | | let width = image.width; |
| | | let height = image.height; |
| | | |
| | | if (width > height && horizontalHeight && height > horizontalHeight && scale) { |
| | | if ( |
| | | width > height && |
| | | horizontalHeight && |
| | | height > horizontalHeight && |
| | | scale |
| | | ) { |
| | | height = horizontalHeight; |
| | | width = horizontalHeight * scale; |
| | | } else if (width <= height && verticalWidth && width > verticalWidth && scale) { |
| | | } else if ( |
| | | width <= height && |
| | | verticalWidth && |
| | | width > verticalWidth && |
| | | scale |
| | | ) { |
| | | width = verticalWidth; |
| | | height = verticalWidth * scale; |
| | | } |
| | |
| | | throw error; |
| | | } |
| | | const zip = new Pizzip(content); |
| | | const imageOptions = getImageOptions(imageSize); |
| | | let doc = new docxtemplater() |
| | | .setOptions({ paragraphLoop: true }) |
| | | .loadZip(zip) |
| | | .attachModule(new ImageModule(imageOptions)) |
| | | .compile(); |
| | | .loadZip(zip); |
| | | |
| | | if (imageSize) { |
| | | const imageOptions = getImageOptions(imageSize); |
| | | doc.attachModule(new ImageModule(imageOptions)); |
| | | } |
| | | doc.compile(); |
| | | doc.resolveData(data).then(() => { |
| | | try { |
| | | doc.render(); |