mupdf/document.lisp
A MuPDF context: its allocator, its store, and its error stack.
Open a MuPDF context with the document handlers registered.
no context for claimed version ~S; ~
set luv.MUPDF:*mupdf-version* to the library's FZ_VERSION
Documents
True when pathname begins with a PDF header.
This is a guard, not a validation. MuPDF reports a broken file by longjmp to a handler this binding cannot install, and with none on the stack it takes the process with it -- so the cheapest thing that catches the ordinary mistake of handing it something that is not a PDF at all is worth doing.
Open pathname. A context is made for the document unless one is given.
Measuring
Pixels
Render page number at scale and return height by width packed rgba words.
The words are alpha in the high byte and red in the third, which is what a CLIM pattern wants, so the result can be handed straight to MAKE-PATTERN.
Text
MuPDF serializes structured text to XML itself, so the positions come out of a documented format rather than out of struct offsets this system would otherwise have to grovel. The XML is regular enough to scan without a parser: what is wanted is the font size in force, and each character with the box it occupies.
Where the pen actually sits. X and Y are the line's box; a renderer setting the line from glyph outlines wants the baseline the document wrote it on, which is the first character's own origin.
A decimal number out of string, without going through READ.
The values in this XML are all plain decimals, and READ on text that came out of a document is a wider door than this needs to open.
Every space-separated decimal in string, in order.
The value of attribute name in the tag beginning at start, or NIL.
MuPDF escapes the characters that would end a tag or a quoted value, so the end of the tag and the end of the value can both be found by looking for the literal character.
The code point in a reference body like "#8217" or "#x201c", or NIL.
The five escapes MuPDF's writer emits, turned back into characters.
Everything outside ASCII comes back as a numeric reference, which for a typeset document means every curly quote and dash in it.
Page number's text as one TEXT-RUN per typeset line.
Positions are in PDF points with the origin at the page's top left, which is the orientation MuPDF's structured text already uses and the one a drawing surface wants.
MuPDF writes the font after the line it applies to, so a line is held back until the font element that follows names its size.
Page number's structured text, as MuPDF's own XML.
A MuPDF context: its allocator, its store, and its error stack.
(&key (max-store (* 256 1024 1024)))Multiplication and scalar scaling.
(&optional directory)Logical disjunction of tests and raw truth values.
The FZ_VERSION string to claim, or NIL to read it from the library path.
(directory)Logical conjunction of tests and raw truth values.
(context)((variable &rest options) &body body)An open document and the context it was opened in.
((call tool-call) stream)(document)(pathname)True when PATHNAME begins with a PDF header. This is a guard, not a validation. MuPDF reports a broken file by longjmp to a handler this binding cannot install, and with none on the stack it takes the process with it -- so the cheapest thing that catches the ordinary mistake of handing it something that is not a PDF…
Test whether two compatible scalars are equal.
(pathname &key context)(document)((variable pathname &rest options) &body body)((variable document number) &body body)(document number)(&optional (text *page*) (name "test"))(document number)Subtraction or unary negation.
(document number &key (scale 1.0))Render page NUMBER at SCALE and return HEIGHT by WIDTH packed RGBA words. The words are alpha in the high byte and red in the third, which is what a CLIM pattern wants, so the result can be handed straight to MAKE-PATTERN.
Convert one scalar float or unsigned value to a 32-bit float.
Addition over compatible quantities.
(string &key (start 0) (end (length string)))A decimal number out of STRING, without going through READ. The values in this XML are all plain decimals, and READ on text that came out of a document is a wider door than this needs to open.
Test whether one compatible scalar is less than another.
Division of two represented quantities.
(string)(text start name)The value of attribute NAME in the tag beginning at START, or NIL. MuPDF escapes the characters that would end a tag or a quoted value, so the end of the tag and the end of the value can both be found by looking for the literal character.
Test whether one compatible scalar is at most another.
Test whether one compatible scalar is greater than another.
(string)(document number)Page NUMBER's text as one TEXT-RUN per typeset line. Positions are in PDF points with the origin at the page's top left, which is the orientation MuPDF's structured text already uses and the one a drawing surface wants. MuPDF writes the font after the line it applies to, so a line is held back until the font element…
(document number)
Documents, pages, and what a page can be turned into.
Everything here owns a C object and is responsible for dropping it, so the objects are CLOS instances with explicit closers and WITH- macros rather than pointers handed around bare. MuPDF's own ownership rule is that a context outlives everything made from it, which is why the document keeps a reference to its context rather than the other way round.