Skip to content

global pdfe

😱 Types incomplete or incorrect? 🙏 Please contribute!


methods


pdfe.open


function pdfe.open(filename: string) -> doc PdfeDocument {
    catalog = any,
    Catalog = any,
    info = any,
    Info = any,
    trailer = any,
    Trailer = any,
    pages = any,
    Pages = any,
}
@param filename - File name.

@return doc - Pdfe document.

Reference:

😱 Types incomplete or incorrect? 🙏 Please contribute!

Open a pdf file.

pdfe.new


function pdfe.new(
  contents: string,
  size: integer
) -> __Reference PdfeDocument {
    catalog = any,
    Catalog = any,
    info = any,
    Info = any,
    trailer = any,
    Trailer = any,
    pages = any,
    Pages = any,
}
@param contents - A string containing a complete pdf file.

@param size - Size of contents in bytes.

@return __Reference - :__

😱 Types incomplete or incorrect? 🙏 Please contribute!

Open a pseudo (in-memory) pdf file.

pdfe.getstatus


function pdfe.getstatus(doc: PdfeDocument {
    catalog = any,
    Catalog = any,
    info = any,
    Info = any,
    trailer = any,
    Trailer = any,
    pages = any,
    Pages = any,
}) -> status integer
@param doc - Pdfe document.

@return status - Encryption status. - -2 is encrypted - -1 is encrypted and decryption with pdfe.unencrypt() failed - 0 is not encrypted - 1 successfully unencrypted with pdfe.unencrypt()

Reference:

😱 Types incomplete or incorrect? 🙏 Please contribute!

Return the encryption status of a pdfe document.

pdfe.close


function pdfe.close(doc: PdfeDocument {
    catalog = any,
    Catalog = any,
    info = any,
    Info = any,
    trailer = any,
    Trailer = any,
    pages = any,
    Pages = any,
})
@param doc - Pdfe document.

Reference:

😱 Types incomplete or incorrect? 🙏 Please contribute!

Close a pdfe document.

pdfe.unencrypt


function pdfe.unencrypt(
  doc: PdfeDocument {
    catalog = any,
    Catalog = any,
    info = any,
    Info = any,
    trailer = any,
    Trailer = any,
    pages = any,
    Pages = any,
},
  userpassword: string?,
  ownerpassword: string?
)
@param doc - Pdfe document.

@param userpassword - User password.

@param ownerpassword - Owner password.

Reference:

😱 Types incomplete or incorrect? 🙏 Please contribute!

Unencrypt a pdfe document.

pdfe.getsize


function pdfe.getsize(doc: PdfeDocument {
    catalog = any,
    Catalog = any,
    info = any,
    Info = any,
    trailer = any,
    Trailer = any,
    pages = any,
    Pages = any,
}) -> size integer
@param doc - Pdfe document.

@return size - Size of pdf document is bytes.

Reference:

😱 Types incomplete or incorrect? 🙏 Please contribute!

Return the size of a pdfe document in bytes.

pdfe.getversion


function pdfe.getversion(doc: PdfeDocument {
    catalog = any,
    Catalog = any,
    info = any,
    Info = any,
    trailer = any,
    Trailer = any,
    pages = any,
    Pages = any,
})
 -> major integer
 -> minor integer

@return major - major version number

@return minor - minor version number

Reference:

😱 Types incomplete or incorrect? 🙏 Please contribute!

Return the version number of the pdf document.

pdfe.getnofobjects


function pdfe.getnofobjects(doc: PdfeDocument {
    catalog = any,
    Catalog = any,
    info = any,
    Info = any,
    trailer = any,
    Trailer = any,
    pages = any,
    Pages = any,
}) -> nobj integer
@param doc - Pdf document.

@return nobj - Number of objects.

Reference:

😱 Types incomplete or incorrect? 🙏 Please contribute!

Return number of objects referenced in the XREF table.

pdfe.getnofpages


function pdfe.getnofpages(document: PdfeDocument {
    catalog = any,
    Catalog = any,
    info = any,
    Info = any,
    trailer = any,
    Trailer = any,
    pages = any,
    Pages = any,
}) -> npages integer
@param document - Pdfe document.

@return npages - Number of pages.

Reference:

😱 Types incomplete or incorrect? 🙏 Please contribute!

Return the number of pages of the pdf document.

pdfe.getmemoryusage


function pdfe.getmemoryusage(doc: PdfeDocument {
    catalog = any,
    Catalog = any,
    info = any,
    Info = any,
    trailer = any,
    Trailer = any,
    pages = any,
    Pages = any,
})
 -> used integer
 -> waste integer
@param doc - Pdfe document.

@return used - Used memory including waste.

@return waste - Waste (E.g. optional keys of pdf objects that are not used.)

Reference:

😱 Types incomplete or incorrect? 🙏 Please contribute!

Return memory usage of pplib library in bytes.

pdfe.getcatalog


function pdfe.getcatalog(doc: PdfeDocument {
    catalog = any,
    Catalog = any,
    info = any,
    Info = any,
    trailer = any,
    Trailer = any,
    pages = any,
    Pages = any,
}) -> catalog PdfeDictionary
@param doc - Pdfe document.

@return catalog - Catalog of the pdf.

Reference:

😱 Types incomplete or incorrect? 🙏 Please contribute!

Return pdf catalog.

pdfe.gettrailer


function pdfe.gettrailer(doc: PdfeDocument {
    catalog = any,
    Catalog = any,
    info = any,
    Info = any,
    trailer = any,
    Trailer = any,
    pages = any,
    Pages = any,
}) -> trailor PdfeDictionary
@param doc - Pdfe document

@return trailor - Trailer of the pdf.

Reference:

😱 Types incomplete or incorrect? 🙏 Please contribute!

Return pdf trailer.

pdfe.getinfo


function pdfe.getinfo(doc: PdfeDocument {
    catalog = any,
    Catalog = any,
    info = any,
    Info = any,
    trailer = any,
    Trailer = any,
    pages = any,
    Pages = any,
}) -> info PdfeDictionary
@param doc - Pdfe document

@return info - Info of the pdf.

Reference:

😱 Types incomplete or incorrect? 🙏 Please contribute!

Return pdf info.

pdfe.getpage


function pdfe.getpage(
  doc: PdfeDocument {
    catalog = any,
    Catalog = any,
    info = any,
    Info = any,
    trailer = any,
    Trailer = any,
    pages = any,
    Pages = any,
},
  page: integer
) -> page PdfeDictionary
@param doc - Pdfe document.

@param page - Page number.

@return page - Page object.

Reference:

😱 Types incomplete or incorrect? 🙏 Please contribute!

Return a specific pdf page.

pdfe.getpages


function pdfe.getpages(doc: PdfeDocument {
    catalog = any,
    Catalog = any,
    info = any,
    Info = any,
    trailer = any,
    Trailer = any,
    pages = any,
    Pages = any,
}) -> table table<PdfeDictionary>
@param doc - Pdfe document.

@return table - Lua table. Each item of the returned table is a PdfeDictionary of one page of the pdf.

Reference:

😱 Types incomplete or incorrect? 🙏 Please contribute!

Return a table of pages.

pdfe.getbox


function pdfe.getbox(
  page: PdfeDictionary,
  bbox_name: ("MediaBox"|"CropBox"|"BleedBox"|"TrimBox"|"ArtBox")
) -> bbox number[]
@param page - Pdfe dictionary.

@param bbox_name - Name of bounding box.

@return bbox - [llx lly urx ury]

Reference:

😱 Types incomplete or incorrect? 🙏 Please contribute!

Return bounding box of a pdf page.

pdfe.getstring


function pdfe.getstring(
  dict_or_array: (PdfeDictionary|PdfeArray),
  key_or_index: integer
) -> string string
@param dict_or_array - Pdfe dictionary or array.

@param key_or_index - Key or index.

@return string - If the pdf string is hex encoded then the returned string is hex encoded too.

Reference:

😱 Types incomplete or incorrect? 🙏 Please contribute!

Return a pdf string object as a string.

pdfe.getstring


function pdfe.getstring(
  dict_or_array: (PdfeDictionary|PdfeArray),
  key_or_index: (string|integer),
  decode: boolean
)
 -> string string
 -> was_encoded boolean
@param dict_or_array - Pdfe dictionary or array.

@param key_or_index - Key or index.

@param decode - True, if a hex encoded string shall be decoded.

@return was_encoded - True, if string was hex encoded. Return value was_encoded is only available if decode is false.

Reference:

😱 Types incomplete or incorrect? 🙏 Please contribute!

Return a pdf string object as a string.

pdfe.getinteger


function pdfe.getinteger(
  dict_or_array: (PdfeDictionary|PdfeArray),
  key_or_index: (string|integer)
) -> value integer
@param dict_or_array - Pdfe dictionary or array.

@param key_or_index - Key or index.

@return value - Integer.

Reference:

😱 Types incomplete or incorrect? 🙏 Please contribute!

Return a pdf integer object as integer.

pdfe.getnumber


function pdfe.getnumber(
  dict_or_array: (PdfeDictionary|PdfeArray),
  key_or_index: (string|integer)
) -> value number
@param dict_or_array - Pdfe dictionary or array.

@param key_or_index - Key or index.

Return a pdf number object as number.

pdfe.getboolean


function pdfe.getboolean(
  dict_or_array: (PdfeDictionary|PdfeArray),
  key_or_index: (string|integer)
) -> value boolean
@param dict_or_array - Pdfe dictionary or array.

@param key_or_index - Key or index.

Return a pdf boolean value as boolean.

pdfe.getname


function pdfe.getname(
  dict_or_array: (PdfeDictionary|PdfeArray),
  key_or_index: (string|integer)
) -> value string
@param dict_or_array - Pdfe dictionary or array.

@param key_or_index - Key or index.

@return value - Name.

Reference:

😱 Types incomplete or incorrect? 🙏 Please contribute!

Return a pdf name object as string.

pdfe.type


function pdfe.type(pdfe_obj: (PdfeDocument|PdfeDictionary|PdfeArray|PdfeStream|PdfeReference)) -> pdfe_type string?

@return pdfe_type - Type of pdfe object.

Note: Returns nil for all other objects like integer, string, etc.

Reference:

😱 Types incomplete or incorrect? 🙏 Please contribute!

Return a string representing the pdfe type of .

returned string type of <pdfe_obj>
pdfe PdfeDocument
pdfe.dictionary PdfeDictionary
pdfe.array PdfeArray
pdfe.stream PdfeStream
pdfe.reference PdfeReference

pdfe.getdictionary


function pdfe.getdictionary(
  dict_or_array: (PdfeDictionary|PdfeArray),
  key_or_index: (string|integer)
) -> dict PdfeDictionary
@param dict_or_array - Pdfe dictionary or array.

@param key_or_index - Key or index.

@return dict - Pdfe dictionary.

Reference:

😱 Types incomplete or incorrect? 🙏 Please contribute!

Return a pdf dictionary as a pdfe dictionary.

pdfe.getarray


function pdfe.getarray(
  dict_or_array: (PdfeDictionary|PdfeArray),
  key_or_index: (string|integer)
) -> array PdfeArray
@param dict_or_array - Pdfe dictionary or array.

@param key_or_index - Key or index.

@return array - Pdfe array.

Reference:

Return a pdf array as a pdfe array.

pdfe.getstream


function pdfe.getstream(
  dict_or_array: (PdfeDictionary|PdfeArray),
  key_or_index: (string|integer)
)
 -> stream PdfeStream
 -> dict PdfeDictionary
@param dict_or_array - Pdfe dictionary or array.

@param key_or_index - Key or index.

@return stream - Pdfe stream.

@return dict - Pdfe dictionary of the stream.

Reference:

😱 Types incomplete or incorrect? 🙏 Please contribute!

Return a pdf stream as a pdfe stream.

The corresponding dictionary of the stream is returned too.

pdfe.getfromstream


function pdfe.getfromstream(
  stream: PdfeStream,
  key: integer
)
 -> type integer
 -> value any
 -> details any

@return type - Integer representing the type of a value. (See table below.)

@return value - The value itself.

@return details - Details about this value. (See table below.)

Reference:

😱 Types incomplete or incorrect? 🙏 Please contribute!

Return a value of a pdf stream dictionary, including low level details about this value.

Like pdfe.getfromdictionary() except that this functions works on a 'dictionary of a stream'.

Type PDF type Lua type Details
0 none nil
1 null nil
2 boolean boolean
3 integer integer
4 number number
5 name string
6 string string Is_hex? (1)
7 array PdfeArray Size of array
8 dictionary PdfeDictionary Size of dictionary
9 stream PdfeStream PdfeDictionary
10 reference PdfeReference Number of reference

(1) true, for hexadecimal string, false for normal string

pdfe.openstream


function pdfe.openstream(
  stream: PdfeStream,
  decode: boolean?
) -> okay boolean
@param stream - Pdfe stream object.

@param decode - True, if stream should be decompressed.

@return okay - True, if reading the stream was successful.

Reference:

😱 Types incomplete or incorrect? 🙏 Please contribute!

Open a stream.

pdfe.closestream


function pdfe.closestream(stream: PdfeStream)
@param stream - Pdfe stream object

Reference:

😱 Types incomplete or incorrect? 🙏 Please contribute!

Close a stream.

pdfe.readfromstream


function pdfe.readfromstream(stream: PdfeStream)
 -> contents string
 -> size integer
@param stream - Pdfe stream object.

@return contents - Contents of stream.

@return size - Length of stream.

Reference:

😱 Types incomplete or incorrect? 🙏 Please contribute!

Read a stream object in chunks.

pdfe.readwholestream


function pdfe.readwholestream(
  stream: PdfeStream,
  decode: boolean
)
 -> contents string
 -> size integer
@param stream - Pdfe stream object.

@param decode - True, if stream should be decompressed.

@return contents - Contents of stream.

@return size - Length of stream.

Reference:

😱 Types incomplete or incorrect? 🙏 Please contribute!

Read stream object as a whole. Opening and closing the stream with pdfe.openstream() and pdfe.closestream() is not necessary.

pdfe.pagestotable


function pdfe.pagestotable(doc: PdfeDocument {
    catalog = any,
    Catalog = any,
    info = any,
    Info = any,
    trailer = any,
    Trailer = any,
    pages = any,
    Pages = any,
}) -> table table
@param doc - Pdfe document.

@return table - Lua table. Each item (page) of the returned table is a table itself like this: { page, size, objnum } * page - pdfe dictionary of a page * size - number of keys of the page dictionary * objnum - pdf object number of the page object

Reference:

😱 Types incomplete or incorrect? 🙏 Please contribute!

Return a table in which each item represents one page of a pdf.

pdfe.getfromdictionary


function pdfe.getfromdictionary(
  dict: PdfeDictionary,
  key: string
)
 -> type integer
 -> value any
 -> details any

@return type - Integer representing the type of a value. (See table below.)

@return value - The value itself.

@return details - Details about this value. (See table below.)

Reference:

😱 Types incomplete or incorrect? 🙏 Please contribute!

Return a value of a pdf dictionary, including low level details about this value.

Type PDF type Lua type Details
0 none nil
1 null nil
2 boolean boolean
3 integer integer
4 number number
5 name string
6 string string Is_hex? (1)
7 array PdfeArray Size of array
8 dictionary PdfeDictionary Size of dictionary
9 stream PdfeStream PdfeDictionary
10 reference PdfeReference Number of reference

(1) true, for hexadecimal string, false for normal string

pdfe.getfromarray


function pdfe.getfromarray(
  array: PdfeArray,
  index: integer
)
 -> type integer
 -> value any
 -> details any

@return type - Integer representing the type of a value. (See table below.)

@return value - The value itself.

@return details - Details about this value. (See table below.)

Reference:

😱 Types incomplete or incorrect? 🙏 Please contribute!

Return a value of a pdf dictionary, including low level details about this value.

Type PDF type Lua type Details
0 none nil
1 null nil
2 boolean boolean
3 integer integer
4 number number
5 name string
6 string string Is_hex? (1)
7 array PdfeArray Size of array
8 dictionary PdfeDictionary Size of dictionary
9 stream PdfeStream PdfeDictionary
10 reference PdfeReference Number of reference

(1) true, for hexadecimal string, false for normal string

pdfe.dictionarytotable


function pdfe.dictionarytotable(dict: PdfeDictionary) -> table table<string,table<integer,any,any>>
@param dict - Pdfe dictionary.

@return table - Lua table This function returns a lua table. Its keys are the keys of the pdfe dictionary and its values are what pdfe.getfromdictionary(dict, key) returns.

Reference:

😱 Types incomplete or incorrect? 🙏 Please contribute!

Convert a pdfe dictionary into a lua table.

pdfe.arraytotable


function pdfe.arraytotable(array: PdfeArray) -> table table<integer,table<integer,any,any>>
@param array - Pdfe array.

@return table - Lua table This function returns a lua table. Its indices are the indices of the pdfe array and its values are what pdfe.getfromarray(array, index) returns.

Reference:

😱 Types incomplete or incorrect? 🙏 Please contribute!

Convert a pdfe array into a lua table.

pdfe.getfromreference


function pdfe.getfromreference(ref: PdfeReference)
 -> type integer
 -> value any
 -> details any

@return type - Type of value. (See table below.)

@return value - The value itself.

@return details - Details about this value. (See table below.)

Reference:

😱 Types incomplete or incorrect? 🙏 Please contribute!

Return the value of a reference, including low level details about this value.

Type PDF type Lua type Details
0 none nil
1 null nil
2 boolean boolean
3 integer integer
4 number number
5 name string
6 string string Is_hex? (1)
7 array PdfeArray Size of array
8 dictionary PdfeDictionary Size of dictionary
9 stream PdfeStream PdfeDictionary
10 reference PdfeReference Number of reference

(1) true, for hexadecimal string, false for normal string