pdfme.parser
- class pdfme.parser.PDFObject(id_, obj=None)
Bases:
objectA class that represents a PDF object.
This object has a
pdfme.parser.PDFRefidattribute representing the id of this object inside the PDF document, and acts as a dict, so the user can update any property of this PDF object like you would do with a dict.- Parameters
id (PDFRef) – The id of this object inside the PDF document.
obj (dict, optional) – the dict representing the PDF object.
- class pdfme.parser.PDFRef(id_)
Bases:
intAn
intrepresenting the id of a PDF object.This is a regular
intthat has an additional property calledrefwith a representation of this object, to be referenced elsewhere in the PDF document.- property ref
- Returns
bytes with a representation of this object, to be referenced elsewhere in the PDF document.
- Return type
bytes
- pdfme.parser.parse_obj(obj)
Function to convert a python object to a bytes object representing the corresponding PDF object.
- pdfme.parser.parse_dict(obj)
Function to convert a python dict to a bytes object representing the corresponding PDF Dictionary.
- Parameters
obj (dict) – the dict to be converted to a PDF Dictionary.
- Returns
bytes representing the corresponding PDF Dictionary.
- Return type
bytes
- pdfme.parser.parse_list(obj)
Function to convert a python iterable to a bytes object representing the corresponding PDF Array.
- Parameters
obj (iterable) – the iterable to be converted to a PDF Array.
- Returns
bytes representing the corresponding PDF Array.
- Return type
bytes
- pdfme.parser.parse_stream(obj)
Function to convert a dict representing a PDF Stream object to a bytes object.
A dict representing a PDF stream should have a
'__stream__key containing the stream bytes. You don’t have to includeLengthkey in the dict, as it is calculated by us. The value of'__stream__'key must be of typebytesor a dict whose values are of typebytes. If you include aFilterkey, a encoding is automatically done in the stream (seepdfme.encoders.encode_stream()function for supported encoders). If the contents of the stream are already encoded using the filter inFilterkey, you can skip the encoding process by including the__skip_filter__key.- Parameters
obj (dict) – the dict representing a PDF stream.
- Returns
bytes representing the corresponding PDF Stream.
- Return type
bytes