File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ """Tables related.
2+
3+ make test T=test_tables.py
4+ """
5+ from . import TestBase
6+
7+
8+ class TestTables (TestBase ):
9+ """Tables content."""
10+
11+ def test_table (self ):
12+ """Convert table content to html."""
13+ from markdown_pdf import Section , MarkdownPdf
14+
15+ text = """
16+ I have some tables content in bellow, but after generate pdf file, table not appear.
17+ | Description | Qty | Unit price | Amount |
18+ |-----------------------------|-----|------------|-----------|
19+ | Premium Plan | 1 | €1,000.00 | €1,000.00 |
20+ | May 24, 2025 – May 24, 2026 | | | |
21+ """
22+ css = """
23+ table {
24+ width: 100%;
25+ border-spacing: 0;
26+ }
27+
28+ th, td {
29+ border: 1px solid #d0d7de;
30+ padding: 8px;
31+ text-align: left;
32+ }
33+
34+ tr {
35+ border-bottom: 1px solid #d0d7de;
36+ }
37+
38+ td {
39+ background-clip: padding-box;
40+ }
41+ """
42+ pdf = MarkdownPdf ()
43+ pdf .add_section (Section (text ), user_css = css )
44+ pdf .save (self .build ("table_css.pdf" ))
You can’t perform that action at this time.
0 commit comments