Beispiel #1
0
    def invoke(self,
               canvas: "Canvas",
               operands: List[AnyPDFType] = []):  # type: ignore [name-defined]

        assert isinstance(operands[0], Decimal)
        assert isinstance(operands[1], Decimal)

        SetTextLeading().invoke(canvas, [-operands[1]])
        MoveTextPosition().invoke(canvas, operands)
Beispiel #2
0
 def __init__(self):
     super(Canvas, self).__init__()
     # initialize operators
     self.canvas_operators = [
         # color
         SetCMYKNonStroking(),
         SetCMYKStroking(),
         SetColorNonStroking(self),
         SetColorStroking(self),
         SetGrayNonStroking(),
         SetGrayStroking(),
         SetRGBNonStroking(),
         SetRGBStroking(),
         # compatibility
         BeginCompatibilitySection(),
         EndCompatibilitySection(),
         # marked content
         BeginMarkedContent(),
         BeginMarkedContentWithPropertyList(),
         EndMarkedContent(),
         # state
         ModifyTransformationMatrix(),
         PopGraphicsState(),
         PushGraphicsState(),
         SetLineWidth(),
         # text
         BeginTextObject(),
         EndTextObject(),
         MoveTextPosition(),
         MoveTextPositionSetLeading(),
         MoveToNextLineShowText(),
         MoveToNextLine(),
         SetCharacterSpacing(),
         SetFontAndSize(),
         SetHorizontalScaling(),
         SetSpacingMoveToNextLineShowText(),
         SetTextLeading(),
         SetTextMatrix(),
         SetTextRenderingMode(),
         SetTextRise(),
         SetWordSpacing(),
         ShowText(),
         ShowTextWithGlyphPositioning(),
         # xobject
         Do(),
     ]
     # compatibility mode
     self.in_compatibility_section = False
     # set initial graphics state
     self.graphics_state = CanvasGraphicsState()
     # canvas tag hierarchy is (oddly enough) not considered to be part of the graphics state
     self.marked_content_stack = []
     # set graphics state stack
     self.graphics_state_stack = []
Beispiel #3
0
    def invoke(self, canvas: "Canvas", operands: List[AnyPDFType] = []):

        if not isinstance(operands[0], Decimal):
            raise PDFTypeError(expected_type=Decimal,
                               received_type=operands[0].__class__)
        if not isinstance(operands[1], Decimal):
            raise PDFTypeError(expected_type=Decimal,
                               received_type=operands[1].__class__)

        tx = operands[0]
        ty = operands[1]

        SetTextLeading().invoke(canvas, [-ty])
        MoveTextPosition().invoke(canvas, operands)
Beispiel #4
0
 def invoke(self, canvas: "Canvas", operands: List[AnyPDFType] = []):  # type: ignore [name-defined]
     operands = [Decimal(0), -canvas.graphics_state.leading]
     MoveTextPosition().invoke(canvas, operands)