Skip to content

Migration: html2print -> html2pdf4doc #38

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

Merged
merged 1 commit into from
May 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/ci-linux-ubuntu-latest.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: "HTML2PDF on Linux"
name: "HTML2PDF4Doc on Linux"

on:
pull_request:
Expand Down Expand Up @@ -30,21 +30,21 @@ jobs:
run: |
pip install -r requirements.development.txt

- name: Clone HTML2PDF.js
- name: Clone HTML2PDF4Doc.js
run: |
invoke bootstrap
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Install HPDF dependencies.
run: |
python developer/pip_install_html2print_deps.py
python developer/pip_install_html2pdf4doc_deps.py

- name: Run Lint tasks
run: |
invoke lint

- name: Build HTML2PDF.js
- name: Build HTML2PDF4Doc.js
run: |
invoke build

Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/ci-mac.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: "HTML2PDF on macOS"
name: "HTML2PDF4Doc on macOS"

on:
pull_request:
Expand Down Expand Up @@ -30,19 +30,19 @@ jobs:
run: |
pip install -r requirements.development.txt

- name: Clone HTML2PDF.js
- name: Clone HTML2PDF4Doc.js
run: |
invoke bootstrap

- name: Install HPDF dependencies.
run: |
python developer/pip_install_html2print_deps.py
python developer/pip_install_html2pdf4doc_deps.py

- name: Run Lint tasks
run: |
invoke lint

- name: Build HTML2PDF.js
- name: Build HTML2PDF4Doc.js
run: |
invoke build

Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/ci-windows.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# NOTE: In contrast to Linux and macOS, the Windows build machines do not have Chrome installed.

name: "HTML2PDF on Windows"
name: "HTML2PDF4Doc on Windows"

on:
pull_request:
Expand Down Expand Up @@ -39,25 +39,25 @@ jobs:
run: |
pip install -r requirements.development.txt

- name: Clone HTML2PDF.js
- name: Clone HTML2PDF4Doc.js
run: |
invoke bootstrap

- name: Install HPDF dependencies.
run: |
python developer/pip_install_html2print_deps.py
python developer/pip_install_html2pdf4doc_deps.py

- name: Run Lint tasks
run: |
invoke lint

- name: Build HTML2PDF.js
- name: Build HTML2PDF4Doc.js
run: |
invoke build

- name: Download ChromeDriver
run: |
python html2print/html2print.py get_driver
python html2pdf4doc/html2pdf4doc.py get_driver

- name: Run tests (Bash)
run: |
Expand Down
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# HTML2PDF JS file.
# html2print/html2pdf_js/
# HTML2PDF4Doc JS file.
# html2pdf4doc/html2pdf4doc_js/

.idea/
**/.wdm/
Expand Down
10 changes: 5 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ ENV PATH="/opt/venv/bin:$PATH"

# Install StrictDoc. Set default StrictDoc installation from PyPI but allow
# overriding it with an environment variable.
ARG HTML2PRINT_SOURCE="pypi"
ENV HTML2PRINT_SOURCE=${HTML2PRINT_SOURCE}
ARG HTML2PDF4DOC_SOURCE="pypi"
ENV HTML2PDF4DOC_SOURCE=${HTML2PDF4DOC_SOURCE}

RUN if [ "$HTML2PRINT_SOURCE" = "pypi" ]; then \
RUN if [ "$HTML2PDF4DOC_SOURCE" = "pypi" ]; then \
pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir html2print; \
pip install --no-cache-dir html2pdf4doc; \
else \
pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir git+https://github.com/mettta/html2pdf_python.git@${HTML2PRINT_SOURCE}; \
pip install --no-cache-dir git+https://github.com/mettta/html2pdf_python.git@${HTML2PDF4DOC_SOURCE}; \
fi; \
chmod -R 777 /opt/venv;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def check_if_package_installed(package_name: str):


print( # noqa: T201
"pip_install_html2print_deps.py: "
"pip_install_html2pdf4doc_deps.py: "
"checking if the current Python environment has all packages installed"
".",
flush=True,
Expand All @@ -48,7 +48,7 @@ def check_if_package_installed(package_name: str):
check_if_package_installed(dependency)
except PackageNotFound:
print( # noqa: T201
f"pip_install_html2print_deps.py: "
f"pip_install_html2pdf4doc_deps.py: "
f"Package is not installed: '{dependency}'.",
flush=True,
)
Expand All @@ -57,8 +57,8 @@ def check_if_package_installed(package_name: str):
except PackageVersionConflict as exception_:
print( # noqa: T201
(
f"pip_install_html2print_deps.py: version conflict between "
f"html2print's requirement '{dependency}' "
f"pip_install_html2pdf4doc_deps.py: version conflict between "
f"html2pdf4doc's requirement '{dependency}' "
f"and the already installed package: "
f"{exception_.args[0]}."
),
Expand All @@ -69,13 +69,13 @@ def check_if_package_installed(package_name: str):

if not needs_installation:
print( # noqa: T201
"pip_install_html2print_deps.py: all packages seem to be installed.",
"pip_install_html2pdf4doc_deps.py: all packages seem to be installed.",
flush=True,
)
sys.exit(0)

print( # noqa: T201
"pip_install_html2print_deps.py: will install packages.", flush=True
"pip_install_html2pdf4doc_deps.py: will install packages.", flush=True
)

all_packages = "\n".join(dependencies) + "\n"
Expand Down
28 changes: 14 additions & 14 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,41 +15,41 @@ if [ -z "$HOST_UID" ] || [ -z "$HOST_GID" ]; then
exit 1
fi

echo "html2print/docker: running a Docker container entrypoint."
echo "html2print/docker: ensuring html2print user with UID=$HOST_UID and GID=$HOST_GID exists"
echo "html2pdf4doc/docker: running a Docker container entrypoint."
echo "html2pdf4doc/docker: ensuring html2pdf4doc user with UID=$HOST_UID and GID=$HOST_GID exists"

# Check if a user with this UID already exists (e.g., "ubuntu")
EXISTING_USER=$(getent passwd "$HOST_UID" | cut -d: -f1)

if [ -n "$EXISTING_USER" ]; then
echo "error: html2print/docker: detected a wrong user: '$EXISTING_USER'. Ensure that any default users are removed from the Dockerfile. This entrypoint script is supposed to create a new user 'html2print'."
echo "error: html2pdf4doc/docker: detected a wrong user: '$EXISTING_USER'. Ensure that any default users are removed from the Dockerfile. This entrypoint script is supposed to create a new user 'html2pdf4doc'."
exit 1
else
# Ensure the group exists.
EXISTING_GROUP=$(getent group "$HOST_GID" | cut -d: -f1)
if [ -z "$EXISTING_GROUP" ]; then
echo "html2print/docker: creating new group html2print with GID=$HOST_GID"
groupadd -g "$HOST_GID" html2print
echo "html2pdf4doc/docker: creating new group html2pdf4doc with GID=$HOST_GID"
groupadd -g "$HOST_GID" html2pdf4doc
else
echo "html2print/docker: group with GID=$HOST_GID already exists: $EXISTING_GROUP, reusing it."
echo "html2pdf4doc/docker: group with GID=$HOST_GID already exists: $EXISTING_GROUP, reusing it."
fi

# Create the user.
echo "html2print/docker: creating new user html2print with UID=$HOST_UID"
useradd -m -u "$HOST_UID" -g "$HOST_GID" -s /bin/bash html2print
echo "html2pdf4doc/docker: creating new user html2pdf4doc with UID=$HOST_UID"
useradd -m -u "$HOST_UID" -g "$HOST_GID" -s /bin/bash html2pdf4doc

# Give the user root privileges. Useful for debugging.
echo "html2print ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/html2print
echo "html2pdf4doc ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/html2pdf4doc
fi

echo "html2print/docker: show created user info:"
id html2print
echo "html2pdf4doc/docker: show created user info:"
id html2pdf4doc

# Run as the correct user. If no command is provided, run a shell.
if [ $# -eq 0 ]; then
echo "html2print/docker: no command provided, opening an interactive shell."
exec gosu html2print /bin/bash
echo "html2pdf4doc/docker: no command provided, opening an interactive shell."
exec gosu html2pdf4doc /bin/bash
else
# Otherwise, run the provided command.
exec gosu html2print "$@"
exec gosu html2pdf4doc "$@"
fi
Loading