Archive¶
only mutool run
Constructors¶
- class Archive(path)¶
Create a new archive based either on a tar- or zip-file or the contents of a directory.
- Arguments:
path (
string) – Path string to the archive file or directory.
var archive1 = new mupdf.Archive("example1.zip") var archive2 = new mupdf.Archive("example2.tar") var archive3 = new mupdf.Archive("images/")
- class Archive(buffer)¶
Create a new archive based either on a tar- or zip-file contained in a buffer.
- Arguments:
buffer (
Buffer | ArrayBuffer | Uint8Array | string) – Buffer containing a archive.
var archive1 = new mupdf.Archive(fs.readFileSync("example1.zip")) var archive2 = new mupdf.Archive(fs.readFileSync("example1.tar"))
Instance methods¶
- Archive.prototype.getFormat()¶
Returns a string describing the archive format.
- Returns:
string
var archive = new mupdf.Archive("example1.zip") print(archive.getFormat())
- Archive.prototype.countEntries()¶
Returns the number of entries in the archive.
- Returns:
number
var archive = new mupdf.Archive("example1.zip") var numEntries = archive.countEntries()
- Archive.prototype.listEntry(idx)¶
Returns the name of entry number idx in the archive, or null if idx is out of range.
- Arguments:
idx (
number) – Entry index.
- Returns:
string | null
var archive = new mupdf.Archive("example1.zip") var entry = archive.listEntry(0)
- Archive.prototype.hasEntry(name)¶
Returns true if an entry of the given name exists in the archive.
- Arguments:
name (
string) – Entry name to look for.
- Returns:
boolean
var archive = new mupdf.Archive("example1.zip") var hasEntry = archive.hasEntry("file1.txt")
Examples¶
var archive = new mupdf.Archive("example1.zip")
var n = archive.countEntries()
for (var i = 0; i < n; ++i) {
var entry = archive.listEntry(i)
var contents = archive.readEntry(entry)
console.log("entry", entry, contents.length)
}