Closed
Description
Environment Data
VS Code version: 1.99.3.0(not relevant)- Jupyter Extension version: 2025.3.0 (however, even 2020.2.0 applies, so it doesn't matter)
Python Extension version: 2025.4.0(not relevant)- OS: Windows 11 24H2
Python and/or Anaconda version: 3.8, 3.11 and 3.12(not relevant)Type of virtual environment used: conda(not relevant)Jupyter server running: Local and Remote(not relevant)
Expected Behavior
Exporting a Jupyter notebook to PDF from the VS Code Jupyter extension bar, and get a pdf.
Actual Behavior
Failed to export.
Steps to Reproduce
- Open any
.ipynb
file in VS Code. - Right-click and select "Export as PDF".
- Observe the export failure, despite a valid PDF existing in the temp directory (for example "C:\Users...\AppData\Local\Temp\tmp-53764aZammKviOmV0.pdf.pdf").
Additional Information
- available options
Source | To | Via | Success? |
---|---|---|---|
Web Server GUI | Download | ✅ | |
Command Line | TEX | Command Line | ✅ |
Command Line | Command Line | ✅ | |
VS Code Extension | HTML | VS Code Extension | ✅ |
VS Code Extension | PY | VS Code Extension | ✅ |
VS Code Extension | VS Code Extension | ❌ |
- This issue is distinct from Can't export a pdf. The html export works fine. #13912, xelatex (TeX) installed but still giving error #10910, and Export to pdf failed #12742, which suggest
pandoc
ornbconvert
problems. These are not the root cause. - root cause: pdf is actually generated, however, the extension failed to get his name. For example, the true ath is
...\AppData\Local\Temp\tmp-54084AG2zf2BvEQSm.pdf.pdf
, but the extension accesses...\AppData\Local\Temp\tmp-54084AG2zf2BvEQSm.pdf
and thus got a failure. - The code snippet from
src/notebooks/export/exportBase.node.ts
,if((await this.fs.stat(Uri.file(tempTarget.filePath))).size > 1) await this.fs.copy(Uri.file(tempTarget.filePath), target);
is the source of the error.tempTarget.filePath
contains the correct temporary filename (e.g.,...\AppData\Local\Temp\tmp-54084AG2zf2BvEQSm.pdf
), but the extension is looking for a file with an extra.pdf
extension. - A temporary workaround is to modify the code to
if((await this.fs.stat(Uri.file(pdfFilePath + '.pdf'))).size > 1) await this.fs.copy(Uri.file(pdfFilePath + '.pdf'), target);
.