Skip to content

Cannot export PDF just with vscode extension (other methods work) #16590

Closed
@CNDY1390

Description

@CNDY1390

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

  1. Open any .ipynb file in VS Code.
  2. Right-click and select "Export as PDF".
  3. 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

  1. available options
Source To Via Success?
Web Server GUI PDF Download
Command Line TEX Command Line
Command Line PDF Command Line
VS Code Extension HTML VS Code Extension
VS Code Extension PY VS Code Extension
VS Code Extension PDF VS Code Extension
  1. 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 or nbconvert problems. These are not the root cause.
  2. 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.
  3. 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.
  4. 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);.

Metadata

Metadata

Labels

bugIssue identified by VS Code Team member as probable bugtriage-neededIssue needs to be triaged

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions