Skip to content

Commit 03b5e70

Browse files
committed
fix: improve page break handling to keep sections together
1 parent aebf0c1 commit 03b5e70

2 files changed

Lines changed: 42 additions & 0 deletions

File tree

src/renderer/src/styles/print.css

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
@media print {
2+
/* Prevent page breaks inside elements */
23
.prose h1,
34
.prose h2,
45
.prose h3,
@@ -10,6 +11,22 @@
1011
page-break-inside: avoid;
1112
}
1213

14+
/* Keep headings with following content */
15+
.prose h1,
16+
.prose h2,
17+
.prose h3,
18+
.prose h4,
19+
.prose h5,
20+
.prose h6 {
21+
page-break-after: avoid;
22+
}
23+
24+
/* Keep list items together */
25+
.prose ul,
26+
.prose ol {
27+
page-break-inside: avoid;
28+
}
29+
1330
.prose h2 {
1431
font-size: 24pt;
1532
}
@@ -23,6 +40,24 @@
2340
page-break-before: always;
2441
}
2542

43+
/* Keep important sections together */
44+
.notes-section {
45+
page-break-inside: avoid;
46+
}
47+
48+
.doctors-section {
49+
page-break-inside: avoid;
50+
}
51+
52+
.info-table {
53+
page-break-inside: avoid;
54+
}
55+
56+
.header-section {
57+
page-break-inside: avoid;
58+
page-break-after: avoid;
59+
}
60+
2661
@page {
2762
size: A4;
2863
margin-top: 0.75in;

src/renderer/src/styles/screen.css

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,7 @@ body {
537537
/* Notes section styling */
538538
.notes-section {
539539
margin-top: 12px;
540+
page-break-inside: avoid;
540541
}
541542

542543
.section-header {
@@ -545,6 +546,12 @@ body {
545546
padding-bottom: 4px;
546547
margin-bottom: 8px;
547548
font-size: 18px;
549+
page-break-after: avoid;
550+
}
551+
552+
/* Prevent orphaned headers - keep with following content */
553+
.section-header + .prose {
554+
page-break-before: avoid;
548555
}
549556

550557
/* Print button */

0 commit comments

Comments
 (0)