This commit is contained in:
2026-01-20 20:24:13 -07:00
commit 885280cf37
5 changed files with 62 additions and 0 deletions

15
README.md Normal file
View File

@@ -0,0 +1,15 @@
# HTML to PDF
## Usage
1. Run the setup script on a debian machine (tested on a debian 13 LXC container)
2. You need to set the parameters in the gen.sh file to match your environmnet.
3. Use either of the following syntax:
```bash
./gen.sh my-file.html
```
```
./gen.sh oliveratkinson.net
```

4
extension/inject.css Normal file
View File

@@ -0,0 +1,4 @@
@page {
margin: 0;
}

13
extension/manifest.json Normal file
View File

@@ -0,0 +1,13 @@
{
"name": "Print CSS",
"description": "Change the default print css for pages",
"version": "1.0",
"manifest_version": 3,
"content_scripts": [
{
"matches": ["<all_urls>"],
"css" : ["inject.css"]
}
]
}

26
gen.sh Executable file
View File

@@ -0,0 +1,26 @@
DEV="192.168.1.179"
USER="chrome"
CHROME="/home/chrome/chrome/linux-144.0.7559.96/chrome-linux64/chrome"
KEYFILE="chrome"
if [[ -z $1 ]]; then
echo Requires argument
exit 1
fi
PRINT=""
if [[ $(printf $1 | tail -c 4) = "html" ]]; then
scp -i $KEYFILE $1 $USER@$DEV:/tmp/input.html
echo html;
PRINT="/tmp/input.html"
else
# This might be a bad idea, idk
echo Assuming argument 1 is a url: $1
PRINT=$1
fi
scp -i $KEYFILE -r extension $USER@$DEV:~/
ssh -i $KEYFILE $USER@$DEV $CHROME --headless=new --no-pdf-header-footer --print-to-pdf --load-extension="/home/$USER/extension" $PRINT
scp -i $KEYFILE $USER@$DEV:~/*.pdf ./

4
setup.sh Executable file
View File

@@ -0,0 +1,4 @@
#!/bin/bash
apt update
apt install npm libnspr4 libss3 libatk1.0-0 libatk-bridge2.0-0 libcups2 libxkbcommon-x11-0 libxdamage1 libcario2 libpango-1.0-0 libasound2
npx @puppeteer/browsers install chrome@stable