forked from strictdoc-project/strictdoc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HTML2PDF: System chromedriver for PDF export
PDF export requires chrome/chromedriver. Currently StrictDoc always uses webdriver_manager to download a suitable chromedriver and install in a strictdoc cache subdirectory. There may be reasons to prefer a system installation over an adhoc download (e.g. security policy). Notably Debian provides packages that work out-of-the-box for StrictDoc. GitHub Ubuntu CI images have the upstream version pre installed. This adds an CLI option --chromedriver to select an explicit chromedriver. If not given, strictdoc uses webdriver_manager as usual. To use the Debian package, one would call apt install chromium chromium-driver strictdoc export --fromats=html2pdf --chromedriver=/usr/bin/chromedriver . To use chromedriver from GitHub Ubuntu image, one would call strictdoc export --fromats=html2pdf --chromedriver=$CHROMEWEBDRIVER .
- Loading branch information
Showing
16 changed files
with
116 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
tests/integration/features/html2pdf/06_system_chromedriver/input.sdoc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[DOCUMENT] | ||
TITLE: Dummy Software Requirements Specification #1 | ||
|
||
[FREETEXT] | ||
Hello world! 😊😊😊 | ||
[/FREETEXT] |
5 changes: 5 additions & 0 deletions
5
tests/integration/features/html2pdf/06_system_chromedriver/strictdoc.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
[project] | ||
|
||
features = [ | ||
"HTML2PDF", | ||
] |
16 changes: 16 additions & 0 deletions
16
tests/integration/features/html2pdf/06_system_chromedriver/test.itest
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
REQUIRES: TEST_HTML2PDF | ||
|
||
# FIXME: Getting timeouts on Windows CI all the time. Needs to be checked or tested by users. | ||
REQUIRES: PLATFORM_IS_NOT_WINDOWS | ||
|
||
# GitHub images provide a chromedriver and export installed location, see | ||
# https://github.com/actions/runner-images/blob/main/images/ubuntu/Ubuntu2404-Readme.md#browsers-and-drivers | ||
RUN: STRICTDOC_CACHE_DIR=%strictdoc_cache_dir %strictdoc export %S --formats=html2pdf --chromedriver=%chromedriver --output-dir Output | filecheck %s --dump-input=fail | ||
CHECK: HTML2PDF: JS logs from the print session | ||
CHECK-NOT: HTML2PDF: Chrome Driver available at path: {{.*}}strictdoc_cache{{.*}} | ||
|
||
RUN: %check_exists --file %S/Output/html2pdf/pdf/input.pdf | ||
|
||
RUN: %check_exists --file %S/Output/html2pdf/html/06_system_chromedriver/input.html | ||
|
||
RUN: python %S/test_pdf.py |
8 changes: 8 additions & 0 deletions
8
tests/integration/features/html2pdf/06_system_chromedriver/test_pdf.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from pypdf import PdfReader | ||
|
||
reader = PdfReader("Output/html2pdf/pdf/input.pdf") | ||
|
||
assert len(reader.pages) == 3, reader.pages | ||
|
||
# page2_text = reader.pages[1].extract_text() # noqa: ERA001 | ||
# assert "Table of contents" not in page2_text # noqa: ERA001 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters