File tree 2 files changed +14
-2
lines changed
legacy-archive/server/src/pdf
xp-archive/server/src/services
2 files changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -120,8 +120,14 @@ export class PdfGenerator {
120
120
121
121
const widthActual = width >= MIN_WIDTH_PX ? width : DEFAULT_WIDTH_PX ;
122
122
123
+ // Remove header and footer in print
124
+ const htmlWithoutHeaderAndFooter = html . replaceAll (
125
+ / ( < h e a d e r ( [ ^ ; ] * ) < \/ h e a d e r > | < f o o t e r ( [ ^ ; ] * ) < \/ f o o t e r > ) / g,
126
+ ''
127
+ ) ;
128
+
123
129
// Ensures assets with relative urls are loaded from the correct origin
124
- const htmlWithBase = html . replace (
130
+ const htmlWithBase = htmlWithoutHeaderAndFooter . replace (
125
131
'<head>' ,
126
132
`<head><base href="${ process . env . APP_ORIGIN_INTERNAL } "/>`
127
133
) ;
Original file line number Diff line number Diff line change @@ -130,9 +130,15 @@ export class PdfService {
130
130
try {
131
131
const page = await this . browser . newPage ( ) ;
132
132
133
+ // Remove header and footer in print
134
+ const htmlWithoutHeaderAndFooter = html . replaceAll (
135
+ / ( < h e a d e r ( [ ^ ; ] * ) < \/ h e a d e r > | < f o o t e r ( [ ^ ; ] * ) < \/ f o o t e r > ) / g,
136
+ ''
137
+ ) ;
138
+
133
139
await page . setViewport ( { width : widthActual , height : 1024 , deviceScaleFactor : 1 } ) ;
134
140
await page . emulateMediaType ( 'screen' ) ;
135
- await page . setContent ( html ) ;
141
+ await page . setContent ( htmlWithoutHeaderAndFooter ) ;
136
142
137
143
const pdf = await page . pdf ( {
138
144
printBackground : true ,
You can’t perform that action at this time.
0 commit comments