diff --git a/src/converter.ts b/src/converter.ts index 59d6904c..ab46c2a9 100644 --- a/src/converter.ts +++ b/src/converter.ts @@ -124,6 +124,8 @@ const stripBOM = (s: string) => (s.charCodeAt(0) === 0xfeff ? s.slice(1) : s) export class Converter { readonly options: ConverterOption + private _firefoxPDFConversionWarning = false + constructor(opts: ConverterOption) { this.options = opts } @@ -252,7 +254,7 @@ export class Converter { if (opts.onConverted) opts.onConverted({ file, newFile, template }) } - // #convertFile must return a single file to serve in server + // convertFile must return a single file to serve in server return { file, template, newFile: files[0] } } else { // Try conversion with specific template to scan using resources @@ -301,6 +303,17 @@ export class Converter { const ret = file.convert(this.options.output, { extension: 'pdf' }) + // Generate PDF + const browser = await browserManager.browserForConversion() + + if (browser.kind === 'firefox' && !this._firefoxPDFConversionWarning) { + this._firefoxPDFConversionWarning = true + + warn( + 'Using Firefox to convert Markdown to PDF: The output may include some incompatible renderings compared to the PDF generated by Chrome.' + ) + } + let outlineData: OutlineData | undefined ret.buffer = Buffer.from(