|
151 | 151 | } |
152 | 152 |
|
153 | 153 | @media print { |
| 154 | + @page gs-landscape { |
| 155 | + size: landscape; |
| 156 | + } |
| 157 | + @page gs-portrait { |
| 158 | + size: portrait; |
| 159 | + } |
| 160 | + |
| 161 | + /* Use native CSS Grid instead of floats for printing to perfectly respect |
| 162 | + visual coordinates and dimensions while maintaining layout flow */ |
154 | 163 | .grid-stack { |
| 164 | + display: grid !important; |
| 165 | + grid-template-columns: repeat(var(--gs-columns, 12), minmax(0, 1fr)) !important; |
| 166 | + grid-auto-rows: var(--gs-cell-height) !important; |
155 | 167 | height: auto !important; |
156 | 168 | } |
157 | 169 | .grid-stack > .grid-stack-item { |
158 | 170 | position: relative !important; |
| 171 | + float: none !important; |
| 172 | + width: auto !important; |
| 173 | + height: auto !important; |
159 | 174 | left: auto !important; |
160 | 175 | top: auto !important; |
161 | | - float: left; |
| 176 | + |
| 177 | + /* Apply GS coordinates natively via the injected CSS vars */ |
| 178 | + grid-column-start: calc(var(--gs-x) + 1) !important; |
| 179 | + grid-column-end: span var(--gs-w) !important; |
| 180 | + grid-row-start: calc(var(--gs-y) + 1) !important; |
| 181 | + grid-row-end: span var(--gs-h) !important; |
162 | 182 | } |
163 | 183 | .grid-stack > .grid-stack-item[gs-page-break="true"] { |
164 | 184 | page-break-before: always !important; |
165 | 185 | break-before: page !important; |
166 | | - float: none !important; |
167 | | - clear: both !important; |
| 186 | + } |
| 187 | + .grid-stack > .grid-stack-item[gs-print-hide="true"] { |
| 188 | + display: none !important; |
| 189 | + } |
| 190 | + .grid-stack > .grid-stack-item[gs-print-orientation="landscape"] { |
| 191 | + page: gs-landscape; |
| 192 | + /* Force item to take proper landscape width, overriding portrait grid track sizing. |
| 193 | + vmax ensures we get the long edge of the paper regardless of default printer orientation */ |
| 194 | + min-width: calc(100vmax * var(--gs-w) / var(--gs-columns, 12)) !important; |
| 195 | + } |
| 196 | + .grid-stack > .grid-stack-item[gs-print-orientation="portrait"] { |
| 197 | + page: gs-portrait; |
| 198 | + /* vmin ensures we get the short edge of the paper */ |
| 199 | + min-width: calc(100vmin * var(--gs-w) / var(--gs-columns, 12)) !important; |
168 | 200 | } |
169 | 201 | } |
0 commit comments