View Full Version : Is it possible to embed PDFs in EPUB?


jsimms
04-16-2011, 10:04 PM
OK, this question probably sounds nuts, but here goes...

Is there a way to embed a PDF file in an EPUB? I have a high-res map that doesn't look good on an iPad or Nook screen (let alone a phone screen), and I'd like to embed the map as a PDF, so the user could then zoom in and find what they need. Maybe something that, once the user clicked on it, opened up in iBooks as a separate PDF. (Of course the dream would be to have something you could zoom in and out IN the EPUB, but I'm assuming that's still a ways off)

Anybody out there work with PDFs in EPUB???

Elfwreck
04-17-2011, 01:45 AM
You can't embed a PDF in an epub. Epub is a renamed .zip file, with some metadata attached to an HTML file or set of HTML files. Just like you can't embed a PDF inside an HTML file, you can't put one in an epub. You can make a link to one, but how that works depends on the software involved.

You might be able to make a link to a PDF file outside of the epub--but whether that would work depends on the software used to read the epub.

Zooming in on a PDF depends on the software used to read the PDF. On a Kindle or Sony 505, for example, there's no zoom option, so it doesn't matter if the PDF was used or not--readers would still be stuck with whatever was viewable on their screen. PDFs aren't inherently zoom-able; that depends on the reading software. (Just like making the map a jpg or png might be zoom-able if it were being read on a PC-based epub reader instead of a portable device.)

jsimms
04-17-2011, 02:09 PM
Got it. Thanks for the info.

And here's to hoping that someday EPUB readers can handle more complex files than just low-res JPEGs.

KevinH
04-17-2011, 02:42 PM
Hi,

They can. I use svg images all of the time in epubs and they are perfectly scalable, zoomable, etc. Try to convert your pdf to an svg image.

Elfwreck
04-17-2011, 02:43 PM
Hi,

They can. I use svg images all of the time in epubs and they are perfectly scalable, zoomable, etc. Try to convert your pdf to an svg image.

Scalable and zoomable in what? I don't think my Sony Reader will zoom on images, regardless of what format they're made in.

jsimms
04-17-2011, 03:43 PM
The map I'm trying to embed was made in Illustrator. I just saved it as a SVG, added it to my EPUB, but my iPad doesn't allow any zooming, etc.

KevinH
04-17-2011, 05:46 PM
Scalable and zoomable in what? I don't think my Sony Reader will zoom on images, regardless of what format they're made in.

Hi,

That is funny. My Sony PRS-600 does it for all images. I simply go to the page with the image and then hit the button with magnifying glass + on it, and then hit the "Zoom In" button and a vertical magnification scrollbar appears along with navigation arrows to move around the zoomed image.

It seems to work great with my svg images. Everytime I zoom in, the image starts as fuzzy and then gets redrawn looking beautiful at that scale.

KevinH
04-17-2011, 05:49 PM
The map I'm trying to embed was made in Illustrator. I just saved it as a SVG, added it to my EPUB, but my iPad doesn't allow any zooming, etc.

Sorry, I don't think iBooks support SVG images yet (even though it is part of the official epub spec). Have you tried in another epub reader on your ipad such as the Bluefire.app or Stanza or .. Perhaps it will work better?

KevinH
04-17-2011, 06:35 PM
Sorry, I don't think iBooks support SVG images yet (even though it is part of the official epub spec). Have you tried in another epub reader on your ipad such as the Bluefire.app or Stanza or .. Perhaps it will work better?

Hi,

I created a quick svg image in an epub and loaded it into my iPad. Normally, in iBooks you simply double-click on an image and then iBooks loads it into its own screen and you can pinch to zoom and move around. When I do this with "SVG" images in an iPad, I get a blank screen and then iBooks terminates (crashes).

I tried with the Kobo reader software on iPad and none of the SVG images even showed up on the screen (quite sad). I tried with the Bluefire reader app and the svg images appeared but I could not figure out how to zoom in on any image, let alone a SVG image.

So you are right, this solution will not work on an iPad using iBooks, Bluefire, Kobos, etc It does work well on my Sony though.

Sorry for getting your hopes up. It may work in Safari. I know in Desktop Safari you can open standalone SVG images and zoom around on them (and with FireFox 4) but I am not sure if that would work on an iPad, though. You would probably be better off just making your entire ebook a pdf one and not an epub if you want it to work with scalable images on an iPad.

Freeshadow
04-17-2011, 09:21 PM
@KevinH
iPub has so often proven absolute ignorance about the specs, that I'd always crosscheck with something different before asking myself what I've done wrong :)

wannabee
04-17-2011, 10:09 PM
I started toying with SVG for a similar purpose. It did work in iBooks and was zoomable.
That was before the latest upgrades to iOS and iBooks and I haven't tried it since. They looked great but wouldn't validate as the file became too big.

KevinH
04-18-2011, 12:13 AM
HI,

I started toying with SVG for a similar purpose. It did work in iBooks and was zoomable.
That was before the latest upgrades to iOS and iBooks and I haven't tried it since. They looked great but wouldn't validate as the file became too big.

That is good to know that it does work. Did you add the svg code directly in the html or did you simply include an image link to a separate .svg file? My iBooks just kept crashing when I tried to zoom using a standard html img link to an .svg file (but this approach works for my Sony reader and stragith html in Safari and Firefox 4).

Is there a sample epub you could post so that I can see how you got it to work in iBooks?

Thanks,

KevinH

Adjust
04-18-2011, 01:23 AM
ePub Kindle conversion to .mobi via kindlegen also has a real problem with SVGs

wannabee
04-18-2011, 01:50 AM
HI,



That is good to know that it does work. Did you add the svg code directly in the html or did you simply include an image link to a separate .svg file? My iBooks just kept crashing when I tried to zoom using a standard html img link to an .svg file (but this approach works for my Sony reader and stragith html in Safari and Firefox 4).

Is there a sample epub you could post so that I can see how you got it to work in iBooks?

Thanks,

KevinH

Kev, I end up with so many versions of a book as it evolves that I don't keep old versions around otherwise they get mixed up. So I don't have one to send you.
However the way I added the SVG image was from Adobe InDesign. It was inserted into the text in InDesign and exported as an ePub in the same way the JPGs are with the ORIGINAL selected rather than FORMATTED which collects the SVG into the OPF folder.

Jellby
04-18-2011, 07:01 AM
You can't embed a PDF in an epub.

Actually, you can embed a PDF in an ePUB. You can embed practically anything in an ePUB, the problem is there is no guaranty at all that any reading system will know what to do it, and you should provide a fallback for the (likely) case that the reader does not support the embedded content.

In the case of PDF, you can include a PDF file in the manifest, and link to it in the text, but you must include some fallback XHTML file to be used when the PDF is not supported. Even when the reader supports PDF, don't expect it to be opened in a nice user-friendly environment, it will probably be opened as a full page inside the ePUB viewer, with the same options as with any illustrations (usually no zoom, etc.)

If you want the user to be able to pan, zoom, rotate, etc. an image, that's a feature of the reading software, not something you can include or not in your ePUB.

adv_dp_fan
04-18-2011, 12:30 PM
Apple's Asset Guide for the iBookstore has a section on embedding PDFs in an epub. Basically they say use an HREF linking an image to the PDF. When the image is tapped it opens the PDF in a separate view that has zoom controls.

They warn that overall maximum book size is 2GB and to keep that in mind.

And of course this is for iBooks, other epub viewers may not support the PDF.

SamL
06-20-2011, 04:25 PM
The iBookstore Asset Guide says this will work.

<a href="pdf/mypdffile.pdf"> <img src="images/mypdffile.jpg"/> </a>

When the image is clicked, it will open the PDF up in a new window with zoom controls. Has anyone tried this yet?

Would be nice if it worked on other readers too.

SamL
06-21-2011, 06:30 PM
The iBookstore Asset Guide says this will work.



When the image is clicked, it will open the PDF up in a new window with zoom controls. Has anyone tried this yet?

Would be nice if it worked on other readers too.


Just to update, I tried this and it works. Make sure you declare the PDF in the content.opf file or else when you click your link, it just jumps to the beginning of the book.

A couple things I noticed:

It makes the height of the PDF take up the entire screen. So if your PDF is landscape, the height will fit, but you have to scroll left to right. I'm using this for music tab PDFs, so it was a problem that they did not automatically fit in the screen. As a work around I re-did the PDFs so that are portrait sized, they just have more white space below. But at least they fit in the window when you click the,

Also what I am noticing is that large hi-res PDFs load very slow, making it hard to quickly zoom in and out and navigate. Low-res PDFs load fine, but look pretty bad when you zoom in on them.

I'll keep playing around to see if I can get settled on a certain size and resolution.

phyllisj9
08-05-2011, 01:20 PM
I'm trying to see if I can figure this out too. I notice that if you embed a PDF the EPUB doesn't validate. Something about hyperlinking to non-standard resources. This page seems to be explaining something about having a fallback method:

http://idpf.org/epub/20/spec/OPF_2.0.1_draft.htm#Section2.0

It's over my head though. Anyone have a working example they could share? And any ideas if it'll work when the file's converted for Kindle?

I'm new at this stuff and probably shouldn't jump in so far over my head. It's fun though. :-)

Thanks, Phyllis