Functions¶
Most functionality is provided by member functions of class objects. There are just a couple of top level configuration functions listed here.
- mupdf.installLoadFontFunction(callback)¶
Install a handler to load system (or missing) fonts.
The callback function will be called with four arguments:
callback(fontName, scriptName, isBold, isItalic)
The callback should return either a
Fontobject for the requested font, ornullif an exact match cannot be found (so that the font loading machinery can keep looking through the chain of fallback fonts).
- mupdf.enableICC()¶
Enable ICC-profiles based operation.
- mupdf.disableICC()¶
Disable ICC-profiles based operation.
- mupdf.emptyStore()¶
Empty all cached entries from the store.
- mupdf.shrinkStore(percent)¶
Remove cached entries from the store until it holds less data than the specified threshold.
If the store was initialized with a limit, the threshold is a percentage of the limit. If the store is unlimited in size, the threshold is a percentage of what the store currently holds.
Returns a boolean indicating whether or not the store was able to be shrunk to below the threshold.
- Arguments:
percent (
number)
- Returns:
boolean
- mupdf.setUserCSS(stylesheet, useDocumentStyles)¶
Set a style sheet to apply to all reflowable documents.
- Arguments:
stylesheet (
string) – The CSS text to use.useDocumentStyles (
boolean) – Whether to respect the document’s own style sheet.
- mupdf.setLog(logger)¶
Install a custom logging object to catch warnings and errors.
The logger should be an object with separate “warning” and “error” methods.
mupdf.setLog({ error(msg) { console.error("MuPDF ERROR: " + msg) }, warning(msg) { console.warn("MuPDF WARNING: " + msg) }, })
You can also pass in a single function to be used to report both errors and warnings:
mupdf.setLog(console.log)