Beispiel #1
0
    def _draw_label(self, drawing_callable, obj=None):
        """Helper method to draw on the current label. Not intended for external use.

        """
        # Create a drawing object for this label and add the border.
        label = Drawing(float(self._lw), float(self._lh))
        label.add(self._border)
        if self._border_visible:
            label.add(self._border_visible)

        # Call the drawing function.
        drawing_callable(label, float(self._lw), float(self._lh), obj)

        # Calculate the bottom edge of the label.
        bottom = self.specs.sheet_height - self.specs.top_margin
        bottom -= (self.specs.label_height * self._position[0])
        bottom -= (self.specs.row_gap * (self._position[0] - 1))
        bottom *= mm

        # And the left edge.
        left = self.specs.left_margin
        left += (self.specs.label_width * (self._position[1] - 1))
        left += (self.specs.column_gap * (self._position[1] - 1))
        left *= mm

        # Render the label on the sheet.
        label.shift(float(left), float(bottom))
        self._current_page.add(label)
Beispiel #2
0
    def _shade_missing_label(self):
        """Helper method to shade a missing label. Not intended for external use.

        """
        # Start a drawing for the whole label.
        label = Drawing(float(self._lw), float(self._lh))
        label.add(self._clip_label)

        # Fill with a rectangle; the clipping path will take care of the borders.
        r = shapes.Rect(0, 0, float(self._lw), float(self._lh))
        r.fillColor = self.shade_missing
        r.strokeColor = None
        label.add(r)

        # Add the label to the page.
        label.shift(*self._calculate_edges())
        self._current_page.add(label)
Beispiel #3
0
    def _shade_missing_label(self):
        """Helper method to shade a missing label. Not intended for external use.

        """
        # Start a drawing for the whole label.
        label = Drawing(float(self._lw), float(self._lh))
        label.add(self._clip_label)

        # Fill with a rectangle; the clipping path will take care of the borders.
        r = shapes.Rect(0, 0, float(self._lw), float(self._lh))
        r.fillColor = self.shade_missing
        r.strokeColor = None
        label.add(r)

        # Add the label to the page.
        label.shift(*self._calculate_edges())
        self._current_page.add(label)
Beispiel #4
0
    def _draw_label(self, obj, count):
        """Helper method to draw on the current label. Not intended for external use.

        """
        # Start a drawing for the whole label.
        label = Drawing(float(self._lw), float(self._lh))
        label.add(self._clip_label)

        # And one for the available area (i.e., after padding).
        available = Drawing(float(self._dw), float(self._dh))
        available.add(self._clip_drawing)

        # Call the drawing function.
        self.drawing_callable(available, float(self._dw), float(self._dh), obj)

        # Render the contents on the label.
        available.shift(float(self._lp), float(self._bp))
        label.add(available)

        # Draw the border if requested.
        if self.border:
            label.add(self._border)

        # Add however many copies we need to.
        for i in range(count):
            # Find the next available label.
            self._next_unused_label()

            # Have we been told to skip this page?
            if self.pages_to_draw and self.page_count not in self.pages_to_draw:
                continue

            # Add the label to the page. ReportLab stores the added drawing by
            # reference so we have to copy it N times.
            thislabel = copy(label)
            thislabel.shift(*self._calculate_edges())
            self._current_page.add(thislabel)
Beispiel #5
0
    def _draw_label(self, obj, count):
        """Helper method to draw on the current label. Not intended for external use.

        """
        # Start a drawing for the whole label.
        label = Drawing(float(self._lw), float(self._lh))
        label.add(self._clip_label)

        # And one for the available area (i.e., after padding).
        available = Drawing(float(self._dw), float(self._dh))
        available.add(self._clip_drawing)

        # Call the drawing function.
        self.drawing_callable(available, float(self._dw), float(self._dh), obj)

        # Render the contents on the label.
        available.shift(float(self._lp), float(self._bp))
        label.add(available)

        # Draw the border if requested.
        if self.border:
            label.add(self._border)

        # Add however many copies we need to.
        for i in range(count):
            # Find the next available label.
            self._next_unused_label()

            # Have we been told to skip this page?
            if self.pages_to_draw and self.page_count not in self.pages_to_draw:
                continue

            # Add the label to the page. ReportLab stores the added drawing by
            # reference so we have to copy it N times.
            thislabel = copy(label)
            thislabel.shift(*self._calculate_edges())
            self._current_page.add(thislabel)