# Path: gymnast/pdf_operation/pdf_operation.py
# class PdfOperation(object):
#     """PDF content stream operations dispatcher.  Content stream operations are
#     registered by calling PdfOperation.register(), passing the opcode, the type
#     of operation, and the function that does it."""
#     # Operation type constants (see Reference p. 196)
#     # These mostly exist to make things easier in PdfRenderer methods
#     NOP                    =     0
#     GENERAL_GRAPHICS_STATE =     1
#     SPECIAL_GRAPHICS_STATE =     2
#     PATH_CONSTRUCTION      =     4
#     PATH_PAINTING          =     8
#     CLIPPING_PATHS         =    16
#     TEXT_OBJECTS           =    32
#     TEXT_STATE             =    64
#     TEXT_POSITIONING       =   128
#     TEXT_SHOWING           =   256
#     TYPE_3_FONTS           =   512
#     COLOR                  =  1024
#     SHADING_PATTERNS       =  2048
#     INLINE_IMAGES          =  4096
#     XOBJECTS               =  8192
#     MARKED_CONTENT         = 16384
#     COMPATIBILITY          = 32768
# 
#     _opcodes = {}
#     _nops    = {} # As we spawn new NOP classes, we'll cache them here
#     @classmethod
#     def register(cls, opcode, optype, opfunc):
#         """Register a new PDF operation.  Arguments are the opcode, the type of
#         operation, and the function that actually does the operation."""
#         opcode = ensure_str(opcode)
#         if not callable(opfunc):
#             raise TypeError('opfunc must be callable')
#         args = inspect.getfullargspec(opfunc)
#         if not (args.varargs or args.args):
#             raise ValueError('opfunc must take at least one positional argument')
#         opcode = ensure_str(opcode)
#         cls._opcodes[opcode] = new_opcode(opcode, optype, opfunc)
# 
#     @classmethod
#     def __getitem__(cls, operator):
#         operator = ensure_str(operator)
#         try:
#             return cls._opcodes[operator]
#         except KeyError:
#             return cls._nop(operator)
#     @classmethod
#     def _nop(cls, operator):
#         """Get the corresponding NOP operation, creating it if necessary."""
#         warnings.warn("Opcode '{}' not implemented. NOP".format(operator),
#                       PdfOpWarning)
#         try:
#             return cls._nops[operator]
#         except KeyError:
#             tpe = new_opcode(operator, 0, lambda *x: None)
#             cls._nops[operator] = tpe
#             return tpe
# 
# Path: gymnast/exc.py
# class PdfError(Exception):
#     """Generic PDF exception"""
#     pass


import numbers
from ..pdf_operation import PdfOperation
from ...exc          import PdfError
"""
Text Showing operations - Reference p. 407
"""


def opcode_Tj(renderer, string=b''):
    """Show a text string and move the position based on its length"""
    renderer.render_text(string)

def opcode_TJ(renderer, args=()):
    """Show one or more strings with individual positioning"""
    for op in args:
        if isinstance(op, str):
            renderer.render_text(op)
        elif isinstance(op, numbers.Real):
            renderer.move_text_cursor(op)
        else:

# Path: gymnast/pdf_operation/pdf_operation.py
# class PdfOperation(object):
#     """PDF content stream operations dispatcher.  Content stream operations are
#     registered by calling PdfOperation.register(), passing the opcode, the type
#     of operation, and the function that does it."""
#     # Operation type constants (see Reference p. 196)
#     # These mostly exist to make things easier in PdfRenderer methods
#     NOP                    =     0
#     GENERAL_GRAPHICS_STATE =     1
#     SPECIAL_GRAPHICS_STATE =     2
#     PATH_CONSTRUCTION      =     4
#     PATH_PAINTING          =     8
#     CLIPPING_PATHS         =    16
#     TEXT_OBJECTS           =    32
#     TEXT_STATE             =    64
#     TEXT_POSITIONING       =   128
#     TEXT_SHOWING           =   256
#     TYPE_3_FONTS           =   512
#     COLOR                  =  1024
#     SHADING_PATTERNS       =  2048
#     INLINE_IMAGES          =  4096
#     XOBJECTS               =  8192
#     MARKED_CONTENT         = 16384
#     COMPATIBILITY          = 32768
# 
#     _opcodes = {}
#     _nops    = {} # As we spawn new NOP classes, we'll cache them here
#     @classmethod
#     def register(cls, opcode, optype, opfunc):
#         """Register a new PDF operation.  Arguments are the opcode, the type of
#         operation, and the function that actually does the operation."""
#         opcode = ensure_str(opcode)
#         if not callable(opfunc):
#             raise TypeError('opfunc must be callable')
#         args = inspect.getfullargspec(opfunc)
#         if not (args.varargs or args.args):
#             raise ValueError('opfunc must take at least one positional argument')
#         opcode = ensure_str(opcode)
#         cls._opcodes[opcode] = new_opcode(opcode, optype, opfunc)
# 
#     @classmethod
#     def __getitem__(cls, operator):
#         operator = ensure_str(operator)
#         try:
#             return cls._opcodes[operator]
#         except KeyError:
#             return cls._nop(operator)
#     @classmethod
#     def _nop(cls, operator):
#         """Get the corresponding NOP operation, creating it if necessary."""
#         warnings.warn("Opcode '{}' not implemented. NOP".format(operator),
#                       PdfOpWarning)
#         try:
#             return cls._nops[operator]
#         except KeyError:
#             tpe = new_opcode(operator, 0, lambda *x: None)
#             cls._nops[operator] = tpe
#             return tpe
# 
# Path: gymnast/exc.py
# class PdfError(Exception):
#     """Generic PDF exception"""
#     pass


# Path: gymnast/pdf_operation/operations/text_showing.py
import numbers
from ..pdf_operation import PdfOperation
from ...exc          import PdfError

"""
Text Showing operations - Reference p. 407
"""


def opcode_Tj(renderer, string=b''):
    """Show a text string and move the position based on its length"""
    renderer.render_text(string)

def opcode_TJ(renderer, args=()):
    """Show one or more strings with individual positioning"""
    for op in args:
        if isinstance(op, str):
            renderer.render_text(op)
        elif isinstance(op, numbers.Real):
            renderer.move_text_cursor(op)
        else:

            raise PdfError('Invalid TJ operand')