feat(viewer): add PrintMode for browser print/PDF export
Adds RenderOptions.PrintMode flag. When true: - view.js (table filters) is not loaded - window.print() fires on page load - @media print CSS hides filters, collapses grid to single column, adds page-break hints for section cards Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -3,6 +3,7 @@ package viewer
|
|||||||
type pageData struct {
|
type pageData struct {
|
||||||
Title string
|
Title string
|
||||||
HasSnapshot bool
|
HasSnapshot bool
|
||||||
|
PrintMode bool
|
||||||
Error string
|
Error string
|
||||||
NoticeTitle string
|
NoticeTitle string
|
||||||
NoticeBody string
|
NoticeBody string
|
||||||
|
|||||||
@@ -86,6 +86,7 @@ type RenderOptions struct {
|
|||||||
DownloadArchiveLabel string
|
DownloadArchiveLabel string
|
||||||
NoticeTitle string
|
NoticeTitle string
|
||||||
NoticeBody string
|
NoticeBody string
|
||||||
|
PrintMode bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func RenderHTML(snapshot []byte, title string) ([]byte, error) {
|
func RenderHTML(snapshot []byte, title string) ([]byte, error) {
|
||||||
@@ -103,6 +104,7 @@ func RenderHTMLWithOptions(snapshot []byte, title string, opts RenderOptions) ([
|
|||||||
func buildPageData(snapshot []byte, title string, opts RenderOptions) (pageData, error) {
|
func buildPageData(snapshot []byte, title string, opts RenderOptions) (pageData, error) {
|
||||||
page := pageData{
|
page := pageData{
|
||||||
Title: title,
|
Title: title,
|
||||||
|
PrintMode: opts.PrintMode,
|
||||||
NoticeTitle: strings.TrimSpace(opts.NoticeTitle),
|
NoticeTitle: strings.TrimSpace(opts.NoticeTitle),
|
||||||
NoticeBody: strings.TrimSpace(opts.NoticeBody),
|
NoticeBody: strings.TrimSpace(opts.NoticeBody),
|
||||||
DownloadArchiveURL: strings.TrimSpace(opts.DownloadArchiveURL),
|
DownloadArchiveURL: strings.TrimSpace(opts.DownloadArchiveURL),
|
||||||
|
|||||||
@@ -432,3 +432,45 @@ body {
|
|||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ── Print / PDF ──────────────────────────────────── */
|
||||||
|
|
||||||
|
@media print {
|
||||||
|
.page-header {
|
||||||
|
background: #fff;
|
||||||
|
color: #000;
|
||||||
|
padding: 8px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.header-actions {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.page-main {
|
||||||
|
width: 100%;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sections-grid {
|
||||||
|
grid-template-columns: 1fr;
|
||||||
|
}
|
||||||
|
|
||||||
|
.section-card-half,
|
||||||
|
.section-card-full {
|
||||||
|
grid-column: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.section-card {
|
||||||
|
break-inside: avoid;
|
||||||
|
page-break-inside: avoid;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.filter-row {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.data-table tbody tr:hover {
|
||||||
|
background: transparent;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -43,7 +43,8 @@
|
|||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<title>{{ .Title }}</title>
|
<title>{{ .Title }}</title>
|
||||||
<link rel="stylesheet" href="static/view.css">
|
<link rel="stylesheet" href="static/view.css">
|
||||||
<script defer src="static/view.js"></script>
|
{{ if not .PrintMode }}<script defer src="static/view.js"></script>{{ end }}
|
||||||
|
{{ if .PrintMode }}<script>window.onload = function() { window.print(); };</script>{{ end }}
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<header class="page-header">
|
<header class="page-header">
|
||||||
|
|||||||
Reference in New Issue
Block a user