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

fix: svg images bottom part is missing #64

Closed
wants to merge 6 commits into from
Closed
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
59 changes: 55 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,62 @@ LABEL maintainer="SBB Polarion Team <polarion-opensource@sbb.ch>"

ARG APP_IMAGE_VERSION

# Architecture from --platform (arm64, amd64 etc.)
ARG TARGETARCH

ARG CHROMIUM_VERSION=126.0.6478.182-1~deb12u1

RUN apt-get update && \
apt-get --yes --no-install-recommends install chromium fonts-dejavu fonts-liberation libpango-1.0-0 libpangoft2-1.0-0 python3-brotli python3-cffi && \
apt-get clean autoclean && \
apt-get --yes autoremove && \
rm -rf /var/lib/apt/lists/*
apt-get --no-install-recommends --yes install fonts-dejavu fonts-liberation libpango-1.0-0 libpangoft2-1.0-0 python3-brotli python3-cffi && \
# Chromium dependencies
apt-get --no-install-recommends --yes install \
dbus \
libasound2 \
libatk-bridge2.0-0 \
libatk1.0-0 \
libatomic1 \
libatspi2.0-0 \
libcairo2 \
libcups2 \
libdav1d6 \
libdbus-1-3 \
libdouble-conversion3 \
libevent-2.1-7 \
libflac12 \
libgbm1 \
libglib2.0-0 \
libgtk-3-0 \
libharfbuzz-subset0 \
libjpeg62-turbo \
libjsoncpp25 \
liblcms2-2 \
libminizip1 \
libnss3 \
libopenh264-7 \
libopenjp2-7 \
libopus0 \
libpulse0 \
libsnappy1v5 \
libwoff1 \
libx11-xcb1 \
libxdamage1 \
libxkbcommon0 \
libxnvctrl0 \
libxslt1.1 \
vim \
wget \
x11-utils \
xdg-utils && \
# Download Chromium (urls taken from https://snapshot.debian.org/archive/debian/20240820T082737Z/pool/main/c/chromium/)
wget -P /tmp https://snapshot.debian.org/archive/debian/20240820T082737Z/pool/main/c/chromium/chromium_${CHROMIUM_VERSION}_${TARGETARCH}.deb && \
wget -P /tmp https://snapshot.debian.org/archive/debian/20240825T022815Z/pool/main/c/chromium/chromium-common_${CHROMIUM_VERSION}_${TARGETARCH}.deb && \
# Install the downloaded packages
# DO NOT USE """|| apt-get install -f -y""" COZ THIS CAN FORCE TO UPDATE CHROMIUM TO THE LATEST VERSION
dpkg -i /tmp/chromium-common_${CHROMIUM_VERSION}_${TARGETARCH}.deb /tmp/chromium_${CHROMIUM_VERSION}_${TARGETARCH}.deb && \
# Clean up to reduce image size
apt-get -y autoremove && \
apt-get -y clean && \
rm -rf /tmp/* /var/lib/apt/lists/* /var/tmp/*

ENV WORKING_DIR=/opt/weasyprint
ENV CHROME_EXECUTABLE_PATH=/usr/bin/chromium
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ Service providing REST API to use WeasyPrint functionality

```bash
docker build \
--build-arg APP_IMAGE_VERSION=62.4.0 \
--build-arg APP_IMAGE_VERSION=62.4.3 \
--file Dockerfile \
--tag weasyprint-service:62.4.0 .
--tag weasyprint-service:62.4.3 .
```

## Start Docker container
Expand All @@ -16,7 +16,7 @@ Service providing REST API to use WeasyPrint functionality
docker run --detach \
--publish 9080:9080 \
--name weasyprint-service \
weasyprint-service:62.4.0
weasyprint-service:62.4.3
```

## Stop Docker container
Expand Down
3 changes: 2 additions & 1 deletion app/SvgUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,14 @@ def replace_svg_with_png(svg_content):
png_filepath = os.path.join(temp_folder, uuid + '.png')
result = subprocess.run([
f'{chrome_executable}',
'--headless',
'--headless=old',
'--no-sandbox',
'--disable-gpu',
'--disable-software-rasterizer',
'--disable-dev-shm-usage',
'--default-background-color=00000000',
'--hide-scrollbars',
'--enable-features=ConversionMeasurement,AttributionReportingCrossAppWeb',
f'--screenshot={png_filepath}',
f'--window-size={width},{height}',
f'{svg_filepath}',
Expand Down
Loading