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 fails with several output formats and SVG image #10883

Open
zlatkig opened this issue Sep 25, 2024 · 1 comment
Open

PDF fails with several output formats and SVG image #10883

zlatkig opened this issue Sep 25, 2024 · 1 comment
Labels
bug Something isn't working docx Issues with the docx format latex LaTeX engines related libraries and technologies projects

Comments

@zlatkig
Copy link

zlatkig commented Sep 25, 2024

Bug description

When generating HTML, PDF and DOCX formats from the same document which includes a SVG image, PDF generation fails. If generating only HTML and PDF, then all three outputs succeed.

Here is a minimal project which demonstrates the issue:

quazz.zip

The archive contains three files: a simple _quarto.yml, a SVG image and a simple document which references the image. If you run quarto render in the directory where you extract this archive, PDF generation will fail with the following error:

ERROR:
compilation failed- error
Unable to load picture or PDF file 'quazz_files/mediabag/piechart.pdf'.
<to be read again>
                   }
l.169 ...eight]{quazz_files/mediabag/piechart.pdf}


see /Users/igor/Gliwa/tmp/quazz/quazz.log for more information.
ERROR: Error
    at renderFiles (file:///Applications/quarto/bin/quarto.js:78081:29)
    at eventLoopTick (ext:core/01_core.js:153:7)
    at async renderProject (file:///Applications/quarto/bin/quarto.js:78479:25)
    at async Command.actionHandler (file:///Applications/quarto/bin/quarto.js:83077:32)
    at async Command.execute (file:///Applications/quarto/bin/quarto.js:8017:13)
    at async Command.parseCommand (file:///Applications/quarto/bin/quarto.js:7907:20)
    at async quarto (file:///Applications/quarto/bin/quarto.js:118224:9)
    at async file:///Applications/quarto/bin/quarto.js:118244:9
    at async mainRunner (file:///Applications/quarto/bin/quarto.js:118128:9)
    at async file:///Applications/quarto/bin/quarto.js:118235:5

If you now modify _quarto.yml and remove DOCX from output formats (remove or comment out the docx: {} line), PDF generation will succeed. I haven't tested them all, but I think you can use any format instead of docx to demonstrate the issue.

What I believe happens here is that Quarto (or Pandoc) use rsvg-convert to convert the SVG image to PDF. This succeeds and the resulting image is placed in quazz_files/mediabag/piechart.pdf. Pandoc generates a Tex file referencing that image. Now Quarto manages to delete that file (in fact it deletes the entire mediabag subdirectory) before Latex processes Pandoc's output. Latex then fails to find the referenced PDF image.

This only happens with SVG images. PNG images for example go fine. It also only happens if more than HTML and PDF output formats are listed in _quarto.yml.

Rendering to PDF on its own with quarto render --to pdf will succeed even if extra formats are specified in _quarto.yml. Ony rendering them all together with quarto render fails.

Am I doing something wrong?

Steps to reproduce

To reproduce this without the archive attached above, follow these steps:

  • Create a Quarto project with default type using quarto create project default . quazz --no-open. This will generate two files in the current directory named _quarto.yml and quazz.qmd.
  • Find any SVG image and save it as piechart.svg.
  • Put this in quazz.qmd:
---
title: "quazz"
---

This is a symbol of a pie chart in SVG:

![Symbolic pie chart](/piechart.svg "A SVG Picture"){width=20%}

That is it.
  • Put this in _quarto.yml:
project:
  title: "quazz"

format:
  html: {}
  pdf: {}
  docx: {}
  • Run quarto render

Expected behavior

Expected is generation of three output documents as specified in _quarto.yml.

Actual behavior

PDF generation fails with an error.

Your environment

  • IDE: VIM, but not relevant. Any text editor will do.
  • OS: macOS Sequoia 15.0

Quarto check output

Quarto 1.5.57
[✓] Checking versions of quarto binary dependencies...
      Pandoc version 3.2.0: OK
      Dart Sass version 1.70.0: OK
      Deno version 1.41.0: OK
      Typst version 0.11.0: OK
[✓] Checking versions of quarto dependencies......OK
[✓] Checking Quarto installation......OK
      Version: 1.5.57
      Path: /Applications/quarto/bin

[✓] Checking tools....................OK
      TinyTeX: v2024.09
      Chromium: 869685

[✓] Checking LaTeX....................OK
      Using: TinyTex
      Path: /Users/igor/Library/TinyTeX/bin/universal-darwin
      Version: 2024

[✓] Checking basic markdown render....OK

[✓] Checking Python 3 installation....OK
      Version: 3.12.6
      Path: /usr/local/opt/[email protected]/bin/python3.12
      Jupyter: (None)

      Jupyter is not available in this Python installation.
      Install with python3 -m pip install jupyter

[✓] Checking R installation...........OK
      Version: 4.4.1
      Path: /Library/Frameworks/R.framework/Resources
      LibPaths:
        - /Library/Frameworks/R.framework/Versions/4.4-x86_64/Resources/library
      knitr: (None)
      rmarkdown: (None)

      The knitr package is not available in this R installation.
      Install with install.packages("knitr")
      The rmarkdown package is not available in this R installation.
      Install with install.packages("rmarkdown")
@zlatkig zlatkig added the bug Something isn't working label Sep 25, 2024
@mcanouil
Copy link
Collaborator

mcanouil commented Sep 29, 2024

Where did you see the following?

format:
  html: {}
  pdf: {}
  docx: {}

That is quite not pretty.
You should use default which is clearer than {}.

This being said, I can reproduce using a simpler example.
Thanks for the report.

---
title: "Quazz"
format:
  pdf: default
  docx: default
---

![Symbolic pie chart](piechart.svg)
  • quarto render index.qmd --to all leads to an error.
  • remove docx: default (or change the order) and quarto render index.qmd --to all works.

Somehow, the temporary files seems to be wrongly deleted or at least not at the right time.

The following with docx as first format also works:

---
title: "Quazz"
format:
  docx: default
  pdf: default
---

![Symbolic pie chart](piechart.svg)

@mcanouil mcanouil added projects docx Issues with the docx format latex LaTeX engines related libraries and technologies labels Sep 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working docx Issues with the docx format latex LaTeX engines related libraries and technologies projects
Projects
None yet
Development

No branches or pull requests

2 participants