I ran into the same issue as outlined in @user2433922's answer. My Kobo Libra 2 showed an error when viewing an EPUB claiming to be about DRM when it was really due to a missing content.opf
file in an Open eBook Publication Structure (OEBPS). Here's additional instructions on how to fix it.
Before getting started, run the EPUB against W3C's epubcheck tool to see if there are any errors.
epubcheck spring-boot-reference.epub
FATAL(OPF-002): ./spring-boot-reference.epub/META-INF/container.xml(-1,-1): The OPF file "https://d544286e-3ac0-4871-81d3-1f9198b71f82.epubcheck.w3c.org/content.opf" was not found in the EPUB.
Check finished with errors
Messages: 1 fatal / 0 errors / 0 warnings / 0 infos
In the case of the ebook mentioned in the linked answer, epubcheck
outlines a clear error regarding the content.opf
file. Another problematic EPUB I used had no errors, despite it not loading on Kobo and a similar issue with that file.
For those unfamiliar with the EPUB format, EPUBs are zip archives with a standardized file structure and metadata. The contents can be viewed by unzipping them:
unzip book.epub -d ./book
Check to see if there is a file located under OEBPS/content.opf
. In the case of the above example, although there is one, the file META-INF/container.xml
doesn't include the OEBPS
directory in the path:
<?xml version="1.0" encoding="UTF-8"?><container xmlns="urn:oasis:names:tc:opendocument:xmlns:container" xmlns:svg="http://www.w3.org/2000/svg" version="1.0">
<rootfiles>
<rootfile full-path="content.opf" media-type="application/oebps-package+xml"/>
</rootfiles>
</container>
Which should be changed to:
<?xml version="1.0" encoding="UTF-8"?><container xmlns="urn:oasis:names:tc:opendocument:xmlns:container" xmlns:svg="http://www.w3.org/2000/svg" version="1.0">
<rootfiles>
<rootfile full-path="OEBPS/content.opf" media-type="application/oebps-package+xml"/>
</rootfiles>
</container>
In the case of another EPUB I had an issue with, META-INF/container.xml
pointed to another file and content.opf
did not exist. Renaming that file to content.opf
and updating META-INF/container.xml
as above fixed it.
To create a new archive, run the following (taken from this answer):
cd /path/to/epub-export
zip -0 -X ../newbook.epub mimetype
zip -9 -X -r -u ../newbook.epub *
Then run epubcheck newbook.epub
and to confirm it can parse the EPUB. Note that sometimes there are errors that won't prevent it from opening on the Kobo.