Including a PDF in an EPUB

By |

I got a request from a PressBooks user, who asked the following:

my plan is to burn the epub file with a reader on a CD and have direct links to some pdf files in my CD as well. how do i link them?

I misinterpreted what the user wanted, and *thought* the question was: “Can I include a PDF for download in an EPUB?” For some thoughts on that question, see below.

[For an answer to the question: you should be able to make a link to a local file from an EPUB.Depending on your ereader that may or may not work. Does anyone have any experience with this?]

Can you include a PDF in an EPUB?

This is a question that I hadn’t seen before, and I wasn’t sure:

a) whether PDFs could be included in an EPUB as an attachment/include, and still validate
b) whether PressBooks would do as it was told if you just treated a PDF as an image and uploaded it to a chapter — and exported to EPUB
b) whether there might be a “better” or different solution

So, first let’s look at the usecase:

The user is creating educational EPUBs, which reference PDFs as supporting materials to the book, and she is distributing these EPUBs on CD to rural areas with no network connection. So this means that linking to a PDF on a server somewhere isn’t going to work — since there is no network connection.

Question 1: Can a PDF be included as an attachment in an EPUP? (and will the EPUB still validate?)

And to answer, I went to Twitter and posted the question with the #eprdctn hashtag (the hashtag you should use and follow to and participate in discussions among ebook production people):

“Anyone know if you can include a PDF for download in an EPUB?”

The first response I got was from Eli, who encapsulated the strangeness of the idea:

The reaction here was, if I got it right, to the idea that you could include the PDF for a book (the same one? a different one?) within an EPUB. In-spine. (And … why not?).

bowerbird agreed, this is a strange question:

bowerbird’s question (if I got it right) is “where” we’d like to “put” this PDF: as an attachment (acting like, say, an image in the text), or in the spine (acting like a chapter in the text). Reflecting on that question, I think the answer is: as an attachment (which seems feasible). In the spine … I don’t think that is workable. Maybe bowerbird might have some comments?

There were some tweets suggesting that iBooks Author lets you do this, and iBooks will support PDF viewing from inside an ebook, but iBooks Author doesn’t make EPUBs, exactly, and anyway, I was trying to figure out if this could be done on PressBooks.

Anyway, Hadrien & Pablo both said: “Yes. It can be done, and it will validate.” Said Hadrien:

And Pablo:

Question 2: Will PressBooks allow you to upload a PDF as an “image” in a chapter, and export to EPUB?

Answer: not right now, anyway. When you upload the PDF to a PressBooks chapter, it adds a link for the PDF. And the link is exported in the EPUB; the PDF isn’t included. I can’t right now think about how else that would be handled in PressBooks … We’d have to have a way to define explicitly when a PDF should be included and when it should just be linked. And interesting question, but not high priority right now.

Question 3: Is there a “better” or different solution?

Since the EPUBs are distributed on CD, you could just add the files separately to the CD (as bowerbird suggested). Questions/comments:
* How would you handle making the link between the EPUB and the PDF, also as a file on the CD? Will a link to a local file work?
* If the CD and EPUBs were to part ways — say if someone moved an EPUB from a CD to their reader, then you would lose your PDF … so this seems a sub-optimal solution?

Last question:
How will various reading devices/software handle having a PDF included in the EPUB?

Anyway, if anyone has any experience with this, feel free to comment here — or post elsewhere and link back.