Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update pdf-chrome derivative #248

Merged
merged 9 commits into from
May 2, 2024
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ jobs:
pip install libpff-python==20211114
- name: Test with pytest
run: |
pytest -vv
pytest -vv
5 changes: 4 additions & 1 deletion docs/installing_mailbagit/pdf.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,23 @@ Installing [wkhtmltopdf](https://wkhtmltopdf.org/) and adding `wkhtmltopdf` or `

## Chrome Headless

Installing [Google Chrome](https://www.google.com/chrome/) and adding `chrome`, `chrome.exe` or `google-chrome` to your `PATH` will make the `pdf-chrome` derivative option available. If you have Google Chrome installed already, you may just need to add it to your `PATH`.
Installing [Google Chrome](https://www.google.com/chrome/) and adding `chrome`, `chrome.exe,` `google-chrome,` or `Google Chrome` to your `PATH` will make the `pdf-chrome` derivative option available. If you have Google Chrome installed already, you may just need to add it to your `PATH`.

For Windows, Chrome usually installs in one of these locations by default:
```
C:\Program Files\Google\Chrome\Application
C:\Program Files (x86)\Google\Chrome\Application
```

For Macs, the usual install path is `/Applications/Google\ Chrome.app/Contents/MacOS/`.

You can test if Chrome is correctly added to your `PATH` by entering the correlating command into a command line terminal:

```
chrome https://archives.albany.edu/mailbag
chrome.exe https://archives.albany.edu/mailbag
google-chrome https://archives.albany.edu/mailbag
Google\ Chrome https://archives.albany.edu/mailbag
```

If any of these commands open a Chrome browser window, you're all set!
4 changes: 2 additions & 2 deletions mailbagit/derivatives/pdf_chrome.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
skip_registry = False

try:
chromes = ["google-chrome", "chrome.exe", "chrome"]
chromes = ["google-chrome", "Google Chrome", "chrome.exe", "chrome"]
chrome = next((c for c in chromes if distutils.spawn.find_executable(c)), None)
skip_registry = True if chrome is None else False

Expand Down Expand Up @@ -72,7 +72,7 @@ def do_task_per_message(self, message):
"--headless",
"--run-all-compositor-stages-before-draw",
"--disable-gpu",
"--print-to-pdf-no-header",
"--no-pdf-header-footer",
"--print-to-pdf=" + os.path.abspath(pdf_name),
os.path.abspath(html_name),
]
Expand Down