Skip to content

Commit

Permalink
refactor single-page pdf generator
Browse files Browse the repository at this point in the history
  • Loading branch information
LouisSzeto committed Oct 1, 2024
1 parent 19f0a93 commit 7774690
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/html_generation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ jobs:
- name: Install dependencies (apt-get)
run: |-
sudo apt-get update
sudo apt-get install -y libmagickwand-dev wkhtmltopdf
wget http://archive.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.1_1.1.1f-1ubuntu2_amd64.deb
sudo dpkg -i libssl1.1_1.1.1f-1ubuntu2_amd64.deb
sudo apt install -y build-essential xorg libssl-dev libxrender-dev wget
wget "https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox_0.12.6-1.bionic_amd64.deb"
sudo apt install -y ./wkhtmltox_0.12.6-1.bionic_amd64.deb
- name: Install dependencies (pip)
run: |-
Expand Down
2 changes: 1 addition & 1 deletion code-generators/SinglePageDocGenerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ def WriteToHtmlFile(content: str, name: str) -> Path:
def PdfConversion(html_path: Union[Path, str], language: str, css: Union[str, List[str]] = None) -> None:
try:
pdf_name = f'{str(html_path)[:-5]}-{"CSharp" if language == "csharp" else "Python"}.pdf'
pdfkit.from_file(str(html_path), pdf_name, css=f'{css}/pdf-styles-{language}.css')
pdfkit.from_file(str(html_path), pdf_name, css=f'{css}/pdf-styles-{language}.css', options={"image-quality": 50})
print(f"PdfConversion(): Successfully converting {html_path} to {pdf_name}")
except Exception as e:
# Do not break with raising exceptions in case due to warnings
Expand Down

0 comments on commit 7774690

Please sign in to comment.