Marc Kupietz | ce1aa0c | 2023-06-15 07:50:23 +0200 | [diff] [blame] | 1 | #!/bin/sh -eu |
Marc Kupietz | fcb7d47 | 2025-06-17 18:07:57 +0200 | [diff] [blame^] | 2 | in=$1 |
| 3 | |
| 4 | # Get absolute path to preserve relative links |
| 5 | abs_in=$(realpath "$in") |
| 6 | work_dir=$(dirname "$abs_in") |
| 7 | |
| 8 | # Use Chrome with no shrinking, working from correct directory |
| 9 | cd "$work_dir" |
| 10 | R -e "pagedown::chrome_print('$(basename "$abs_in")', |
| 11 | options=list( |
| 12 | pageRanges='1', |
| 13 | paperWidth=33.11, |
| 14 | paperHeight=46.81, |
| 15 | marginTop=0, |
| 16 | marginBottom=0, |
| 17 | marginLeft=0, |
| 18 | marginRight=0, |
| 19 | printBackground=TRUE, |
| 20 | scale=0.98, # Compensate for ~2% print scaling |
| 21 | displayHeaderFooter=FALSE, |
| 22 | preferCSSPageSize=TRUE |
| 23 | ), |
| 24 | extra_args = c( |
| 25 | '--disable-gpu', |
| 26 | '--no-sandbox', |
| 27 | '--disable-dev-shm-usage', |
| 28 | '--force-device-scale-factor=1', |
| 29 | '--disable-print-preview', |
| 30 | '--disable-background-timer-throttling', |
| 31 | '--allow-file-access-from-files', |
| 32 | '--force-color-profile=srgb', |
| 33 | '--disable-lcd-text', |
| 34 | '--disable-font-subpixel-positioning', |
| 35 | '--run-all-compositor-stages-before-draw' |
| 36 | ) |
| 37 | )" |