bell notificationshomepageloginedit profileclubsdmBox

10.02% popularity   0 Reactions

I am using the C# library DotNetZip (Ionic.Zip and Ionic.Zlib) to generate an ebook from a directory. Directory looks like this:

BookName
|
|___content/
| images/
| css/
| (html pages, .ops, .ncx)
|
|___META-INF/
| container.xml
|
|___mimetype

The code to generate the archive looks like this:

using (ZipFile zip = new ZipFile(pathTemp + ".epub"))
{
zip.RemoveSelectedEntries("*.*");
zip.AddFile(mimetype, "").CompressionLevel = CompressionLevel.None;
zip.AddDirectory(pathTemp + "content", "content");
zip.AddDirectory(pathTemp + "META-INF", "META-INF");
zip.Save();
}

When I run it through the EPUB Validator, it throws this error:

The mimetype file has an extra field of length 36. The use of the extra field feature of the ZIP format is not permitted for the mimetype file.

I'm not compressing the mimetype file, so I don't know what is happening.

UPDATE: This problem has been solved; see the solution here.


Free books android app tbrJar TBR JAR Read Free books online gutenberg


Load Full (2)

Login to follow story

More posts by @Radia

2 Comments

Sorted by latest first Latest Oldest Best

 

@Sarah

10% popularity   0 Reactions

I'm responsible for an attempt to improve this error message, see github.com/IDPF/epubcheck/pull/497 for details. Essentially your Zip packer puts some application or operating system specific stuff into the file, which breaks EPUB mimetype magic number support.


Free books android app tbrJar TBR JAR Read Free books online gutenberg


Load Full (0)

 

@James

10% popularity   0 Reactions

Ive also had some problems with compression of the mimetype file. What I ended up doing was adding the entry myself from a byte[].

using (ZipOutputStream zs = new ZipOutputStream(pathTemp + ".epub"))
{
var o = zs.PutNextEntry("mimetype");
o.CompressionLevel = CompressionLevel.None;
byte[] mimetype = System.Text.Encoding.ASCII.GetBytes("application/epub+zip");
zs.Write(mimetype, 0, mimetype.Length);
}

using (ZipFile zip = new ZipFile(pathTemp + ".epub"))
{
zip.RemoveSelectedEntries("*.*");
zip.AddDirectory(pathTemp + "content", "content");
zip.AddDirectory(pathTemp + "META-INF", "META-INF");
zip.Save();
}

This should fix it for you.


Free books android app tbrJar TBR JAR Read Free books online gutenberg


Load Full (0)

 

Back to top