fix getsup (HH)
[luatex.git] / manual / luatex-backend.tex
blob40b6472118816b916ae102658db248fbfee350f7
1 % language=uk
3 \environment luatex-style
4 \environment luatex-logos
6 \startcomponent luatex-backend
8 \startchapter[reference=backend,title={The backend libraries}]
10 \section{The \type {pdf} library}
12 This library contains variables and functions that are related to the \PDF\
13 backend. You can find more details about the expected values to setters in \in
14 {section} [backendprimitives].
16 \subsection{\type {mapfile}, \type {mapline}}
18 \startfunctioncall
19 pdf.mapfile(<string> map file)
20 pdf.mapline(<string> map line)
21 \stopfunctioncall
23 These two functions can be used to replace primitives \type {\pdfmapfile} and
24 \type {\pdfmapline} inherited from \PDFTEX. They expect a string as only
25 parameter and have no return value. The first character in a map line can be
26 \type {-}, \type {+} or \type {=} which means as much as remove, add or replace
27 this line.
29 \subsection {\type {[set|get][catalog|info|names|trailer]}}
31 These functions complement the corresponding \PDF\ backend token lists dealing
32 with metadata. The value types are strings and they are written out to the \PDF\
33 file directly after the token registers.
35 \subsection {\type {[set|get][pageattributes|pageresources|pagesattributes]}}
37 These functions complement the corresponding \PDF\ backend token lists dealing
38 with page resources. The variables have no interaction with the corresponding \PDF\
39 backend token register. They are written out to the \PDF\ file directly after the
40 token registers.
42 \subsection{\type {[set|get][xformattributes|xformresources]}}
44 These functions complement the corresponding \PDF\ backend token lists dealing
45 with reuseable boxes and images. The variables have no interaction with the
46 corresponding \PDF\ backend token register. They are written out to the \PDF\
47 file directly after the token registers.
49 \subsection{\type {getversion} and \type {[set|get]minorversion}}
51 The version is frozen in the binary but you can set the minor version. What minor
52 version you set depends on what \PDF\ features you use. This is out of control
53 of \LUATEX.
55 \subsection{\type {getcreationdate}}
57 This function returns a string with the date in the format that ends up in the
58 \PDF\ file, in this case it's: {\tttf \cldcontext{pdf.getcreationdate()}}.
60 \subsection{\type {[set|get]inclusionerrorlevel}, \type {[set|get]ignoreunknownimages}}
62 These variable control how error in included image are treated. They are modeled
63 after the \PDFTEX\ equivalents.
65 \subsection{\type {[set|get]suppressoptionalinfo}}
67 This bitset determnines what kind of info gets flushes. By default we flush all.
69 \subsection{\type {[set|get]trailerid}}
71 You can set your own trailer id. This has to be a valid array string
72 with checksums.
74 \subsection{\type {[set|get]compresslevel}}
76 These two functions set the level of compression. The minimum value is~0,
77 the maximum is~9.
79 \subsection{\type {[set|get]objcompresslevel}}
81 These two functions set the level of compression. The minimum value is~0,
82 the maximum is~9.
84 \subsection{\type {[set|get]gentounicode}}
86 This flag enables tounicode generation (like in \PDFTEX).
88 \subsection{\type {[set|get]omitcidset}}
90 This flag disables inclusion of a so called CIDSet which can be handy when aiming
91 at some of the many \PDF\ substandards.
93 \subsection{\type {[set|get]decimaldigits}}
95 These two functions set the accuracy of floats written to the \PDF file. You can
96 set any value but the backend will not go below~3 and above~6.
98 \subsection{\type {[set|get]pkresolution}}
100 These setter takes two arguments: the resolution and an optional zero or one that
101 indicates if this is a fixed one. The getter returns these two values.
103 \subsection{\type {getlast[obj|link|annot]} and \type {getretval}}
105 These status variables are similar to the ones traditionally used in the backend
106 interface at the \TEX\ end.
108 \subsection{\type {maxobjnum} and \type {objtype}, \type {fontname}, \type {fontobjnum},
109 \type {fontsize}, \type {xformname}}.
111 These (and some other) introspective helpers were moved from the the \type {tex}
112 namespace to the \type {pdf} namespace but kept their original names. They are
113 mostly used when you construct \PDF\ objects yourself and need for instance
114 information about a (to be) embedded font.
116 \subsection{\type {[set|get]origin}}
118 This one is used to set the horizonal and|/|or vertical offset, a traditional
119 backend property.
121 \starttyping
122 pdf.setorigin() -- sets both to 0pt
123 pdf.setorigin(tex.sp("1in")) -- sets both to 1in
124 pdf.setorigin(tex.sp("1in"),tex.sp("1in"))
125 \stoptyping
127 The counterpart of this function returns two values.
129 \subsection{\type {[set|get]imageresolution}}
131 These two functions relate to the imageresolution that is used when the image
132 itself doesn't provide a non|-|zero x or y resolution.
134 \subsection {\type {[set|get][link|dest|thread|xform]margin}}
136 These functions can be used to set and retrieve the margins that are added to the
137 natural bounding boxes of the respective objects.
139 \subsection {\type {get[pos|hpos|vpos]}}
141 These function get current location on the output page, measured from its lower
142 left corner. The values return scaled points as units.
144 \starttyping
145 local h, v = pdf.getpos()
146 \stoptyping
148 \subsection {\type {[has|get]matrix}}
150 The current matrix transformation is available via the \type {getmatrix} command,
151 which returns 6 values: \type {sx}, \type {rx}, \type {ry}, \type {sy}, \type
152 {tx}, and \type {ty}. The \type {hasmatrix} function returns \type {true} when a
153 matrix is applied.
155 \starttyping
156 if pdf.hasmatrix() then
157 local sx, rx, ry, sy, tx, ty = pdf.getmatrix()
158 -- do something useful or not
160 \stoptyping
162 \subsection {\type {print}}
164 You can print string to the \PDF\ document from within a within a \type
165 {\latelua} call. This function is not to be used inside \type {\directlua} unless
166 you know {\it exactly} what you are doing.
168 \startfunctioncall
169 pdf.print(<string> s)
170 pdf.print(<string> type, <string> s)
171 \stopfunctioncall
173 The optional parameter can be used to mimic the behavior of \PDF\ literals: the
174 \type {type} is \type {direct} or \type {page}.
176 \subsection {\type {immediateobj}}
178 This function creates a \PDF\ object and immediately writes it to the \PDF\ file.
179 It is modelled after \PDFTEX's \type {\immediate} \type {\pdfobj} primitives. All
180 function variants return the object number of the newly generated object.
182 \startfunctioncall
183 <number> n =
184 pdf.immediateobj(<string> objtext)
185 <number> n =
186 pdf.immediateobj("file", <string> filename)
187 <number> n =
188 pdf.immediateobj("stream", <string> streamtext, <string> attrtext)
189 <number> n =
190 pdf.immediateobj("streamfile", <string> filename, <string> attrtext)
191 \stopfunctioncall
193 The first version puts the \type {objtext} raw into an object. Only the object
194 wrapper is automatically generated, but any internal structure (like \type {<<
195 >>} dictionary markers) needs to provided by the user. The second version with
196 keyword \type {file} as first argument puts the contents of the file with name
197 \type {filename} raw into the object. The third version with keyword \type
198 {stream} creates a stream object and puts the \type {streamtext} raw into the
199 stream. The stream length is automatically calculated. The optional \type
200 {attrtext} goes into the dictionary of that object. The fourth version with
201 keyword \type {streamfile} does the same as the third one, it just reads the
202 stream data raw from a file.
204 An optional first argument can be given to make the function use a previously
205 reserved \PDF\ object.
207 \startfunctioncall
208 <number> n =
209 pdf.immediateobj(<integer> n, <string> objtext)
210 <number> n =
211 pdf.immediateobj(<integer> n, "file", <string> filename)
212 <number> n =
213 pdf.immediateobj(<integer> n, "stream", <string> streamtext, <string> attrtext)
214 <number> n =
215 pdf.immediateobj(<integer> n, "streamfile", <string> filename, <string> attrtext)
216 \stopfunctioncall
218 \subsection{\type{obj}}
220 This function creates a \PDF\ object, which is written to the \PDF\ file only
221 when referenced, e.g., by \type {refobj()}.
223 All function variants return the object number of the newly generated object, and
224 there are two separate calling modes. The first mode is modelled after \PDFTEX's
225 \type {\pdfobj} primitive.
227 \startfunctioncall
228 <number> n =
229 pdf.obj(<string> objtext)
230 <number> n =
231 pdf.obj("file", <string> filename)
232 <number> n =
233 pdf.obj("stream", <string> streamtext, <string> attrtext)
234 <number> n =
235 pdf.obj("streamfile", <string> filename, <string> attrtext)
236 \stopfunctioncall
238 An optional first argument can be given to make the function use a previously
239 reserved \PDF\ object.
241 \startfunctioncall
242 <number> n =
243 pdf.obj(<integer> n, <string> objtext)
244 <number> n =
245 pdf.obj(<integer> n, "file", <string> filename)
246 <number> n =
247 pdf.obj(<integer> n, "stream", <string> streamtext, <string> attrtext)
248 <number> n =
249 pdf.obj(<integer> n, "streamfile", <string> filename, <string> attrtext)
250 \stopfunctioncall
252 The second mode accepts a single argument table with key--value pairs.
254 \startfunctioncall
255 <number> n = pdf.obj {
256 type = <string>,
257 immmediate = <boolean>,
258 objnum = <number>,
259 attr = <string>,
260 compresslevel = <number>,
261 objcompression = <boolean>,
262 file = <string>,
263 string = <string>
265 \stopfunctioncall
267 The \type {type} field can have the values \type {raw} and \type {stream}, this
268 field is required, the others are optional (within constraints).
270 Note: this mode makes \type{obj} look more flexible than it actually is: the
271 constraints from the separate parameter version still apply, so for example you
272 can't have both \type {string} and \type {file} at the same time.
274 \subsection {\type {refobj}}
276 This function, the \LUA\ version of the \type {\pdfrefobj} primitive, references an
277 object by its object number, so that the object will be written out.
279 \startfunctioncall
280 pdf.refobj(<integer> n)
281 \stopfunctioncall
283 This function works in both the \type {\directlua} and \type {\latelua} environment.
284 Inside \type {\directlua} a new whatsit node \quote {pdf_refobj} is created, which
285 will be marked for flushing during page output and the object is then written
286 directly after the page, when also the resources objects are written out. Inside
287 \type {\latelua} the object will be marked for flushing.
289 This function has no return values.
291 \subsection {\type {reserveobj}}
293 This function creates an empty \PDF\ object and returns its number.
295 \startfunctioncall
296 <number> n = pdf.reserveobj()
297 <number> n = pdf.reserveobj("annot")
298 \stopfunctioncall
300 \subsection {\type {registerannot}}
302 This function adds an object number to the \type {/Annots} array for the current
303 page without doing anything else. This function can only be used from within
304 \type {\latelua}.
306 \startfunctioncall
307 pdf.registerannot (<number> objnum)
308 \stopfunctioncall
310 \subsection {\type {newcolorstack}}
312 This function allocates a new color stack and returns it's id. The arguments
313 are the same as for the similar backend extension primitive.
315 \startfunctioncall
316 pdf.newcolorstack("0 g","page",true) -- page|direct|origin
317 \stopfunctioncall
319 \subsection {\type {setfontattributes}}
321 This function will force some additional code into the font resource. It can for
322 instance be used to add a custom \type {ToUnicode} vector to a bitmap file.
324 \startfunctioncall
325 pdf.setfontattributes(<number> font id, <string> pdf code)
326 \stopfunctioncall
328 \section {The \type {pdfscanner} library}
330 The \type {pdfscanner} library allows interpretation of \PDF\ content streams and
331 \type {/ToUnicode} (cmap) streams. You can get those streams from the \type
332 {epdf} library, as explained in an earlier section. There is only a single
333 top|-|level function in this library:
335 \startfunctioncall
336 pdfscanner.scan (<Object> stream, <table> operatortable, <table> info)
337 \stopfunctioncall
339 The first argument, \type {stream}, should be either a \PDF\ stream object, or a
340 \PDF\ array of \PDF\ stream objects (those options comprise the possible return
341 values of \type {<Page>:getContents()} and \type {<Object>:getStream()} in the
342 \type {epdf} library).
344 The second argument, \type {operatortable}, should be a \LUA\ table where the
345 keys are \PDF\ operator name strings and the values are \LUA\ functions (defined
346 by you) that are used to process those operators. The functions are called
347 whenever the scanner finds one of these \PDF\ operators in the content stream(s).
348 The functions are called with two arguments: the \type {scanner} object itself,
349 and the \type {info} table that was passed are the third argument to \type
350 {pdfscanner.scan}.
352 Internally, \type {pdfscanner.scan} loops over the \PDF\ operators in the
353 stream(s), collecting operands on an internal stack until it finds a \PDF\
354 operator. If that \PDF\ operator's name exists in \type {operatortable}, then the
355 associated function is executed. After the function has run (or when there is no
356 function to execute) the internal operand stack is cleared in preparation for the
357 next operator, and processing continues.
359 The \type {scanner} argument to the processing functions is needed because it
360 offers various methods to get the actual operands from the internal operand
361 stack.
363 A simple example of processing a \PDF's document stream could look like this:
365 \starttyping
366 function Do (scanner, info)
367 local val = scanner:pop()
368 local name = val[2] -- val[1] == 'name'
369 local resources = info.resources
370 local xobject = resources:lookup("XObject"):getDict():lookup(name)
371 print (info.space ..'Use XObject '.. name)
372 if xobject and xobject:isStream() then
373 local dict = xobject:getStream():getDict()
374 if dict then
375 local name = dict:lookup("Subtype")
376 if name:getName() == "Form" then
377 local newinfo = {
378 space = info.space .. " " ,
379 resources = dict:lookup("Resources"):getDict()
381 pdfscanner.scan(xobject, operatortable, newinfo)
387 operatortable = { Do = Do }
389 doc = epdf.open(arg[1])
390 pagenum = 1
392 while pagenum <= doc:getNumPages() do
393 local page = doc:getCatalog():getPage(pagenum)
394 local info = {
395 space = " " ,
396 resources = page:getResourceDict()
398 print('Page ' .. pagenum)
399 pdfscanner.scan(page:getContents(), operatortable, info)
400 pagenum = pagenum + 1
402 \stoptyping
404 This example iterates over all the actual content in the \PDF, and prints out the
405 found \type {XObject} names. While the code demonstrates quite some of the \type
406 {epdf} functions, let's focus on the type \type {pdfscanner} specific code
407 instead.
409 From the bottom up, the following line runs the scanner with the \PDF\ page's
410 top-level content.
412 \starttyping
413 pdfscanner.scan(page:getContents(), operatortable, info)
414 \stoptyping
416 The third argument, \type {info}, contains two entries: \type {space} is used to
417 indent the printed output, and \type {resources} is needed so that embedded \type
418 {XForms} can find their own content.
420 The second argument, \type {operatortable} defines a processing function for a
421 single \PDF\ operator, \type {Do}.
423 The function \type {Do} prints the name of the current \type {XObject}, and then
424 starts a new scanner for that object's content stream, under the condition that
425 the \type {XObject} is in fact a \type {/Form}. That nested scanner is called
426 with new \type {info} argument with an updated \type {space} value so that the
427 indentation of the output nicely nests, and with an new \type {resources} field
428 to help the next iteration down to properly process any other, embedded \type
429 {XObject}s.
431 Of course, this is not a very useful example in practise, but for the purpose of
432 demonstrating \type {pdfscanner}, it is just long enough. It makes use of only
433 one \type {scanner} method: \type {scanner:pop()}. That function pops the top
434 operand of the internal stack, and returns a \LUA\ table where the object at index
435 one is a string representing the type of the operand, and object two is its
436 value.
438 The list of possible operand types and associated \LUA\ value types is:
440 \starttabulate[|lT|p|]
441 \NC integer \NC <number> \NC \NR
442 \NC real \NC <number> \NC \NR
443 \NC boolean \NC <boolean> \NC \NR
444 \NC name \NC <string> \NC \NR
445 \NC operator \NC <string> \NC \NR
446 \NC string \NC <string> \NC \NR
447 \NC array \NC <table> \NC \NR
448 \NC dict \NC <table> \NC \NR
449 \stoptabulate
451 In case of \type {integer} or \type {real}, the value is always a \LUA\ (floating
452 point) number.
454 In case of \type {name}, the leading slash is always stripped.
456 In case of \type {string}, please bear in mind that \PDF\ actually supports
457 different types of strings (with different encodings) in different parts of the
458 \PDF\ document, so may need to reencode some of the results; \type {pdfscanner}
459 always outputs the byte stream without reencoding anything. \type {pdfscanner}
460 does not differentiate between literal strings and hexadecimal strings (the
461 hexadecimal values are decoded), and it treats the stream data for inline images
462 as a string that is the single operand for \type {EI}.
464 In case of \type {array}, the table content is a list of \type {pop} return
465 values and in case of \type {dict}, the table keys are \PDF\ name strings and the
466 values are \type {pop} return values.
468 \blank
470 There are few more methods defined that you can ask \type {scanner}:
472 \starttabulate[|lT|p|]
473 \NC pop \NC as explained above \NC \NR
474 \NC popNumber \NC return only the value of a \type {real} or \type {integer} \NC \NR
475 \NC popName \NC return only the value of a \type {name} \NC \NR
476 \NC popString \NC return only the value of a \type {string} \NC \NR
477 \NC popArray \NC return only the value of a \type {array} \NC \NR
478 \NC popDict \NC return only the value of a \type {dict} \NC \NR
479 \NC popBool \NC return only the value of a \type {boolean} \NC \NR
480 \NC done \NC abort further processing of this \type {scan()} call \NC \NR
481 \stoptabulate
483 The \type {popXXX} are convenience functions, and come in handy when you know the
484 type of the operands beforehand (which you usually do, in \PDF). For example, the
485 \type {Do} function could have used \type {local name = scanner:popName()}
486 instead, because the single operand to the \type {Do} operator is always a \PDF\
487 name object.
489 The \type {done} function allows you to abort processing of a stream once you
490 have learned everything you want to learn. This comes in handy while parsing
491 \type {/ToUnicode}, because there usually is trailing garbage that you are not
492 interested in. Without \type {done}, processing only end at the end of the
493 stream, possibly wasting \CPU\ cycles.
495 \section{The \type {epdf} library}
497 The \type {epdf} library provides \LUA\ bindings to many \PDF\ access functions
498 that are defined by the poppler \PDF\ viewer library (written in C$+{}+$ by
499 Kristian H\o gsberg, based on xpdf by Derek Noonburg). Within \LUATEX\ xpdf
500 functionality is being used since long time to embed \PDF\ files. The \type
501 {epdf} library allows to scrutinize an external \PDF\ file. It gives access to
502 its document structure: catalog, cross|-|reference table, individual pages,
503 objects, annotations, info, and metadata. The \type {epdf} library only provides
504 read|-|only acess. At some point we might decide to limit the interface to a
505 reasonable subset.
507 For a start, a \PDF\ file is opened by \type {epdf.open()} with file name, e.g.:
509 \starttyping
510 doc = epdf.open("foo.pdf")
511 \stoptyping
513 This normally returns a \type {PDFDoc} userdata variable; but if the file could
514 not be opened successfully, instead of a fatal error just the value \type {nil} is
515 returned.
517 All \LUA\ functions in the \type {epdf} library are named after the poppler
518 functions listed in the poppler header files for the various classes, e.g., files
519 \type {PDFDoc.h}, \type {Dict.h}, and \type {Array.h}. These files can be found
520 in the poppler subdirectory within the \LUATEX\ sources. Which functions are
521 already implemented in the \type {epdf} library can be found in the \LUATEX\
522 source file \type {lepdflib.cc}. For using the \type {epdf} library, knowledge of
523 the \PDF\ file architecture is indispensable.
525 There are many different userdata types defined by the \type {epdf} library,
526 currently these are \type {AnnotBorderStyle}, \type {AnnotBorder}, \type
527 {Annots}, \type {Annot}, \type {Array}, \type {Attribute}, \type {Catalog}, \type
528 {Dict}, \type {EmbFile}, \type {GString}, \type {LinkDest}, \type {Links}, \type
529 {Link}, \type {ObjectStream}, \type {Object}, \type {PDFDoc}, \type
530 {PDFRectangle}, \type {Page}, \type {Ref}, \type {Stream}, \type {StructElement},
531 \type {StructTreeRoot} \type {TextSpan}, \type {XRefEntry} and \type {XRef}.
533 All these userdata names and the \LUA\ access functions closely resemble the
534 classes naming from the poppler header files, including the choice of mixed upper
535 and lower case letters. The \LUA\ function calls use object|-|oriented syntax,
536 e.g., the following calls return the \type {Page} object for page~1:
538 \starttyping
539 pageref = doc:getCatalog():getPageRef(1)
540 pageobj = doc:getXRef():fetch(pageref.num, pageref.gen)
541 \stoptyping
543 But writing such chained calls is risky, as an intermediate function may return
544 \type {nil} on error. Therefore between function calls there should be \LUA\ type
545 checks (e.g., against \type {nil}) done. If a non|-|object item is requested (for
546 instance a \type {Dict} item by calling \type {page:getPieceInfo()}, cf.~\type
547 {Page.h}) but not available, the \LUA\ functions return \type {nil} (without
548 error). If a function should return an \type {Object}, but it's not existing, a
549 \type {Null} object is returned instead, also without error. This is in|-|line
550 with poppler behavior.
552 All library objects have a \type {__gc} metamethod for garbage collection. The
553 \type {__tostring} metamethod gives the type name for each object.
555 These are the object constructors:
557 \startfunctioncall
558 <PDFDoc> = epdf.open(<string> PDF filename)
559 <Annot> = epdf.Annot(<XRef>, <Dict>, <Catalog>, <Ref>)
560 <Annots> = epdf.Annots(<XRef>, <Catalog>, <Object>)
561 <Array> = epdf.Array(<XRef>)
562 <Attribute> = epdf.Attribute(<Type>,<Object>)| epdf.Attribute(<string>, <int>, <Object>)
563 <Dict> = epdf.Dict(<XRef>)
564 <Object> = epdf.Object()
565 <PDFRectangle> = epdf.PDFRectangle()
566 \stopfunctioncall
568 The functions \type {StructElement_Type}, \type {Attribute_Type} and \type
569 {AttributeOwner_Type} return a hash table \type {{<string>,<integer>}}.
571 \type {Annot} methods:
573 \startfunctioncall
574 <boolean> = <Annot>:isOK()
575 <Object> = <Annot>:getAppearance()
576 <AnnotBorder> = <Annot>:getBorder()
577 <boolean> = <Annot>:match(<Ref>)
578 \stopfunctioncall
580 \type {AnnotBorderStyle} methods:
582 \startfunctioncall
583 <number> = <AnnotBorderStyle>:getWidth()
584 \stopfunctioncall
586 \type {Annots} methods:
588 \startfunctioncall
589 <integer> = <Annots>:getNumAnnots()
590 <Annot> = <Annots>:getAnnot(<integer>)
591 \stopfunctioncall
593 \type {Array} methods:
595 \startfunctioncall
596 <Array>:incRef()
597 <Array>:decRef()
598 <integer> = <Array>:getLength()
599 <Array>:add(<Object>)
600 <Object> = <Array>:get(<integer>)
601 <Object> = <Array>:getNF(<integer>)
602 <string> = <Array>:getString(<integer>)
603 \stopfunctioncall
605 \type {Attribute} methods:
607 \startfunctioncall
608 <boolean> = <Attribute>:isOk()
609 <integer> = <Attribute>:getType()
610 <integer> = <Attribute>:getOwner()
611 <string> = <Attribute>:getTypeName()
612 <string> = <Attribute>:getOwnerName()
613 <Object> = <Attribute>:getValue()
614 <Object> = <Attribute>:getDefaultValue
615 <string> = <Attribute>:getName()
616 <integer> = <Attribute>:getRevision()
617 <Attribute>:setRevision(<unsigned integer>)
618 <boolean> = <Attribute>:istHidden()
619 <Attribute>:setHidden(<boolean>)
620 <string> = <Attribute>:getFormattedValue()
621 <string> = <Attribute>:setFormattedValue(<string>)
622 \stopfunctioncall
624 \type {Catalog} methods:
626 \startfunctioncall
627 <boolean> = <Catalog>:isOK()
628 <integer> = <Catalog>:getNumPages()
629 <Page> = <Catalog>:getPage(<integer>)
630 <Ref> = <Catalog>:getPageRef(<integer>)
631 <string> = <Catalog>:getBaseURI()
632 <string> = <Catalog>:readMetadata()
633 <Object> = <Catalog>:getStructTreeRoot()
634 <integer> = <Catalog>:findPage(<integer> object number, <integer> object generation)
635 <LinkDest> = <Catalog>:findDest(<string> name)
636 <Object> = <Catalog>:getDests()
637 <integer> = <Catalog>:numEmbeddedFiles()
638 <EmbFile> = <Catalog>:embeddedFile(<integer>)
639 <integer> = <Catalog>:numJS()
640 <string> = <Catalog>:getJS(<integer>)
641 <Object> = <Catalog>:getOutline()
642 <Object> = <Catalog>:getAcroForm()
643 \stopfunctioncall
645 \type {EmbFile} methods:
647 \startfunctioncall
648 <string> = <EmbFile>:name()
649 <string> = <EmbFile>:description()
650 <integer> = <EmbFile>:size()
651 <string> = <EmbFile>:modDate()
652 <string> = <EmbFile>:createDate()
653 <string> = <EmbFile>:checksum()
654 <string> = <EmbFile>:mimeType()
655 <Object> = <EmbFile>:streamObject()
656 <boolean> = <EmbFile>:isOk()
657 \stopfunctioncall
659 \type {Dict} methods:
661 \startfunctioncall
662 <Dict>:incRef()
663 <Dict>:decRef()
664 <integer> = <Dict>:getLength()
665 <Dict>:add(<string>, <Object>)
666 <Dict>:set(<string>, <Object>)
667 <Dict>:remove(<string>)
668 <boolean> = <Dict>:is(<string>)
669 <Object> = <Dict>:lookup(<string>)
670 <Object> = <Dict>:lookupNF(<string>)
671 <integer> = <Dict>:lookupInt(<string>, <string>)
672 <string> = <Dict>:getKey(<integer>)
673 <Object> = <Dict>:getVal(<integer>)
674 <Object> = <Dict>:getValNF(<integer>)
675 <boolean> = <Dict>:hasKey(<string>)
676 \stopfunctioncall
678 \type {Link} methods:
680 \startfunctioncall
681 <boolean> = <Link>:isOK()
682 <boolean> = <Link>:inRect(<number>, <number>)
683 \stopfunctioncall
685 \type {LinkDest} methods:
687 \startfunctioncall
688 <boolean> = <LinkDest>:isOK()
689 <integer> = <LinkDest>:getKind()
690 <string> = <LinkDest>:getKindName()
691 <boolean> = <LinkDest>:isPageRef()
692 <integer> = <LinkDest>:getPageNum()
693 <Ref> = <LinkDest>:getPageRef()
694 <number> = <LinkDest>:getLeft()
695 <number> = <LinkDest>:getBottom()
696 <number> = <LinkDest>:getRight()
697 <number> = <LinkDest>:getTop()
698 <number> = <LinkDest>:getZoom()
699 <boolean> = <LinkDest>:getChangeLeft()
700 <boolean> = <LinkDest>:getChangeTop()
701 <boolean> = <LinkDest>:getChangeZoom()
702 \stopfunctioncall
704 \type {Links} methods:
706 \startfunctioncall
707 <integer> = <Links>:getNumLinks()
708 <Link> = <Links>:getLink(<integer>)
709 \stopfunctioncall
711 \type {Object} methods:
713 \startfunctioncall
714 <Object>:initBool(<boolean>)
715 <Object>:initInt(<integer>)
716 <Object>:initReal(<number>)
717 <Object>:initString(<string>)
718 <Object>:initName(<string>)
719 <Object>:initNull()
720 <Object>:initArray(<XRef>)
721 <Object>:initDict(<XRef>)
722 <Object>:initStream(<Stream>)
723 <Object>:initRef(<integer> object number, <integer> object generation)
724 <Object>:initCmd(<string>)
725 <Object>:initError()
726 <Object>:initEOF()
727 <Object> = <Object>:fetch(<XRef>)
728 <integer> = <Object>:getType()
729 <string> = <Object>:getTypeName()
730 <boolean> = <Object>:isBool()
731 <boolean> = <Object>:isInt()
732 <boolean> = <Object>:isReal()
733 <boolean> = <Object>:isNum()
734 <boolean> = <Object>:isString()
735 <boolean> = <Object>:isName()
736 <boolean> = <Object>:isNull()
737 <boolean> = <Object>:isArray()
738 <boolean> = <Object>:isDict()
739 <boolean> = <Object>:isStream()
740 <boolean> = <Object>:isRef()
741 <boolean> = <Object>:isCmd()
742 <boolean> = <Object>:isError()
743 <boolean> = <Object>:isEOF()
744 <boolean> = <Object>:isNone()
745 <boolean> = <Object>:getBool()
746 <integer> = <Object>:getInt()
747 <number> = <Object>:getReal()
748 <number> = <Object>:getNum()
749 <string> = <Object>:getString()
750 <string> = <Object>:getName()
751 <Array> = <Object>:getArray()
752 <Dict> = <Object>:getDict()
753 <Stream> = <Object>:getStream()
754 <Ref> = <Object>:getRef()
755 <integer> = <Object>:getRefNum()
756 <integer> = <Object>:getRefGen()
757 <string> = <Object>:getCmd()
758 <integer> = <Object>:arrayGetLength()
759 = <Object>:arrayAdd(<Object>)
760 <Object> = <Object>:arrayGet(<integer>)
761 <Object> = <Object>:arrayGetNF(<integer>)
762 <integer> = <Object>:dictGetLength(<integer>)
763 = <Object>:dictAdd(<string>, <Object>)
764 = <Object>:dictSet(<string>, <Object>)
765 <Object> = <Object>:dictLookup(<string>)
766 <Object> = <Object>:dictLookupNF(<string>)
767 <string> = <Object>:dictgetKey(<integer>)
768 <Object> = <Object>:dictgetVal(<integer>)
769 <Object> = <Object>:dictgetValNF(<integer>)
770 <boolean> = <Object>:streamIs(<string>)
771 = <Object>:streamReset()
772 <integer> = <Object>:streamGetChar()
773 <integer> = <Object>:streamLookChar()
774 <integer> = <Object>:streamGetPos()
775 = <Object>:streamSetPos(<integer>)
776 <Dict> = <Object>:streamGetDict()
777 \stopfunctioncall
779 \type {Page} methods:
781 \startfunctioncall
782 <boolean> = <Page>:isOk()
783 <integer> = <Page>:getNum()
784 <PDFRectangle> = <Page>:getMediaBox()
785 <PDFRectangle> = <Page>:getCropBox()
786 <boolean> = <Page>:isCropped()
787 <number> = <Page>:getMediaWidth()
788 <number> = <Page>:getMediaHeight()
789 <number> = <Page>:getCropWidth()
790 <number> = <Page>:getCropHeight()
791 <PDFRectangle> = <Page>:getBleedBox()
792 <PDFRectangle> = <Page>:getTrimBox()
793 <PDFRectangle> = <Page>:getArtBox()
794 <integer> = <Page>:getRotate()
795 <string> = <Page>:getLastModified()
796 <Dict> = <Page>:getBoxColorInfo()
797 <Dict> = <Page>:getGroup()
798 <Stream> = <Page>:getMetadata()
799 <Dict> = <Page>:getPieceInfo()
800 <Dict> = <Page>:getSeparationInfo()
801 <Dict> = <Page>:getResourceDict()
802 <Object> = <Page>:getAnnots()
803 <Links> = <Page>:getLinks(<Catalog>)
804 <Object> = <Page>:getContents()
805 \stopfunctioncall
807 \type {PDFDoc} methods:
809 \startfunctioncall
810 <boolean> = <PDFDoc>:isOk()
811 <integer> = <PDFDoc>:getErrorCode()
812 <string> = <PDFDoc>:getErrorCodeName()
813 <string> = <PDFDoc>:getFileName()
814 <XRef> = <PDFDoc>:getXRef()
815 <Catalog> = <PDFDoc>:getCatalog()
816 <number> = <PDFDoc>:getPageMediaWidth()
817 <number> = <PDFDoc>:getPageMediaHeight()
818 <number> = <PDFDoc>:getPageCropWidth()
819 <number> = <PDFDoc>:getPageCropHeight()
820 <integer> = <PDFDoc>:getNumPages()
821 <string> = <PDFDoc>:readMetadata()
822 <Object> = <PDFDoc>:getStructTreeRoot()
823 <integer> = <PDFDoc>:findPage(<integer> object number, <integer> object generation)
824 <Links> = <PDFDoc>:getLinks(<integer>)
825 <LinkDest> = <PDFDoc>:findDest(<string>)
826 <boolean> = <PDFDoc>:isEncrypted()
827 <boolean> = <PDFDoc>:okToPrint()
828 <boolean> = <PDFDoc>:okToChange()
829 <boolean> = <PDFDoc>:okToCopy()
830 <boolean> = <PDFDoc>:okToAddNotes()
831 <boolean> = <PDFDoc>:isLinearized()
832 <Object> = <PDFDoc>:getDocInfo()
833 <Object> = <PDFDoc>:getDocInfoNF()
834 <integer> = <PDFDoc>:getPDFMajorVersion()
835 <integer> = <PDFDoc>:getPDFMinorVersion()
836 \stopfunctioncall
838 \type {PDFRectangle} methods:
840 \startfunctioncall
841 <boolean> = <PDFRectangle>:isValid()
842 \stopfunctioncall
844 %\type {Ref} methods:
846 %\startfunctioncall
847 %\stopfunctioncall
849 \type {Stream} methods:
851 \startfunctioncall
852 <integer> = <Stream>:getKind()
853 <string> = <Stream>:getKindName()
854 = <Stream>:reset()
855 = <Stream>:close()
856 <integer> = <Stream>:getChar()
857 <integer> = <Stream>:lookChar()
858 <integer> = <Stream>:getRawChar()
859 <integer> = <Stream>:getUnfilteredChar()
860 = <Stream>:unfilteredReset()
861 <integer> = <Stream>:getPos()
862 <boolean> = <Stream>:isBinary()
863 <Stream> = <Stream>:getUndecodedStream()
864 <Dict> = <Stream>:getDict()
865 \stopfunctioncall
867 \type {StructElement} methods:
869 \startfunctioncall
870 <string> = <StructElement>:getTypeName()
871 <integer> = <StructElement>:getType()
872 <boolean> = <StructElement>:isOk()
873 <boolean> = <StructElement>:isBlock()
874 <boolean> = <StructElement>:isInline()
875 <boolean> = <StructElement>:isGrouping()
876 <boolean> = <StructElement>:isContent()
877 <boolean> = <StructElement>:isObjectRef()
878 <integer> = <StructElement>:getMCID()
879 <Ref> = <StructElement>:getObjectRef()
880 <Ref> = <StructElement>:getParentRef()
881 <boolean> = <StructElement>:hasPageRef()
882 <Ref> = <StructElement>:getPageRef()
883 <StructTreeRoot> = <StructElement>:getStructTreeRoot()
884 <string> = <StructElement>:getID()
885 <string> = <StructElement>:getLanguage()
886 <integer> = <StructElement>:getRevision()
887 <StructElement>:setRevision(<unsigned integer>)
888 <string> = <StructElement>:getTitle()
889 <string> = <StructElement>:getExpandedAbbr()
890 <integer> = <StructElement>:getNumChildren()
891 <StructElement> = <StructElement>:getChild()
892 = <StructElement>:appendChild<StructElement>)
893 <integer> = <StructElement>:getNumAttributes()
894 <Attribute> = <StructElement>:geAttribute(<integer>)
895 <string> = <StructElement>:appendAttribute(<Attribute>)
896 <Attribute> = <StructElement>:findAttribute(<Attribute::Type>,boolean,Attribute::Owner)
897 <string> = <StructElement>:getAltText()
898 <string> = <StructElement>:getActualText()
899 <string> = <StructElement>:getText(<boolean>)
900 <table> = <StructElement>:getTextSpans()
901 \stopfunctioncall
903 \type {StructTreeRoot} methods:
905 \startfunctioncall
906 <StructElement> = <StructTreeRoot>:findParentElement
907 <PDFDoc> = <StructTreeRoot>:getDoc
908 <Dict> = <StructTreeRoot>:getRoleMap
909 <Dict> = <StructTreeRoot>:getClassMap
910 <integer> = <StructTreeRoot>:getNumChildren
911 <StructElement> = <StructTreeRoot>:getChild
912 <StructTreeRoot>:appendChild
913 <StructElement> = <StructTreeRoot>:findParentElement
914 \stopfunctioncall
916 \type {TextSpan} han only one method:
918 \startfunctioncall
919 <string> = <TestSpan>:getText()
920 \stopfunctioncall
922 \type {XRef} methods:
924 \startfunctioncall
925 <boolean> = <XRef>:isOk()
926 <integer> = <XRef>:getErrorCode()
927 <boolean> = <XRef>:isEncrypted()
928 <boolean> = <XRef>:okToPrint()
929 <boolean> = <XRef>:okToPrintHighRes()
930 <boolean> = <XRef>:okToChange()
931 <boolean> = <XRef>:okToCopy()
932 <boolean> = <XRef>:okToAddNotes()
933 <boolean> = <XRef>:okToFillForm()
934 <boolean> = <XRef>:okToAccessibility()
935 <boolean> = <XRef>:okToAssemble()
936 <Object> = <XRef>:getCatalog()
937 <Object> = <XRef>:fetch(<integer> object number, <integer> object generation)
938 <Object> = <XRef>:getDocInfo()
939 <Object> = <XRef>:getDocInfoNF()
940 <integer> = <XRef>:getNumObjects()
941 <integer> = <XRef>:getRootNum()
942 <integer> = <XRef>:getRootGen()
943 <integer> = <XRef>:getSize()
944 <Object> = <XRef>:getTrailerDict()
945 \stopfunctioncall
947 There is an experimental function \type {epdf.openMemStream} that takes three
948 arguments:
950 \starttabulate
951 \NC \type {stream} \NC this is a (in low level \LUA\ speak) light userdata
952 object, i.e.\ a pointer to a sequence of bytes \NC \NR
953 \NC \type {length} \NC this is the length of the stream in bytes \NC \NR
954 \NC \type {name} \NC this is a unique identifier that is used for hashing the
955 stream, so that multiple doesn't use more memory \NC \NR
956 \stoptabulate
958 Instead of a light userdata stream you can also pass a \LUA\ string, in which
959 case the given length is (at most) the string length.
961 The function returns a \type{epdf} object and a string. The string can be used in
962 the \type {img} library instead of a filename. You need to prevent garbage
963 collection of the object when you use it as image (for instance by storing it
964 somewhere).
966 Both the memory stream and it's use in the image library is experimental and can
967 change. In case you wonder where this can be used: when you use the swiglib
968 library for \type {graphicmagick}, it can return such a userdata object. This
969 permits conversion in memory and passing the result directly to the backend. This
970 might save some runtime in one|-|pass workflows. This feature is currently not
971 meant for production and we might come up with a better implementation.
973 \stopchapter
975 \stopcomponent