如何使用 System.IO.Compression.ZipArchive 创建 ePub? [英] How to create ePub with System.IO.Compression.ZipArchive?

查看:33
本文介绍了如何使用 System.IO.Compression.ZipArchive 创建 ePub?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经编写了一些使用 .NET 4.5 System.IO.Compression.ZipArchive 生成​​ ePub 存档的代码.我需要它成为可移植类库 (PCL) 的一部分,因此使用 .NET fx 的一个子集.

I've written some code generating ePub archive using .NET 4.5 System.IO.Compression.ZipArchive. I need this to be part of a Portable Class Library (PCL), hence using a subset of .NET fx.

我对包含魔法application/epub+zip"的 mimetype 文件有疑问.阅读规范后,我首先添加该文件,不进行压缩.

I have issue with the mimetype file containing the magic 'application/epub+zip'. Having read the specs, I add that file first with no compression.

尽管如此,但生成的 ePub 存档并不符合规范.规范要求 mimetype 文件的内容应从位置 38 开始.我的从位置 47 开始.

Despite this care, the produced ePub archive isn't conforming to specs. Specs demand the content of the mimetype file should start at position 38. Mine starts at position 47.

ZipArchive 本身没有任何参数,ZipArchiveEntry 只能通过压缩模式进行参数化.我有点困惑,因为我认为 Zip 文件只有一种,而且我不明白是什么影响了这种特定行为.

There isn't any parameter on ZipArchive itself and ZipArchiveEntry can only be parametrized by compression mode only. I'm a bit confused since I thought Zip files came in one variety and I don't understand what influences this specific behaviour.

作为参考,以下是示例 ePub 的第一部分(即工作):

For reference, here are the first bits of a sample ePub (working that is):

这是我的:

推荐答案

我确实遵循了 Nickolay 的建议,我使用 DotNetZip 创建了一个只有 mimetype 文件的存档,并使用该文件作为其他 epub 的起点.

I did follow Nickolay's advice, I used DotNetZip to create an archive with only the mimetype file in it and use that file as a starting point for other epubs.

这种方法允许我在遵守 ePub 规范的同时使用 ZipArchive 及其异步接口.

This approach allows me to use ZipArchive and its async interface while respecting ePub's specs.

这篇关于如何使用 System.IO.Compression.ZipArchive 创建 ePub?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆