Skip to content

Commit

Permalink
HTML2PDF: update to include latest fixes, exclude included documents …
Browse files Browse the repository at this point in the history
…from bundle document
  • Loading branch information
stanislaw committed Jan 3, 2025
1 parent 7d3e14a commit 51f9b76
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 1 deletion.
5 changes: 5 additions & 0 deletions strictdoc/core/traceability_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -1088,6 +1088,11 @@ def clone_to_bundle_document(
DocumentCachingIterator(bundle_document)
)
for document_ in traceability_index_copy.document_tree.document_list:
# Ignore all included documents. They are anyway included by
# the including documents.
if document_.document_is_included():
continue

document_.ng_including_document_reference.set_document(
bundle_document
)
Expand Down
3 changes: 2 additions & 1 deletion strictdoc/export/html/_static/html2pdf/bundle.js

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,15 @@ RUN: %check_exists --file %S/Output/html2pdf/html/04_composable_document_with_as
RUN: %check_exists --file %S/Output/html2pdf/html/04_composable_document_with_assets/nested/_assets/file.svg
RUN: %check_exists --file %S/Output/html2pdf/html/04_composable_document_with_assets/nested/subnested/_assets/file.svg

# By default, a bundle document is not generated.
RUN: %check_exists --file --invert %S/Output/html2pdf/pdf/bundle.pdf

RUN: %cat %S/Output/html2pdf/html/04_composable_document_with_assets/nested/subnested/input3.html | filecheck %s --check-prefix CHECK-DOC-HTML
CHECK-DOC-HTML:data="_assets/file.svg"

RUN: python %S/test_pdf.py

RUN: %strictdoc export %S --formats=html2pdf --included-documents --generate-bundle-document --output-dir Output | filecheck %s --dump-input=fail
# With --generate-bundle-document, a bundle document is generated.
RUN: %check_exists --file %S/Output/html2pdf/pdf/bundle.pdf
RUN: python %S/test_bundle_pdf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from pypdf import PdfReader

reader = PdfReader("Output/html2pdf/pdf/bundle.pdf")

assert len(reader.pages) == 5, reader.pages

0 comments on commit 51f9b76

Please sign in to comment.