| 35 | |
| 36 | // Helper: Get body dimensions and check for overflow |
| 37 | async function getBodyDimensions(page) { |
| 38 | const bodyDimensions = await page.evaluate(() => { |
| 39 | const body = document.body; |
| 40 | const style = window.getComputedStyle(body); |
| 41 | |
| 42 | return { |
| 43 | width: parseFloat(style.width), |
| 44 | height: parseFloat(style.height), |
| 45 | scrollWidth: body.scrollWidth, |
| 46 | scrollHeight: body.scrollHeight |
| 47 | }; |
| 48 | }); |
| 49 | |
| 50 | const errors = []; |
| 51 | const widthOverflowPx = Math.max(0, bodyDimensions.scrollWidth - bodyDimensions.width - 1); |
| 52 | const heightOverflowPx = Math.max(0, bodyDimensions.scrollHeight - bodyDimensions.height - 1); |
| 53 | |
| 54 | const widthOverflowPt = widthOverflowPx * PT_PER_PX; |
| 55 | const heightOverflowPt = heightOverflowPx * PT_PER_PX; |
| 56 | |
| 57 | if (widthOverflowPt > 0 || heightOverflowPt > 0) { |
| 58 | const directions = []; |
| 59 | if (widthOverflowPt > 0) directions.push(`${widthOverflowPt.toFixed(1)}pt horizontally`); |
| 60 | if (heightOverflowPt > 0) directions.push(`${heightOverflowPt.toFixed(1)}pt vertically`); |
| 61 | const reminder = heightOverflowPt > 0 ? ' (Remember: leave 0.5" margin at bottom of slide)' : ''; |
| 62 | errors.push(`HTML content overflows body by ${directions.join(' and ')}${reminder}`); |
| 63 | } |
| 64 | |
| 65 | return { ...bodyDimensions, errors }; |
| 66 | } |
| 67 | |
| 68 | // Helper: Validate dimensions match presentation layout |
| 69 | function validateDimensions(bodyDimensions, pres) { |