internationalscholarsprogram commited on
Commit
68be85f
·
1 Parent(s): 205c317

fix: label at right:0 inside content area with padding-right, add debug log

Browse files
app/services/pdf_renderer.py CHANGED
@@ -118,6 +118,21 @@ async def render_pdf_from_html(
118
  # Small delay for final layout settle
119
  await page.wait_for_timeout(500)
120
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
121
  # Extract header image src from DOM for Playwright header_template
122
  header_src = await page.evaluate("""
123
  () => {
@@ -147,17 +162,16 @@ async def render_pdf_from_html(
147
  }
148
  """)
149
 
150
- # Expand cover and full-page image elements to fill the
151
- # entire page (including Playwright margin zones). This
152
- # conceals the position:fixed label on those pages while
153
- # keeping it visible on normal content pages (page 3+).
154
  await page.evaluate("""
155
  () => {
156
  document.querySelectorAll('.cover-page, .fullpage-img-wrap').forEach(el => {
157
- el.style.margin = '-2.54cm';
158
- el.style.width = 'calc(100% + 5.08cm)';
159
  el.style.position = 'relative';
160
- el.style.zIndex = '2';
161
  });
162
  }
163
  """)
 
118
  # Small delay for final layout settle
119
  await page.wait_for_timeout(500)
120
 
121
+ # Debug: verify label element presence
122
+ label_info = await page.evaluate("""
123
+ () => {
124
+ const el = document.querySelector('.hb-right-label');
125
+ if (!el) return 'NO .hb-right-label element found';
126
+ const img = el.querySelector('img');
127
+ const src = img ? img.src.substring(0, 80) : 'NO img';
128
+ const loaded = img ? img.complete : false;
129
+ const natW = img ? img.naturalWidth : 0;
130
+ const natH = img ? img.naturalHeight : 0;
131
+ return `label OK: loaded=${loaded}, natural=${natW}x${natH}, src=${src}...`;
132
+ }
133
+ """)
134
+ logger.info("Label check: %s", label_info)
135
+
136
  # Extract header image src from DOM for Playwright header_template
137
  header_src = await page.evaluate("""
138
  () => {
 
162
  }
163
  """)
164
 
165
+ # Hide the label on cover and fullpage image pages.
166
+ # These pages expand to fill the full page so the label
167
+ # should not be visible on them.
 
168
  await page.evaluate("""
169
  () => {
170
  document.querySelectorAll('.cover-page, .fullpage-img-wrap').forEach(el => {
171
+ const overlay = document.createElement('div');
172
+ overlay.style.cssText = 'position:absolute;top:0;right:0;width:2cm;height:100%;background:#fff;z-index:20;';
173
  el.style.position = 'relative';
174
+ el.appendChild(overlay);
175
  });
176
  }
177
  """)
app/static/css/print.css CHANGED
@@ -65,10 +65,10 @@ body {
65
  width: 100%;
66
  max-width: 100%;
67
  margin: 0;
68
- padding: 0;
69
  position: relative;
70
  z-index: 1;
71
- overflow: hidden;
72
  word-wrap: break-word;
73
  overflow-wrap: break-word;
74
  }
@@ -91,19 +91,18 @@ body {
91
  /* ------------------------------
92
  DECORATIVE RIGHT-SIDE LABEL
93
  position:fixed repeats on every printed page.
94
- right:-2.54cm places it in the right margin zone.
95
- Cover / fullpage pages are expanded via JS to
96
- fill margins, concealing the label on those pages.
97
  Original: 43.28cm × 3.31cm → scaled 54% × 50%
98
  = 23.42cm × 1.65cm
99
  ------------------------------ */
100
  .hb-right-label {
101
  position: fixed;
102
  top: 0;
103
- right: -2.54cm;
104
  width: 1.65cm;
105
  height: 23.42cm;
106
- z-index: 0;
107
  pointer-events: none;
108
  overflow: hidden;
109
  }
 
65
  width: 100%;
66
  max-width: 100%;
67
  margin: 0;
68
+ padding: 0 1.85cm 0 0;
69
  position: relative;
70
  z-index: 1;
71
+ overflow: visible;
72
  word-wrap: break-word;
73
  overflow-wrap: break-word;
74
  }
 
91
  /* ------------------------------
92
  DECORATIVE RIGHT-SIDE LABEL
93
  position:fixed repeats on every printed page.
94
+ Placed at right:0 inside the content area.
95
+ page-content gets padding-right to prevent overlap.
 
96
  Original: 43.28cm × 3.31cm → scaled 54% × 50%
97
  = 23.42cm × 1.65cm
98
  ------------------------------ */
99
  .hb-right-label {
100
  position: fixed;
101
  top: 0;
102
+ right: 0;
103
  width: 1.65cm;
104
  height: 23.42cm;
105
+ z-index: 10;
106
  pointer-events: none;
107
  overflow: hidden;
108
  }