Closed enkuso closed 11 years ago
Problem is
(http://www.jedisaber.com/eBooks/Tutorial.shtml) mimetype This file is just a plain ASCII text file that contains the line: "application/epub+zip" The operating system can look at this file to figure out what a .epub file is instead of using the file extension. This file must be the first file in the zip file, and must not be compressed.
So I did, 1st: mimetype file added first to zip file. So I modified Toolkit.php file. on line 104: $zip->addFromString('mimetype', file_get_contents($source.'/mimetype')); in line 120: } elseif (is_file($file) && str_replace($source . '/', '', $file) != 'mimetype') {
With this changes mimetype file added first to archive but ZipArchive compress it. Validator gives Mimetype contains wrong type (application/epub+zip expected). error message.
2nd:
in Toolkit.php file on line 97 $zip = new \ZipArchive();
PHP's ZipArchive does not support compression method, so mimetype file is compressed in archive. So nevermind create epub file with ZipArchive. (https://bugs.php.net/bug.php?id=41243)
Did I understand correctly? I stucked in this issue very badly :(
Found a solution for mimetype issue.
create archive file first with mimetype file and then add other contents to archive.
in Toolkit.php about line 96
// make the archive first
file_put_contents($destination, base64_decode("UEsDBAoAAAAAAOmRAT1vYassFAAAABQAAAAIAAAAbWltZXR5cGVhcHBsaWNhdGlvbi9lcHViK3ppcFBLAQIUAAoAAAAAAOmRAT1vYassFAAAABQAAAAIAAAAAAAAAAAAIAAAAAAAAABtaW1ldHlwZVBLBQYAAAAAAQABADYAAAA6AAAAAAA="));
$zip = new \ZipArchive();
if (($err = $zip->open($destination)) !== TRUE){
return false;
}
and does not allow mimetype file while adding
} elseif (is_file($file) && str_replace($source . '/', '', $file) != 'mimetype') {
with this changes created epub file surpass validator :)
epub output validation fails
checked at http://validator.idpf.org
Results
Detected version: Could not determine version.
Results: The following problems were found in book.epub:
Type File Line Position Message ERROR -1 -1 Length of the first filename in archive must be 8, but was 9 ! ERROR OEBPS/content.opf 7 66 character content of element "dc:identifier" invalid; must be a string with length at least 1 (actual length was 0) ERROR OEBPS/toc.ncx 4 94 value of attribute "xml:lang" is invalid; must be an RFC 3066 language identifier WARNING -1 -1 zip file contains empty directory OEBPS/images/ ERROR OEBPS/chapter-2.html 128 114 'OEBPS/./chapter-3.html': referenced resource missing in the package Validated using EpubCheck version 3.0b5-pre.
also http://www.magicscroll.net/ Chrome extension cannot process output file.