Skip to content

Some elements of long table missing #80

Description

@d-vesely

I have a markdown with a long table. In the resulting PDF, some values are cut off. I have tried to track down to the cause of this issue via trial-and-error, but I am not sure. It definitely stems from the CSS, but it seems to be a combination of styles that can cause this issue. With the markdown, css and python code below, the issue can be reproduced. For example, in the CSS below, when removing the font-size for h1 and h2, all table elements are displayed in the PDF. Otherwise, some elements are cut off.

Markdown:

# Header

## Long Table

| File                                                                 | Result |
| -------------------------------------------------------------------- | ------ |
| 2025-06-27T10-53-25Z_bd237f0f-09d7-4d25-bda6-a3781b5e0e9a_input.json | **OK** |
| 2025-06-27T10-30-23Z_6a7a664a-c0ab-417b-b049-99ae14f4b336_input.json | **OK** |
| 2025-06-27T10-53-28Z_f264fc5c-ef02-4735-b3db-96f132021b85_input.json | **OK** |
| 2025-06-27T10-53-32Z_321f8db0-ba54-4854-a78c-24a540fef886_input.json | **OK** |
| 2025-06-27T10-53-36Z_ae1262cc-0f0a-4f63-ba36-8063904132bb_input.json | **OK** |
| 2025-06-27T10-53-39Z_830bee1b-50cc-40ff-aec3-8fbc5c85b515_input.json | **OK** |
| 2025-06-27T10-53-43Z_542ec173-d16a-4f74-a113-eb5a107a892f_input.json | **OK** |
| 2025-06-27T10-53-47Z_f1ff9131-71df-4ead-9d7c-52f09c053cd7_input.json | **OK** |
| 2025-06-27T10-53-50Z_be9dca91-d8a4-4e28-92f8-8931b6121686_input.json | **OK** |
| 2025-06-27T10-53-54Z_98a2524c-73b8-4ec1-894c-71a14cacc944_input.json | **OK** |
| 2025-06-27T10-53-58Z_177799f3-e828-4f6b-9b7c-74e0aa1671ea_input.json | **OK** |
| 2025-06-27T10-54-01Z_f90a472d-80fb-4441-bae4-4d3e46bd8c52_input.json | **OK** |
| 2025-06-27T10-54-05Z_75240c4b-5dbf-440b-8717-8cd546a1e7b2_input.json | **OK** |

TODO: Extend the table here and add more elements, e.g. 200.
h1 {
    font-size: 16pt;
    font-family: serif;
    color: maroon;
}

h2 {
    font-size: 13pt;
    font-family: serif;
    color: maroon;
}

table {
    font-size: 10pt;
    font-family: serif;
}
pdf = MarkdownPdf(toc_level=0)
pdf_data_path = Path("pdf_data")
style_file_path = Path(pdf_data_path, "style.css")

with style_file_path.open("r") as style_file:
    user_css = style_file.read()

with open("report.md", "r") as report_file:
    report_content = report_file.read()

pdf.add_section(
    Section(report_content),
    user_css=user_css,
)

out_buffer = BytesIO()
pdf.save(out_buffer)
out_buffer.seek(0)
report_pdf_path = Path("report.pdf")
with report_pdf_path.open("wb") as output_file:
    output_file.write(out_buffer.read())

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions