Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PDF Export Error: "Failed to add header/footer" with Null pdf Type #6216

Open
3 tasks done
HoeYeungHo opened this issue Jan 22, 2025 · 1 comment
Open
3 tasks done

Comments

@HoeYeungHo
Copy link

HoeYeungHo commented Jan 22, 2025

  • Searched existing issues to avoid creating duplicates.
  • Confirmed that it can be reproduced in built-in themes without customized css.
  • Searched http://support.typora.io/

Describe the bug
When exporting a PDF in Typora, the following error is displayed:

Failed to add header / footer.
`pdf` must be of type `string` or `Uint8Array` or `ArrayBuffer`, but was actually of type `null`

As a result, the exported PDF does not include any header or footer content. The settings used for export are shown in the attached screenshot.

To Reproduce

Steps to reproduce the behavior:

  1. Set up the page settings as shown in the screenshot (e.g., custom margins, A4 size, and headers/footers with variables like ${pageNo} / ${totalPages}).
  2. Export a Markdown file to PDF.
  3. Observe the error message and missing header/footer in the exported PDF.

Expected behavior

Headers and footers should be correctly rendered in the exported PDF, without any errors.

Screenshots / Screencasts

Image

Image

Sample Markdown File

Any Markdown file.

Desktop (please complete the following information):

  • OS: Windows 11 64-bit
  • Typora Version: 1.10.5-dev
@HoeYeungHo
Copy link
Author

I have tested 1.10.5-dev on two different windows computers and found that the problem can be repeated. This warning will appear if you use customization on the margins (even if you do not adjust the default customization value), but there will be no problem if you use the default.

The log files (%APPDATA%/Typora) are as follows

INFO 2025/1/30 01:36:17  get PDF data
ERROR 2025/1/30 01:36:17  unhandledRejection Error: Script failed to execute, this normally means an error was thrown. Check the renderer console for the error.
    at node:electron/js2c/sandbox_bundle:2:58548
    at IpcRendererInternal.<anonymous> (node:electron/js2c/sandbox_bundle:2:52741)
    at IpcRendererInternal.emit (node:electron/js2c/sandbox_bundle:2:34768)
    at Object.onMessage (node:electron/js2c/sandbox_bundle:2:50819)
INFO 2025/1/30 01:36:17  get background color
INFO 2025/1/30 01:36:18  load file [C:\Users\HoeYeung\AppData\Local\Temp\Typora\1738172178001-1.html] for PDF export
INFO 2025/1/30 01:36:18  generate print window with id 3
ERROR 2025/1/30 01:36:18  Error: margins must be less than or equal to pageSize
    at _.printToPDF (node:electron/js2c/browser_init:2:77206)
    at C:\Program Files\Typora\resources\app.asar\atom.compiled.dist.jsc:1:6414
    at async WebContents.<anonymous> (node:electron/js2c/browser_init:2:86077)
INFO 2025/1/30 01:36:20  [blur] 1
INFO 2025/1/30 01:36:20  [win] blur
INFO 2025/1/30 01:40:02  [focus] 1
INFO 2025/1/30 01:40:03  [blur] 1
INFO 2025/1/30 01:40:03  [win] blur

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant