This is a common issue with Safari’s handling of print styles when using flex layouts and explicit heights. In your case, the combination of the flex container with a fixed height (100vh) and the print-specific rules (like page-break-inside: avoid) is causing each chart area to be treated as if it should fill a whole page. Here are a few suggestions to get the printed output to match what you see on the screen:
Since the main container uses height: 100vh (and possibly other fixed heights), override those in your print stylesheet so that elements can flow naturally. For example, add:
html, body, #chartContainer, .plot-container {
The rule page-break-inside: avoid can force entire containers to stick together, sometimes causing unexpected page breaks or stretching. You might try removing or modifying this rule:
.plot-container, .chart-area {
/* Either remove or change to auto */
Flexbox can sometimes interfere with print layouts. If possible, consider removing or overriding flex-related properties for print:
div[style*="display: flex"] {
display: block !important;
Ensure that containers aren’t set to hide overflow on print. You already set overflow: visible for some elements, but double-check that no container is inadvertently clipping content.
You can also specify page margins using the @page rule:
Safari’s PDF export can behave unexpectedly when print styles force each element to be a “page.” Overriding the fixed heights and modifying the page-break and flexbox rules should allow the page to print as it appears on screen. You may need to tweak these suggestions to fit your exact layout, but removing the constraints that force each chart area into its own page is the key.
Give these changes a try, and if you still experience issues, consider testing in a different browser’s print-to-PDF functionality to help narrow down whether it’s a Safari-specific quirk.