acep-uaf / aetr-web-book-2024

Alaska Electricity Trends Report as a web book
https://acep-uaf.github.io/aetr-web-book-2024/
Creative Commons Attribution Share Alike 4.0 International
0 stars 0 forks source link

[AETR] Add rendered PDF to book #57

Open eldobbins opened 1 month ago

eldobbins commented 1 month ago

Neil found it easier to work with PDFs rather than the web pages.

Example: https://openscapes.github.io/booklet/. (see the PDF symbol under the icon in the left margin?)

eldobbins commented 4 weeks ago

Have experimented with rendering as PDF. Quarto uses KOMA-script to use defined LaTeX document classes, so formatting a report is super easy.

Working and looking good:

Problems:

So considering just those things, generating a PDF is pretty easy...

BUT!

ojs figures are rendered by the browser when the HTML pages are viewed - not by Quarto. So the rendered PDF only has code - not the figures.

Quarto "recommends" to print pages from the browser to PDF files = twisted. In 2022, the prediction was that adding ojs rendering would be implemented in 3-9 months.

Also:

eldobbins commented 4 weeks ago

How to print website to PDF?

Note: the Quarto rendered HTML pages (_site/methods.html) are full of javascript not static images in _site_images. Of course! That was the point. So the converter has to render the js.

ianalexmac commented 3 weeks ago

At the moment, we are in a bind over two issues:
First of all, our figures are built in OJS, which needs some workarounds to render into a static images.



Second, Quarto has conditional code execution, but only for R blocks. So we can't turn OJS blocks on/off depending on render format.

eldobbins commented 3 weeks ago

What if we thought of the PDF as a different beast with static figures, not as a differently rendered version of the interactive figures? That would broaden the applicability of Quarto to article and report generation without relying on an intermediate interactive version.

The steps of this would look like

  1. Liz pushes the change to https://github.com/eldobbins/new-quarto-website that renders R
  2. Ian forks that repo, and adds a code block to index.qmd with the condition code execution
    • option 1 renders a "Hello World" type plot in R
    • option 2 renders an OJS version of the same plot as an interactive version
      1. Ian makes a PR back to new-quarto-website so Liz can clearly see the changes he had to make
      2. Liz migrates those changes to the cookiecutter so that it can now generate a repo that can produce both interactive plots or static plots depending on the render
      3. Meanwhile, Ian uses his stripped down example to teach Emily about Quarto and plots
      4. Ian and Emily have a hackathon to add a static option to every plot in AETR that will be used in the PDF.

Deadline for this would be July 1