# How-to Fix: ePubs from Scrivener or Calibre No Longer Pass ePubCheck



## David Adams (Jan 2, 2012)

Okay, so there's a bit of a kerfuffle about this and it's stung me, but I fixed it. Despite extensive Googling, I think I'm the only one who's managed to fix this, so here goes. KB'ers get it first. This page is indexed by Google, so hopefully someone else with this problem can find it.  If anyone does, I spent a whole productive writing day on this, so if you wanted to help me out, my books are in my signature line.

*Problem:*

If you are creating ePub files using Scrivener or Calibre, and are discovering that they no longer pass ePubChecker verification (either because you're uploading them via Draft2Digital or Apple direct), then this is your problem. You may get an error that looks something like this:

If you're using Scrivener for Windows:

WARNING	OPS/toc.ncx	-	-	[email protected]:uid content 'e6f9dd53-a44e-4b62-91d1-3c5b7cae613f' should conform to unique-identifier in content.opf: 'urn:uuid:e6f9dd53-a44e-4b62-91d1-3c5b7cae613f'
ERROR	OPS/contents.xhtml	11	98	non-standard stylesheet resource 'OPS/page-template.xpgt' of type 'application/adobe-page-template+xml'. A fallback must be specified.

If you are using Scrivener for Mac, or Calibre, you will probably only get:

WARNING	OPS/toc.ncx	-	-	[email protected]:uid content 'e6f9dd53-a44e-4b62-91d1-3c5b7cae613f' should conform to unique-identifier in content.opf: 'urn:uuid:e6f9dd53-a44e-4b62-91d1-3c5b7cae613f'

To check if your ePub files have this error, you can upload them here:

http://validator.idpf.org/

*Cause:*

All ePubs that are submitted to Draft2Digital, or Apple, are passed through an open-source program called ePubChecker. Recently, ePubChecker released a new version of their program (v3.0.1) which changed, slightly, what constitutes a 'valid' file. This means that .ePubs that previously verified fine no longer do. For the technically inclined, you can see the bug report here:

https://code.google.com/p/epubcheck/issues/detail?id=271

*Solution:*

Ready for the pain?

Firstly, to resolve the 'error', you need to download ePubFixer, located here:

https://code.google.com/p/epubfixer/downloads/detail?name=ePubFixer_cli%20v1.5.3.zip&can=2&q=

Unzip it, copy the affected .epub into the same directory, and then bring up a command line (start | run | 'cmd'). Navigate to the directory with ePubFixer in it, then run the following command:

ePubFixer_cli.exe -f <filename>.epub -t -h -c

For example:

ePubFixer_cli.exe -f Rakshasa.epub -t -h -c

It should say:

TOC has been created

This resolves the issue with the error. But the ePub will still not verify because, while the error is gone, the warning remains. To solve that warning, you need to rename the .epub to a .zip and open it.

You want to go into /OPS/ and copy out the toc.ncx file.

Open it up in Notepad. Look for the "head" area. It should be near the beginning and look something like this:

</meta>
</meta>
</meta>
</meta>

Now, you want to find that part that says:

(NOTE THAT THE NUMBERS WILL LOOK DIFFERENT ON YOUR ePUB, consult the error above for the exact numbers if you need them, but it should be fairly obvious which line it is)

And change it to:

Again remembering not to change the numbers.

Okay. Save that file, then re-add it back to the .zip. Rename the .zip to a .epub, and there you have it. That file should now verify.

If anyone needs more information, I can post it here. 

Good luck!


----------



## Sever Bronny (May 13, 2013)

I sincerely appreciate the effort you put into this. I've bookmarked it in case I run into this problem.

Again, thanks for sharing it here


----------



## Zelah Meyer (Jun 15, 2011)

I plan to use Smashwords with my next book - but this is still handy to know in case I need to upload an epub direct anywhere.

Thank you for taking the time to work this out/put this together!


----------



## Mark McGuinness (Jul 16, 2012)

Thank you. Haven't noticed this yet, but bookmarking just in case, could be a godsend.


----------



## hardnutt (Nov 19, 2010)

David, I'm in AWE! Wish I understood this stuff. I don't think I ever will as it just makes my eyes glaze over...

Luckily, I haven't yet needed to upload direct to Apple, though I may use drafttodigital (or whatever it's called) in the future.

I'm bookmarking your instructions. By God, I'll need 'em!

Sincere thanks for all your trouble, from this techno-thickie.  
Geraldine


----------



## Carradee (Aug 21, 2010)

I've found it helps to keep spaces out of my document titles in the Scrivener Binder. I'm on a Mac, and your fix is Windows-only, so I mention that just in case it could help someone.


----------



## Andre Jute (Dec 18, 2010)

Thanks for sharing, David. People on Macs could also be using Pages to make their ePubs; I do. I wonder whether the problem affects Pages ePubs as well.


----------



## KellyHarper (Jul 29, 2012)

I *really* hope I don't run into this. I have a new release that I'll be uploading today!

How much are you charging for a quick fix?


----------



## beccaprice (Oct 1, 2011)

Oh, thank goodness. I thought it was something I was doing wrong when this started happening to me.

I use Sigil to make the changes, and got a lot of help from people in the Sigil forum at Mobilreads.


----------



## Tim_A (May 25, 2013)

This happened to me a few days ago when I wanted to send an update to iTunes (Scrivener for Mac). I didn't see anything on Google, but what fixed it for me was loading the epub into Sigil and then have Sigil build a new table of contents. Then it validated fine.


----------



## Mark Philipson (Mar 9, 2013)

I had that issue and fixed it in Sigil. The Flight Check in Sigil verified. The Online checker threw a warning. The Command Line Java validator passed. Upload to Kindle Okay.


----------



## PeggyI (Jan 9, 2011)

David Adams said:


> You want to go into /OPS/ and copy out the toc.ncx file.
> 
> Open it up in Notepad. Look for the "head" area. It should be near the beginning and look something like this:
> 
> ...


Thank you David for all this work. Unfortunately I still have no idea what all that stuff is for...


----------



## David Adams (Jan 2, 2012)

PeggyI said:


> Thank you David for all this work. Unfortunately I still have no idea what all that stuff is for...


It's reeeeeeeeeeeeeeeally complicated. :/ But basically, yeah. I can provide pictures if you like, or as others have pointed out, if you put them into Sigil and then save them again, that fixes it too apparently. 

I didn't even think to try that. It's my software engineer brain at work... problem? Let's dive into the code!


----------



## RuthNestvold (Jan 4, 2012)

I think I'll go for the Sigil fix too.  I recently had a file rejected for the Apple store, but I haven't gotten around to fixing it yet.


----------



## Gennita Low (Dec 13, 2012)

I have no idea what David wrote  but if I upload a Word file to D2D and get their epub file for use, I'm okay right?

Right?

Sigh. Sometimes it's worth it for me to use my book earnings to hire a formatter who understands the stuff David talks about!

Thank you for sharing. I'll endeavor to learn.


----------



## 10105 (Feb 16, 2010)

epubs generated from Calibre have almost always flunked the validator. It inserts deprecated HTML into the chapter files. The only way I got Sigil to fix it was to use Sigil's find/paste to remove that code. I dropped out of the Word->Mobipocket->Calibre procedure a while back just to lose the CSS bloat that you get with those programs. Here's a tutorial for how I do it now:

http://alstevens.blogspot.com/2013/04/a-gearheads-guide-to-e-book-publishing_8864.html


----------



## TexasGirl (Dec 21, 2011)

Scrivener needs to be notified so they can make the appropriate changes to their compile process.


----------



## Speaker-To-Animals (Feb 21, 2012)

> epubs generated from Calibre have almost always flunked the validator. It inserts deprecated HTML into the chapter files. The only way I got Sigil to fix it was to use Sigil's find/paste to remove that code. I dropped out of the Word->Mobipocket->Calibre procedure a while back just to lose the CSS bloat that you get with those programs. Here's a tutorial for how I do it now:


Epubs from calibre were fine, to fix that issue, you just needed to use an html file that didn't have spaces in the filename. (Talk about obscure eh?)

I've bugged this to Scrivener at [email protected] and [email protected]

From reading the "stuff" it isn't clear. Is this an actual epub failure or is the epub validator itself bugged?


----------



## Tim_A (May 25, 2013)

A year ago I'd have done the same (26 years under the belt as a software engineer), but I've done so little programming in the last 12 months that I'm getting out of the habit. Anyway, I've never really touched html, at least not much beyond nodding in the street.


----------



## 10105 (Feb 16, 2010)

Scrivener-generated epubs often flunk the validator even when there are no spaces in filenames. The validator's error messages are cryptic and ambiguous. I use those epubs during the project to load into my iPad to proofread, but for the final epub, I export to raw text and use the procedure I cited in the post above.


----------



## Cleo (Jan 11, 2013)

I think I'm going to be sick... half of my catalog is awaiting inspection at Apple (one of the books since March, the others for a month). They're all going to come back for failing ePub check. I can feel it.

Carradee, your fix is duly noted. Can't hurt to try. Thank you. And David, of course, you're a hero for doing all this work.


----------



## Mark Philipson (Mar 9, 2013)

I try to do three validations before submission and resolve issues encountered.


----------



## Cleo (Jan 11, 2013)

Al Stevens said:


> Scrivener-generated epubs often flunk the validator even when there are no spaces in filenames.


Gah! Bookmarking your link!

My titles did pass validation before I uploaded them, but Apple is so slow to approve me that maybe it's not up to current standards. But I only do it once. Why three times, Mark? Is the online checker that unreliable?


----------



## Mark Philipson (Mar 9, 2013)

Cleo said:


> My titles did pass validation before I uploaded them, but Apple is so slow to approve me that maybe it's not up to current standards. But I only do it once. Why three times, Mark? Is the online checker that unreliable?


I noticed the error mentioned on first validation in Sigil. I checked with online version and command line version and received same. Fixed code in Sigil. Passed there. Ran through online and received warning, not show stopper. Command line validated and upload to Kindle okay. I only do kindle. Not sure about other vendors. The online version has some limitations and is not recommended.


----------



## DRMarvello (Dec 3, 2011)

Nice work, David. I build my EPUBs by hand, so I appreciate the work you had to go through to reverse-engineer the files and identify the source of the problem. Finding someone else's bugs is never fun. 

I understand the value of enhancing the validator so it does a better job of validating. After all, they are only enforcing rules that were always there (not including a TOC and failing to put "urn:uuid:" on the uid meta tag content were always errors). But it sure sucks for people who use code generators that suddenly fail validation when they passed fine before.


----------



## Mark Philipson (Mar 9, 2013)

I think I'll run a test and send the error message results to Scrivener.


----------



## David Adams (Jan 2, 2012)

Gennita Low said:


> I have no idea what David wrote  but if I upload a Word file to D2D and get their epub file for use, I'm okay right?


It depends on the process Draft2Digitial use to create their ePubs, but it should be fine, yes.



TexasGirl said:


> Scrivener needs to be notified so they can make the appropriate changes to their compile process.


Yes, I think this is the issue. They WERE compliant, but the definition of "compliant" changed in the latest version, so they're not now. It's important to note that the definition was changed to make it _more_ accurate; it's simply finding bugs in code that existed, but couldn't be found before. If you validate using older versions of ePubChecker they will validate fine.

I really hope Scrivener fix it. I hate having to manually fix all my files before upload.



Cleo said:


> I think I'm going to be sick... half of my catalog is awaiting inspection at Apple (one of the books since March, the others for a month). They're all going to come back for failing ePub check. I can feel it.


If you're worried they'll fail, there's an online validator here: http://validator.idpf.org/

Upload them using the buttons, it should tell you if you're going to fail or not.



Mark Philipson said:


> I think I'll run a test and send the error message results to Scrivener.


Honestly that's the best thing anyone can do. Show them that the bug exists and hopefully soon they fix it.


----------



## 69959 (May 14, 2013)

It looks like you put a lot of work into that! That said, I hope that Scrivener fixes the problem before I need to upload any epubs.


----------



## Speaker-To-Animals (Feb 21, 2012)

Scrivener support says the fix is already coded for the Mac and will be in the next release. They are working on it for the PC version.


----------



## 68564 (Mar 17, 2013)

Thanks for this! Thankfully I use Sigil in my flow, so my stuff should all still be good.  But if not, at least I know the fix now.


----------



## Clare K. R. Miller (Apr 6, 2011)

Katie Elle said:


> Scrivener support says the fix is already coded for the Mac and will be in the next release.


Great to know! Thanks, Katie! Hopefully that next release will be before I have anything new to upload (likely).

And thanks, David, for doing all this hard work for us. You're awesome


----------



## Cherise (May 13, 2012)

Yay! Scrivener says they are working on fixing this!

------------------------
Hello Cherise,

Unfortunately, this is an issue which has occurred not because of a shortcoming in Scrivener, but because the ePub validator in question has (very) recently changed its requirements (creating a standard that didn't previously exist). We began working on a fix the moment that we became aware of the problem. It will be fixed in the very next release of Scrivener, both for Windows and the Mac.

Jeff
Literature and Latte Support
----------------------

I replied and asked if they will be pushing out notification of the new release.


----------



## Cherise (May 13, 2012)

Scrivener support says:

----------------quote-----------
Just the regular notifications, which includes a notification when you launch the program.
-------------end quote---------------


----------



## 60865 (Jun 11, 2012)

I'm happy it's getting fixed, somewhere in the middle of your post my brain melted.


----------



## Speaker-To-Animals (Feb 21, 2012)

No One Stars Please.


----------



## Amanda Brice (Feb 16, 2011)

Thank you so much, David! I just got this error this morning, so this helps.


----------



## Incognita (Apr 3, 2011)

I didn't run them through the .epub checker, but the last two .epub files I generated from Scrivener (Mac version) uploaded to Apple and everywhere else without a hitch


----------



## Amanda Brice (Feb 16, 2011)

I couldn't figure out how to do this (thank you David for the instructions, but I'm such a Luddite it made my eyes glaze over), but instead I used Dannika's suggestion to upload the Mobi to www.2epub.com and coverted it that way, and now it works. Yay!


----------



## 10105 (Feb 16, 2010)

ChristinePope said:


> I didn't run them through the .epub checker, but the last two .epub files I generated from Scrivener (Mac version) uploaded to Apple and everywhere else without a hitch


That's not always a reliable experience. I uploaded two books through D2D to Apple. They rejected one and accepted the other. Both books had the problems they cited for rejecting only one of them. (Failed the epub check and links to other Amazon books.)


----------



## CraigInOregon (Aug 6, 2010)

Good news!

I just downloaded and installed the latest-n-greatest update for Scrivener for PC. (v1.6.0.0)

It appears that, among a huge laundry list of fixes, issues with the compiler were addressed.

Those using Scrivener on Windows, get your update and see if it helps!


----------



## JRHenderson (Dec 4, 2011)

CraigInTwinCities said:


> I just downloaded and installed the latest-n-greatest update for Scrivener for PC. (v1.6.0.0)
> 
> It appears that, among a huge laundry list of fixes, issues with the compiler were addressed.


Yes, according to Literature & Latte's "Announcements" forum, version 1.6.0 of Scrivener for Windows was released on the 12th of August.

However, Scrivener for Mac hasn't been updated since the 8th of March...


----------



## jackz4000 (May 15, 2011)

Yeah, downloaded. That Epub 3 problem is fixed.


----------



## MorganKegan (Jan 10, 2013)

JRHenderson said:


> Yes, according to Literature & Latte's "Announcements" forum, version 1.6.0 of Scrivener for Windows was released on the 12th of August.
> 
> However, Scrivener for Mac hasn't been updated since the 8th of March...


There is a beta version available (look in the Mac beta forum on their site) that has the fix for the epub check problem. I'm using it right now, and in addition to that fix, it has some other pretty nice changes.


----------



## JRHenderson (Dec 4, 2011)

MorganKegan said:


> There is a beta version available (look in the Mac beta forum on their site) that has the fix for the epub check problem. I'm using it right now, and in addition to that fix, it has some other pretty nice changes.


Thank you Morgan; I wasn't aware that newer (beta) versions of Scrivener were available for download.


----------

