How do you embed an .epub in a web page?
Asked Answered
E

2

9

Is there a viewer or plugin of any kind that would allow an .epub document to be viewable on a web page? A Google search turned up tons of installable epub viewing desktop software but I couldn't seem to find anything for embedding this format on a web page. Perhaps you folks have some insight into this?

Educationist answered 14/9, 2011 at 15:48 Comment(0)
K
6

epub files are just HTML/XML and CSS, so you could easily open the epub container (it's a zip), then parse the XML inside using a language like PHP.

It shouldn't be too difficult to do that.

The format looks like:

--ZIP Container--
mimetype
META-INF/
  container.xml
OPS/
  book.opf
  chapter1.xhtml
  ch1-pic.png
  css/
    style.css
    myfont.otf

Here's an example of the content you might find in chapter1:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
  <head>
    <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" />
    <title>Pride and Prejudice</title>
    <link rel="stylesheet" href="css/main.css" type="text/css" />
  </head>
  <body>
    ...
  </body>
</html>
Kerchief answered 14/9, 2011 at 16:0 Comment(0)
A
0

I'd suggest that this should in most cases be done with Javascript using a library like one of these How to read epub files using javascript

Aboulia answered 14/9, 2015 at 8:2 Comment(3)
Not that I don't appreciate your answer, but why do you say you should shift this processing onto the client in "most cases"?Educationist
Every instance that I can think of, it would be best to shift it to the client. Maybe there's others where this isn't the best option. Maybe browsers will start supporting .epub natively in the future. Hard to say.Aboulia
I can't think of one.Educationist

© 2022 - 2024 — McMap. All rights reserved.