@@ -183,7 +183,7 @@ const convertMarkdownToPdf = async (markdownFilePath) => {
183183
184184 const puppeteerOptions = {
185185 args : [ '--no-sandbox' , '--disable-setuid-sandbox' ] ,
186- headless : "new"
186+ headless : true // Use boolean for better compatibility with older Puppeteer versions
187187 } ;
188188
189189 // Only specify executablePath if running in Docker
@@ -213,25 +213,37 @@ const convertMarkdownToPdf = async (markdownFilePath) => {
213213 ` ) ;
214214
215215 // Configure the page for better emoji support
216- await page . evaluateHandle ( 'document.fonts.ready' ) ;
216+ try {
217+ // Try to wait for fonts to load
218+ await page . evaluate ( ( ) => {
219+ // This will resolve when fonts are loaded or reject if not supported
220+ return Promise . resolve ( document . fonts . ready ) . catch ( ( ) => Promise . resolve ( ) ) ;
221+ } ) ;
222+ } catch ( err ) {
223+ console . log ( "Font loading check not fully supported, continuing anyway" ) ;
224+ }
217225
218- // Add additional font configuration for emoji support
219- await page . addStyleTag ( {
220- content : `
221- @font-face {
222- font-family: 'Noto Color Emoji';
223- src: local('Noto Color Emoji');
224- }
225-
226- @font-face {
227- font-family: 'Symbola';
228- src: local('Symbola');
229- }
230- `
231- } ) ;
226+ try {
227+ // Add additional font configuration for emoji support
228+ await page . addStyleTag ( {
229+ content : `
230+ @font-face {
231+ font-family: 'Noto Color Emoji';
232+ src: local('Noto Color Emoji');
233+ }
234+
235+ @font-face {
236+ font-family: 'Symbola';
237+ src: local('Symbola');
238+ }
239+ `
240+ } ) ;
241+ } catch ( err ) {
242+ console . log ( "Could not add font configuration:" , err . message ) ;
243+ }
232244
233245 // Ensure fonts are loaded before generating PDF
234- await page . waitForTimeout ( 500 ) ;
246+ await new Promise ( resolve => setTimeout ( resolve , 500 ) ) ;
235247
236248 // Generate PDF
237249 await page . pdf ( {
0 commit comments