(page, image, sizeRatio, getSize)
| 3282 | |
| 3283 | // `getWidgetPosition` is used to calulcate position of image type widget like x, y, width, height for pdf-lib |
| 3284 | function getWidgetPosition(page, image, sizeRatio, getSize) { |
| 3285 | let pageWidth; |
| 3286 | // pageHeight; |
| 3287 | if ([90, 270].includes(page.getRotation().angle)) { |
| 3288 | pageWidth = getSize?.height || page.getHeight(); |
| 3289 | } else { |
| 3290 | pageWidth = getSize?.width || page.getWidth(); |
| 3291 | } |
| 3292 | // eslint-disable-next-line |
| 3293 | if (!image?.hasOwnProperty("vpWidth")) { |
| 3294 | image["vpWidth"] = pageWidth; |
| 3295 | } |
| 3296 | const pageRatio = pageWidth / (image.vpWidth * sizeRatio); |
| 3297 | const imageWidth = image.width * sizeRatio * pageRatio; |
| 3298 | const imageHeight = image.height * sizeRatio * pageRatio; |
| 3299 | const imageX = image.x * sizeRatio * pageRatio; |
| 3300 | const imageYFromTop = image.y * sizeRatio * pageRatio; |
| 3301 | |
| 3302 | const correction = compensateRotation( |
| 3303 | page.getRotation().angle, |
| 3304 | imageX, |
| 3305 | imageYFromTop, |
| 3306 | 1, |
| 3307 | getSize, |
| 3308 | imageHeight |
| 3309 | ); |
| 3310 | |
| 3311 | return { |
| 3312 | width: imageWidth, |
| 3313 | height: imageHeight, |
| 3314 | x: correction.x, |
| 3315 | y: correction.y, |
| 3316 | rotate: page.getRotation() |
| 3317 | }; |
| 3318 | } |
| 3319 | //function to use calculate pdf rendering scale in the container |
| 3320 | export const getContainerScale = (pdfOriginalWH, pageNumber, containerWH) => { |
| 3321 | const getPdfPageWidth = pdfOriginalWH.find( |
no test coverage detected