Open csgillespie opened 2 years ago
The version of build_pdf()
being called here is essentially a small wrapper around pagedown::chrome_print()
, so I'd suggest trying that function on its own to see if you can get a more informative error message.
To closely replicate our flow, you could use build_html()
to build the html file and then call
pagedown::chrome_print(
input = "chapter1.html",
output = "chapter1.pdf"
)
It does smell like there's something wrong with chrome/chromote going on here
So it's working on Ubuntu 20.04 but not Ubuntu 22.04? Sounds like an issue with Chrome.
Another check is to try and print some other webpage, like pagedown::chrome_print("https://en.wikipedia.org/wiki/R_(programming_language)")
If you get a similar error, then that should at least help narrow down the source.
So this is odd. This works
pagedown::chrome_print("https://en.wikipedia.org/wiki/R_(programming_language)",
output = "wiki.pdf")
But this doesn't
pagedown::chrome_print(
input = "chapter1.html",
output = "chapter1.pdf"
)
Chapter1.Rmd now looks like
---
title: "Introduction"
output:
xaringan::moon_reader
---
Can you try this?
pagedown::chrome_print(
input = "file://chapter1.html",
output = "chapter1.pdf"
)
❯ pagedown::chrome_print(
input = "file://chapter1.html",
output = "chapter1.pdf"
)
Error in force(expr) :
Failed to generate output. Reason: net::ERR_INVALID_URL
Run `rlang::last_error()` to see where the error occurred.
✖ [main* ↓]
❯ last_error()
<error/rlang_error>
Error:
! Failed to generate output. Reason: net::ERR_INVALID_URL
---
Backtrace:
1. pagedown::chrome_print(input = "file://chapter1.html", output = "chapter1.pdf")
2. later with_temp_loop_maybe(...)
3. later::with_loop(loop, expr)
4. base::force(expr)
Run `rlang::last_trace()` to see the full context.
✔ [main* ↓]
❯ last_trace()
<error/rlang_error>
Error:
! Failed to generate output. Reason: net::ERR_INVALID_URL
---
Backtrace:
▆
1. └─pagedown::chrome_print(input = "file://chapter1.html", output = "chapter1.pdf")
2. └─later with_temp_loop_maybe(...)
3. └─later::with_loop(loop, expr)
4. └─base::force(expr)
You'll need the absolute path prefixed with file://
, which ends up being file:///Users/colin/chapter1.html
You'll need the absolute path prefixed with file://, which ends up being file:///Users/colin/chapter1.html
Duh! I did that the first time, and got an error. Must have had a typo :(
pagedown::chromepagedown::chrome_print(
input = "file:///data/ncsg3/gitlab/training/r/introduction/slides/chapter1.html",
output = "chapter1.pdf"
)
works!
But you still get the error when using build_pdf()
? I wonder if you could try
debug(xaringanBuilder:::build_pdf_simple)
xaringanBuilder::build_pdf("chapter1.Rmd")
And check that the file path for input
is correct. Some other things to take a look at:
self_contained = TRUE
?The net::ERR_ABORTED
error seems like maybe it's some kind of 404-equivalent error, but beyond that I'm just making guesses. I was surprised that pagedown::chrome_print()
worked as expected, I was thinking that would give us a better hint. 🤔
My chapter1.Rmd is now minimal. It's only five lines:
---
title: "Introduction"
output:
xaringan::moon_reader
---
This
input = "file:///data/ncsg3/gitlab/training/r/introduction/slides/chapter1.html"
output = "/data/ncsg3/gitlab/training/r/introduction/slides/chapter1.pdf"
pagedown::chrome_print(input = input, output = output, verbose = 2)
works fine. But if I remove the explicit file:://
, I get the error.
Interestingly,
---
title: "Introduction"
---
works with no issues. So there is something odd around xaringan
for me.
One more tiny piece of information on this: Ubuntu 20.04, Chrome Version 101.0.4951.54 (Official Build) (64-bit). Similarly having failures on build_pdf() -
✖ Building xaringanBuilder_3805fa20d95692.html into xaringanBuilder_3805fa78b5fac.pdf ... failed Error in force(expr) : Failed to generate output. Reason: Failed to open http://127.0.0.1:5677/figure/infer_oregon3.png (HTTP status code: 404)
Adding the manual explicit full file path to the input sails through:
xaringanBuilder:::build_pdf_simple("file:///home/path/to/file/here/index.html", "index.pdf")
Input is just a bog-standard set of slides for a presentation. Maybe the 404 that's bouncing reinforces the comment by gadenbuie above.
@wesleyburr / @gadenbuie I had a "similar" issue with RStudio. Essentially when opening an HTML file, it used firefox. The issue was that the default browser for opening a file was firefox.
Firefox can't open local assets on my machine, so could, I suppose, generate the above errors. I wonder if that is the issue?
I'm having trouble building PDF slides.