コード例 #1
0
ファイル: figures.py プロジェクト: mjibson/junk
    def __init__(
        self,
        width,
        height,
        caption="",
        captionFont="Times-Italic",
        captionSize=12,
        background=None,
        captionTextColor=toColor('black'),
        captionBackColor=None,
        border=1,
        spaceBefore=12,
        spaceAfter=12,
        captionGap=None,
    ):
        Flowable.__init__(self)
        self.width = width
        self.figureHeight = height
        self.caption = caption
        self.captionFont = captionFont
        self.captionSize = captionSize
        self.captionTextColor = captionTextColor
        self.captionBackColor = captionBackColor
        self.captionGap = captionGap
        self._captionData = None
        self.captionHeight = 0  # work out later
        self.background = background
        self.border = border
        self.spaceBefore = spaceBefore
        self.spaceAfter = spaceAfter

        self._getCaptionPara(
        )  #Larry Meyn's fix - otherwise they all get the number of the last chapter.
コード例 #2
0
 def __init__(self, filename, width=None, height=None, kind='direct',
                                  mask=None, lazy=True, srcinfo=None):
     Flowable.__init__(self)
     ext = os.path.splitext(filename)[-1]
     self._kind = kind
     # Prefer svg2rlg for SVG, as it works better
     if LazyImports.svg2rlg:
         self._mode = 'svg2rlg'
         self.doc = LazyImports.svg2rlg.svg2rlg(filename)
         self.imageWidth = width
         self.imageHeight = height
         x1, y1, x2, y2 = self.doc.getBounds()
         # Actually, svg2rlg's getBounds seems broken.
         self._w, self._h = x2, y2
         if not self.imageWidth:
             self.imageWidth = self._w
         if not self.imageHeight:
             self.imageHeight = self._h
     else:
         self._mode = None
         log.error("SVG support not enabled,"
             " please install svg2rlg.")
     self.__ratio = float(self.imageWidth)/self.imageHeight
     if kind in ['direct','absolute']:
         self.drawWidth = width or self.imageWidth
         self.drawHeight = height or self.imageHeight
     elif kind in ['bound','proportional']:
         factor = min(float(width)/self.imageWidth,float(height)/self.imageHeight)
         self.drawWidth = self.imageWidth*factor
         self.drawHeight = self.imageHeight*factor
コード例 #3
0
 def __init__(self, x=0, y=-15, width=40, height=15, text=""):
     Flowable.__init__(self)
     self.x = x
     self.y = y
     self.width = width
     self.height = height
     self.text = text
コード例 #4
0
    def __init__(self, text_array_to_encode):
        Flowable.__init__(self)
        self.text_array_to_encode = text_array_to_encode
        self.encoded_all = ""

        for e in self.text_array_to_encode:
            self.encoded_all = self.encoded_all + " " + e
コード例 #5
0
ファイル: flowable.py プロジェクト: affinitic/affinitic.pdf
 def __init__(self, measure_unit, document):
     Flowable.__init__(self)
     self.unit = measure_unit
     self.cursor = Cursor()
     self._elements = []
     self.canv = document.canv
     self._frame = document.pageTemplate.frames[0]
コード例 #6
0
ファイル: svgimage.py プロジェクト: EronHennessey/rst2pdf
 def __init__(self, filename, width=None, height=None, kind='direct',
                                  mask=None, lazy=True, srcinfo=None):
     Flowable.__init__(self)
     ext = os.path.splitext(filename)[-1]
     self._kind = kind
     # Prefer svg2rlg for SVG, as it works better
     if LazyImports.svg2rlg:
         self._mode = 'svg2rlg'
         self.doc = LazyImports.svg2rlg.svg2rlg(filename)
         self.imageWidth = width
         self.imageHeight = height
         x1, y1, x2, y2 = self.doc.getBounds()
         # Actually, svg2rlg's getBounds seems broken.
         self._w, self._h = x2, y2
         if not self.imageWidth:
             self.imageWidth = self._w
         if not self.imageHeight:
             self.imageHeight = self._h
     else:
         self._mode = None
         log.error("SVG support not enabled,"
             " please install svg2rlg.")
     self.__ratio = float(self.imageWidth)/self.imageHeight
     if kind in ['direct','absolute']:
         self.drawWidth = width or self.imageWidth
         self.drawHeight = height or self.imageHeight
     elif kind in ['bound','proportional']:
         factor = min(float(width)/self.imageWidth,float(height)/self.imageHeight)
         self.drawWidth = self.imageWidth*factor
         self.drawHeight = self.imageHeight*factor
コード例 #7
0
ファイル: figures.py プロジェクト: AceZOfZSpades/RankPanda
    def __init__(self, width, height, caption="",
                 captionFont="Times-Italic", captionSize=12,
                 background=None,
                 captionTextColor=toColor('black'),
                 captionBackColor=None,
                 border=1,
                 spaceBefore=12,
                 spaceAfter=12,
                 captionGap=None,
                 ):
        Flowable.__init__(self)
        self.width = width
        self.figureHeight = height
        self.caption = caption
        self.captionFont = captionFont
        self.captionSize = captionSize
        self.captionTextColor = captionTextColor
        self.captionBackColor = captionBackColor
        self.captionGap = captionGap
        self._captionData = None
        self.captionHeight = 0  # work out later
        self.background = background
        self.border = border
        self.spaceBefore = spaceBefore
        self.spaceAfter = spaceAfter

        self._getCaptionPara()  #Larry Meyn's fix - otherwise they all get the number of the last chapter.
コード例 #8
0
ファイル: pdftools.py プロジェクト: neurospin/pyconnectomist
    def __init__(self, height, text_width, text_padding, texts,
                 linecount=42, linespace=14, verbose=0):
        """ Initialize the 'Intro' class.

        Parameters
        ----------
        height: float (mandatory)
            the text box height.
        text_width: float (mandatory)
            each text box width.
        text_padding: float (mandatory)
            the padding between each text box.
        texts: list of str (mandatory)
            the texts to be displayed.
        linecount: int (optional, default 42)
            the number of characters in each line.
        linespace: int (optional, default 14)
            the space between lines.
        verbose: int (optional, default 0)
            the verbosity level.
        """
        Flowable.__init__(self)
        self.height = height
        self.text_width = text_width
        self.text_padding = text_padding
        self.texts = []
        for txt in texts:
            self.texts.append([txt[i: i + linecount]
                               for i in range(0, len(txt), linecount)])
        self.linespace = linespace
        self.verbose = verbose
コード例 #9
0
ファイル: pdftools.py プロジェクト: neurospin/pyconnectomist
    def __init__(self, width, height, images, preserve_aspect_ratio=True):
        """ Initialize the 'TriPlanar' class.

        If a None image is passed, an empty box will be displayed.

        Parameters
        ----------
        width: float (mandatory)
            the element width.
        heights: float (mandatory)
            the element height.
        images: 4-uplet or 1-uplet (mandatory)
            the path to the images to be displayed. If a 4-uplet is specified
            the display order is (image_upper_left, image_upper_right,
            image_bottom_left, image_bottom_right)
        preserve_aspect_ratio: bool (optional, default True)
            if True preserve the image aspect ratios.
        """
        Flowable.__init__(self)
        self.width = width
        self.height = height
        self.display_mode = "multi"
        if len(images) == 1:
            self.display_mode = "single"
        self.images = images
        self.preserve_aspect_ratio = preserve_aspect_ratio
        self.missing_file = os.path.join(os.path.dirname(__file__),
                                         "resources", "missing.png")
コード例 #10
0
ファイル: card.py プロジェクト: flavour/aidiq
    def __init__(self,
                 resource,
                 item,
                 labels=None,
                 common=None,
                 backside=False,
                 multiple=False,
                 ):
        """
            Constructor

            @param resource: the resource
            @param item: the data item
            @param labels: the field labels
            @param common: common data for all cards
            @param backside: this instance should render a card backside
            @param multiple: there are multiple cards per page
        """

        Flowable.__init__(self)

        self.width, self.height = self.cardsize

        self.resource = resource
        self.item = item

        self.labels = labels if labels is not None else {}
        self.common = common if common is not None else {}

        self.backside = backside
        self.multiple = multiple
コード例 #11
0
 def __init__(self, width, height, caption="",
              captionFont=_baseFontNameI, captionSize=12,
              background=None,
              captionTextColor=toColor('black'),
              captionBackColor=None,
              border=None,
              spaceBefore=12,
              spaceAfter=12,
              captionGap=None,
              captionAlign='centre',
              captionPosition='bottom',
              hAlign='CENTER',
              ):
     Flowable.__init__(self)
     self.width = width
     self.figureHeight = height
     self.caption = caption
     self.captionFont = captionFont
     self.captionSize = captionSize
     self.captionTextColor = captionTextColor
     self.captionBackColor = captionBackColor
     self.captionGap = captionGap or 0.5*captionSize
     self.captionAlign = captionAlign
     self.captionPosition = captionPosition
     self._captionData = None
     self.captionHeight = 0  # work out later
     self.background = background
     self.border = border
     self.spaceBefore = spaceBefore
     self.spaceAfter = spaceAfter
     self.hAlign=hAlign
     self._getCaptionPara()  #Larry Meyn's fix - otherwise they all get the number of the last chapter.
コード例 #12
0
    def __init__(self, filename_or_object, width=None,
                 height=None, kind='direct'):
        # from reportlab.lib.units import inch
        # If using StringIO buffer, set pointer to begining
        Flowable.__init__(self)

        if hasattr(filename_or_object, 'read'):
            filename_or_object.seek(0)
        page = PdfReader(filename_or_object, decompress=False).pages[0]
        self.xobj = pagexobj(page)
        self.image_width = width
        self.image_height = height
        x1, y1, x2, y2 = self.xobj.BBox

        self._w, self._h = x2 - x1, y2 - y1
        if not self.image_width:
            self.image_width = self._w
        if not self.image_height:
            self.image_height = self._h

        self.__ratio = float(self.image_width) / self.image_height
        if kind in ['direct', 'absolute'] or width is None or height is None:
            self.draw_width = width or self.image_width
            self.draw_height = height or self.image_height
        elif kind in ['bound', 'proportional']:
            factor = min(float(width) / self._w, float(height) / self._h)
            self.draw_width = self._w * factor
            self.draw_height = self._h * factor
コード例 #13
0
ファイル: svgimage.py プロジェクト: thomaspurchas/rst2pdf
 def __init__(self, filename, width=None, height=None, kind='direct'):
     Flowable.__init__(self)
     ext = os.path.splitext(filename)[-1]
     self._kind = kind
     # Prefer svglib for SVG, as it works better
     if ext in ('.svg', '.svgz') and svglib is not None:
         self._mode = 'svglib'
         self.doc = svglib.svg2rlg(filename)
         self.width = width
         self.height = height
         _, _, self._w, self._h = self.doc.getBounds()
         if not self.width:
             self.width = self._w
         if not self.height:
             self.height = self._h
     # Use uniconvertor for the rest
     elif load is not None:
         self._mode = 'uniconvertor'
         self.doc = load.load_drawing(filename.encode('utf-8'))
         self.saver = plugins.find_export_plugin(
             plugins.guess_export_plugin('.pdf'))
         self.width = width
         self.height = height
         _, _, self._w, self._h = self.doc.BoundingRect()
         if not self.width:
             self.width = self._w
         if not self.height:
             self.height = self._h
     else:
         self._mode = None
         log.error("Vector image support not enabled,"
                   " please install svglib and/or uniconvertor.")
     if self._mode:
         self.__ratio = float(self.width) / self.height
コード例 #14
0
ファイル: figures.py プロジェクト: jwheare/digest
 def __init__(self, width, height, caption="",
              captionFont="Times-Italic", captionSize=12,
              background=None,
              captionTextColor=toColor('black'),
              captionBackColor=None,
              border=1,
              spaceBefore=12,
              spaceAfter=12,
              captionGap=None,
              ):
     Flowable.__init__(self)
     self.width = width
     self.figureHeight = height
     self.caption = caption
     self.captionFont = captionFont
     self.captionSize = captionSize
     self.captionTextColor = captionTextColor
     self.captionBackColor = captionBackColor
     self.captionGap = captionGap
     self._captionData = None
     self.captionHeight = 0  # work out later
     self.background = background
     self.border = border
     self.spaceBefore = spaceBefore
     self.spaceAfter = spaceAfter
コード例 #15
0
ファイル: svgimage.py プロジェクト: aytsai/ricebowl
 def __init__(self, svg, width=None, height=None, kind='direct'):
     # svg is either a text buffer with svg or a xml node object.
     Flowable.__init__(self)
     self._kind = kind
     s = svglib.SvgRenderer()
     if isinstance(svg, (str, unicode)):
         doc = xml.dom.minidom.parseString(svg)
         svg = doc.documentElement
     s.render(svg)
     self.doc = s.finish()
     #self.doc = svglib.svg2rlg(filename)
     self.imageWidth = width
     self.imageHeight = height
     x1, y1, x2, y2 = self.doc.getBounds()
     self._w, self._h = x2, y2
     if not self.imageWidth:
         self.imageWidth = self._w
     if not self.imageHeight:
         self.imageHeight = self._h
     self.__ratio = float(self.imageWidth)/self.imageHeight
     if kind in ['direct','absolute']:
         self.drawWidth = width or self.imageWidth
         self.drawHeight = height or self.imageHeight
     elif kind in ['bound','proportional']:
         factor = min(float(width)/self.imageWidth,float(height)/self.imageHeight)
         self.drawWidth = self.imageWidth*factor
         self.drawHeight = self.imageHeight*factor
コード例 #16
0
    def __init__(
        self,
        resource,
        item,
        labels=None,
        common=None,
        backside=False,
        multiple=False,
    ):
        """
            Constructor

            @param resource: the resource
            @param item: the data item
            @param labels: the field labels
            @param common: common data for all cards
            @param backside: this instance should render a card backside
            @param multiple: there are multiple cards per page
        """

        Flowable.__init__(self)

        self.width, self.height = self.cardsize

        self.resource = resource
        self.item = item

        self.labels = labels if labels is not None else {}
        self.common = common if common is not None else {}

        self.backside = backside
        self.multiple = multiple
コード例 #17
0
 def __init__(self, title, level=0, closed=0):
     self.title = title
     self.key = str(uuid.uuid4())
     self.level = level
     self.align = None
     self.closed = closed
     Flowable.__init__(self)
 def __init__(self, size=3.8 * mm, value=True):
     Flowable.__init__(self)
     self.width = self.height = size
     if value == "":
         self.value = True
     else:
         self.value = value
コード例 #19
0
ファイル: svgimage.py プロジェクト: aquavitae/rst2pdf-py3-dev
 def __init__(self, filename, width=None, height=None, kind='direct',
              mask=None, lazy=True, srcinfo=None):
     Flowable.__init__(self)
     self._kind = kind
     self._mode = 'svg2rlg'
     self.doc = svg2rlg(filename)
     self.imageWidth = width
     self.imageHeight = height
     x1, y1, x2, y2 = self.doc.getBounds()
     # Actually, svg2rlg's getBounds seems broken.
     self._w, self._h = x2, y2
     if not self.imageWidth:
         self.imageWidth = self._w
     if not self.imageHeight:
         self.imageHeight = self._h
     self.__ratio = float(self.imageWidth) / self.imageHeight
     if kind in ['direct', 'absolute']:
         self.drawWidth = width or self.imageWidth
         self.drawHeight = height or self.imageHeight
     elif kind in ['bound', 'proportional']:
         factor = min(
             float(width) / self.imageWidth,
             float(height) / self.imageHeight
         )
         self.drawWidth = self.imageWidth * factor
         self.drawHeight = self.imageHeight * factor
コード例 #20
0
 def __init__(self, filename, width=None, height=None, kind='direct',
              mask=None, lazy=True, srcinfo=None):
     Flowable.__init__(self)
     self._kind = kind
     self._mode = 'svg2rlg'
     self.doc = svg2rlg(filename)
     self.imageWidth = width
     self.imageHeight = height
     x1, y1, x2, y2 = self.doc.getBounds()
     # Actually, svg2rlg's getBounds seems broken.
     self._w, self._h = x2, y2
     if not self.imageWidth:
         self.imageWidth = self._w
     if not self.imageHeight:
         self.imageHeight = self._h
     self.__ratio = float(self.imageWidth) / self.imageHeight
     if kind in ['direct', 'absolute']:
         self.drawWidth = width or self.imageWidth
         self.drawHeight = height or self.imageHeight
     elif kind in ['bound', 'proportional']:
         factor = min(
             float(width) / self.imageWidth,
             float(height) / self.imageHeight
         )
         self.drawWidth = self.imageWidth * factor
         self.drawHeight = self.imageHeight * factor
コード例 #21
0
    def __init__(self,
                 filename,
                 width=None,
                 height=None,
                 kind='direct',
                 mask=None,
                 lazy=True,
                 srcinfo=None):
        Flowable.__init__(self)
        self._kind = kind
        self.xobj = self.load_xobj(srcinfo)
        self.imageWidth = width
        self.imageHeight = height
        x1, y1, x2, y2 = self.xobj.BBox

        self._w, self._h = x2 - x1, y2 - y1
        if not self.imageWidth:
            self.imageWidth = self._w
        if not self.imageHeight:
            self.imageHeight = self._h
        self.__ratio = float(self.imageWidth) / self.imageHeight
        if kind in ['direct', 'absolute']:
            self.drawWidth = width or self.imageWidth
            self.drawHeight = height or self.imageHeight
        elif kind in ['bound', 'proportional']:
            factor = min(
                float(width) / self.imageWidth,
                float(height) / self.imageHeight)
            self.drawWidth = self.imageWidth * factor
            self.drawHeight = self.imageHeight * factor
コード例 #22
0
    def __init__(self, df, x=0, y=0, width=50, height=200):
        Flowable.__init__(self)
        self.Stats = {}
        self.data = df

        self.x = x
        self.y = y
        self.width = width
        self.height = height
        self.styles = getSampleStyleSheet()
        self.aw = 0
        self.ah = 0
        self.Colors = [(0.7, 0.0, 0.0, 0.9), (0.9, 0.20, 0.25, 0.9),
                       (0.45, 0.7, 0.35, 0.9), (0.9, 0.8, 0.15, 0.9),
                       (0.9, 0.55, 0.15, 0.9)]

        # self.Colors = [(0.65, 0.82, 0.55), (0.97, 0.52, 0.32, 0.9), (0.97, 0.82, 0.20, 0.9),
        #                (0.62, 0.56, 0.67, 0.9), (0.25, 0.33, 0.86, 0.9)]

        # self.Colors = [(0.53, 0.53, 0.53), (0.47, 0.8, 0.7, 0.9), (0.57, 0.79, 0.82, 0.9),
        #                (0.84, 0.84, 0.15, 0.9), (0.91, 0.45, 0.30, 0.9)]

        self.TextPos = [0.1, 0.3, 0.5, 0.7, 0.9]

        self.InitStats()
コード例 #23
0
 def __init__(self, width, height, caption="",
              captionFont=_baseFontNameI, captionSize=12,
              background=None,
              captionTextColor=toColor('black'),
              captionBackColor=None,
              border=None,
              spaceBefore=12,
              spaceAfter=12,
              captionGap=None,
              captionAlign='centre',
              captionPosition='bottom',
              hAlign='CENTER',
              ):
     Flowable.__init__(self)
     self.width = width
     self.figureHeight = height
     self.caption = caption
     self.captionFont = captionFont
     self.captionSize = captionSize
     self.captionTextColor = captionTextColor
     self.captionBackColor = captionBackColor
     self.captionGap = captionGap or 0.5*captionSize
     self.captionAlign = captionAlign
     self.captionPosition = captionPosition
     self._captionData = None
     self.captionHeight = 0  # work out later
     self.background = background
     self.border = border
     self.spaceBefore = spaceBefore
     self.spaceAfter = spaceAfter
     self.hAlign=hAlign
     self._getCaptionPara()  #Larry Meyn's fix - otherwise they all get the number of the last chapter.
コード例 #24
0
 def __init__(self, xml_data, logo=None, width=150, height=50):
     Flowable.__init__(self)
     self.xml_data = xml_data
     self.logo = logo
     self.width = width
     self.height = height
     self.styles = getSampleStyleSheet()
コード例 #25
0
ファイル: flowable.py プロジェクト: moodpulse/l2
 def __init__(self, x=0, y=0, width=0, height=0, text=None):
     Flowable.__init__(self)
     self.x = x
     self.y = y
     self.width = width
     self.height = height
     self.text = text
コード例 #26
0
    def __init__(self, width, height, images, preserve_aspect_ratio=True):
        """ Initialize the 'TriPlanar' class.

        If a None image is passed, an empty box will be displayed.

        Parameters
        ----------
        width: float (mandatory)
            the element width.
        heights: float (mandatory)
            the element height.
        images: 4-uplet or 1-uplet (mandatory)
            the path to the images to be displayed. If a 4-uplet is specified
            the display order is (image_upper_left, image_upper_right,
            image_bottom_left, image_bottom_right)
        preserve_aspect_ratio: bool (optional, default True)
            if True preserve the image aspect ratios.
        """
        Flowable.__init__(self)
        self.width = width
        self.height = height
        self.display_mode = "multi"
        if len(images) == 1:
            self.display_mode = "single"
        self.images = images
        self.preserve_aspect_ratio = preserve_aspect_ratio
        self.missing_file = os.path.join(os.path.dirname(__file__),
                                         "resources", "missing.png")
コード例 #27
0
ファイル: flowable.py プロジェクト: moodpulse/l2
 def __init__(self, qr_value, params):
     # init and store rendering value
     Flowable.__init__(self)
     self.qr_value = qr_value
     self.x_offset = params.get("x", 0) * mm
     self.y_offset = params.get("y", 0) * mm
     self.size = params.get("size", 0) * mm
コード例 #28
0
ファイル: figures.py プロジェクト: alexissmirnov/donomo
 def __init__(
     self,
     width,
     height,
     caption="",
     captionFont="Times-Italic",
     captionSize=12,
     background=None,
     captionTextColor=toColor('black'),
     captionBackColor=None,
     border=1,
     spaceBefore=12,
     spaceAfter=12,
     captionGap=None,
 ):
     Flowable.__init__(self)
     self.width = width
     self.figureHeight = height
     self.caption = caption
     self.captionFont = captionFont
     self.captionSize = captionSize
     self.captionTextColor = captionTextColor
     self.captionBackColor = captionBackColor
     self.captionGap = captionGap
     self._captionData = None
     self.captionHeight = 0  # work out later
     self.background = background
     self.border = border
     self.spaceBefore = spaceBefore
     self.spaceAfter = spaceAfter
コード例 #29
0
 def __init__(self, sectioninfo, x=0 * inch, y=0 * inch, width=7.5 * inch):
     Flowable.__init__(self)
     self.x = x
     self.y = y
     self.width = width
     #self.height = height
     self.sectioninfo = sectioninfo
     print sectioninfo
コード例 #30
0
ファイル: dnp_rs.py プロジェクト: rsheil/dnpworkup
 def __init__(self, x=0, y=-15, width=100, height=15, text=""):
     Flowable.__init__(self)
     self.x = x
     self.y = y
     self.width = width
     self.height = height
     self.text = text
     self.styles = getSampleStyleSheet()
コード例 #31
0
 def __init__(self, texto="", x=0, y=0, width=200, height=10):
     Flowable.__init__(self)
     self.x = x
     self.y = y
     self.width = width
     self.height = height
     self.texto = texto
     self.styles = getSampleStyleSheet()
コード例 #32
0
 def __init__(self, texto="", x=0, y=0, width=200, height=10):
     Flowable.__init__(self)
     self.x      = x
     self.y      = y
     self.width  = width
     self.height = height
     self.texto  = texto
     self.styles = getSampleStyleSheet()
コード例 #33
0
 def __init__(self, width, height, leftIndent=0, spaceBefore=0, showBoundary=False):
     Flowable.__init__(self)
     self.width = width
     self.height = height
     self.leftIndent = leftIndent
     self.spaceBefore = spaceBefore
     self.showBoundary = showBoundary
     self.coords = list()
コード例 #34
0
 def __init__(self, fname, width, height):
     Flowable.__init__(self)
     self.fname = fname
     self.width = width
     self.height = height
     self.x = 0
     self.y = 0
     self.page = 0
コード例 #35
0
 def __init__(self, dataX, dataY, width=600, height=500):
     Flowable.__init__(self)
     self.width = width
     self.height = height
     self.dataX = dataX
     self.dataY = dataY
     self.Padding = {"left": 50, "right": 50, "top": 50, "bottom": 50}
     self.Init()
コード例 #36
0
 def __init__(self,
              doc: SimpleDocTemplate,
              image_src: str,
              size: str = "th") -> None:
     Flowable.__init__(self)
     self.doc = doc
     self.image_src = image_src
     self.size = size
コード例 #37
0
 def __init__(self, width, height, text, font, font_size, color):
     Flowable.__init__(self)
     self.width = width
     self.height = height
     self.text = text
     self.font = font
     self.color = color
     self.font_size = font_size
コード例 #38
0
ファイル: pdf.py プロジェクト: dolvany/dtrace-stap-book
 def __init__(self, fname, width, height):
     Flowable.__init__(self)
     self.fname = fname
     self.width = width 
     self.height = height
     self.x = 0
     self.y = 0
     self.page = 0
コード例 #39
0
    def __init__(self,
                 filename,
                 width=None,
                 height=None,
                 kind='direct',
                 mask=None,
                 lazy=True,
                 srcinfo=None):
        Flowable.__init__(self)
        ext = os.path.splitext(filename)[-1]
        self._kind = kind
        # Prefer svglib for SVG, as it works better
        if ext in ('.svg', '.svgz') and LazyImports.svglib:
            self._mode = 'svglib'
            self.doc = LazyImports.svglib.svg2rlg(filename)
            self.imageWidth = width
            self.imageHeight = height
            x1, y1, x2, y2 = self.doc.getBounds()
            # Actually, svglib's getBounds seems broken.
            self._w, self._h = x2, y2
            if not self.imageWidth:
                self.imageWidth = self._w
            if not self.imageHeight:
                self.imageHeight = self._h
        # Use uniconvertor for the rest
        elif LazyImports.uniconvertor:
            load, plugins, self.uniconvertor_save = LazyImports.uniconvertor
            self._mode = 'uniconvertor'
            self.doc = load.load_drawing(filename.encode('utf-8'))
            self.saver = plugins.find_export_plugin(
                plugins.guess_export_plugin('.pdf'))
            self.imageWidth = width
            self.imageHeight = height
            x1, y1, x2, y2 = self.doc.BoundingRect()
            # The abs is to compensate for what appears to be
            # a bug in uniconvertor. At least doing it this way
            # I get the same values as in inkscape.
            # This fixes Issue 236
            self._w, self._h = abs(x2) - abs(x1), abs(y2) - abs(y1)

            if not self.imageWidth:
                self.imageWidth = self._w
            if not self.imageHeight:
                self.imageHeight = self._h
        else:
            self._mode = None
            log.error("Vector image support not enabled,"
                      " please install svglib and/or uniconvertor.")
        self.__ratio = float(self.imageWidth) / self.imageHeight
        if kind in ['direct', 'absolute']:
            self.drawWidth = width or self.imageWidth
            self.drawHeight = height or self.imageHeight
        elif kind in ['bound', 'proportional']:
            factor = min(
                float(width) / self.imageWidth,
                float(height) / self.imageHeight)
            self.drawWidth = self.imageWidth * factor
            self.drawHeight = self.imageHeight * factor
コード例 #40
0
 def __init__(self, fator=None, style=None, imagem=None, x=0, y=0, width=defaultPageSize[0] - (2 * cm), height=55):
     Flowable.__init__(self)
     self.x      = x
     self.y      = y
     self.width  = width
     self.height = height
     self.fator  = fator
     self.style = style
     self.imagem = imagem
コード例 #41
0
 def __init__(self, x=0, y=0, width=390, height=0, text="", space_after=10):
     Flowable.__init__(self)
     self.x = x
     self.y = y
     self.width = width
     self.height = height
     self.text = text
     self.space_after = space_after
     self.text_width = stringWidth(self.text, fontName='Helvetica', fontSize=20)
コード例 #42
0
ファイル: invoice.py プロジェクト: Foxugly/medagenda
 def __init__(self, doctor):
     Flowable.__init__(self)
     self.user = doctor.refer_userprofile.user
     self.adr = doctor.address
     self.x = 0
     self.y = 25
     self.width = 250
     self.height = 15
     self.styles = getSampleStyleSheet()
コード例 #43
0
ファイル: invoice.py プロジェクト: Foxugly/medagenda
 def __init__(self, doctor):
     Flowable.__init__(self)
     self.user = doctor.refer_userprofile.user
     self.adr = doctor.address
     self.x = 0
     self.y = 25
     self.width = 250
     self.height = 15
     self.styles = getSampleStyleSheet()
コード例 #44
0
 def __init__(self, canvFig, Grid=False, width=500, height=250):
     Flowable.__init__(self)
     self.Stats = {}
     self.CanvFig = canvFig
     self.Grid = Grid
     self.width = width
     self.height = height
     self.aw = 0
     self.ah = 0
     self.InitStats()
コード例 #45
0
ファイル: printing.py プロジェクト: mimischi/django-clock
 def __init__(self, x=0, y=-15, width=40, height=15, text_label="", text_box=""):
     Flowable.__init__(self)
     self.x = x
     self.y = y
     self.width = width
     self.height = height
     self.text_box = text_box
     self.text_label = text_label
     self.styles = getSampleStyleSheet()
     self.styles.add(ParagraphStyle(name='HeadText', fontName='OpenSans-Regular', fontSize=10))
コード例 #46
0
 def __init__(self, s, label=None, fontsize=12, color='black'):
     self.s = s
     self.label = label
     self.fontsize = fontsize
     self.color = color
     if HAS_MATPLOTLIB:
         self.parser = mathtext.MathTextParser("Pdf")
     else:
         log.error('Math support not available, some parts of this ' +
                   'document will be rendered incorrectly. Install ' +
                   'matplotlib.')
     Flowable.__init__(self)
     self.hAlign = 'CENTER'
コード例 #47
0
ファイル: pdf.py プロジェクト: dolvany/dtrace-stap-book
 def __init__(self, coords, paragraphs):
     Flowable.__init__(self)
     self.coords = coords
     
     # Scale pdf images
     s = self.coords.get('s', 1.0)
     for para in paragraphs:
         if isinstance(para, _PDFImage):
             para.scale(s)
         
     self.paragraphs = paragraphs
     
     self._maxWidth = 0
コード例 #48
0
ファイル: svgimage.py プロジェクト: ddd332/presto
 def __init__(self, filename, width=None, height=None, kind='direct',
                                  mask=None, lazy=True, srcinfo=None):
     Flowable.__init__(self)
     ext = os.path.splitext(filename)[-1]
     self._kind = kind
     # Prefer svglib for SVG, as it works better
     if ext in ('.svg', '.svgz') and LazyImports.svglib:
         self._mode = 'svglib'
         self.doc = LazyImports.svglib.svg2rlg(filename)
         self.imageWidth = width
         self.imageHeight = height
         x1, y1, x2, y2 = self.doc.getBounds()
         # Actually, svglib's getBounds seems broken.
         self._w, self._h = x2, y2
         if not self.imageWidth:
             self.imageWidth = self._w
         if not self.imageHeight:
             self.imageHeight = self._h
     # Use uniconvertor for the rest
     elif LazyImports.uniconvertor:
         load, plugins, self.uniconvertor_save = LazyImports.uniconvertor
         self._mode = 'uniconvertor'
         self.doc = load.load_drawing(filename.encode('utf-8'))
         self.saver = plugins.find_export_plugin(
             plugins.guess_export_plugin('.pdf'))
         self.imageWidth = width
         self.imageHeight = height
         x1, y1, x2, y2 = self.doc.BoundingRect()
         # The abs is to compensate for what appears to be
         # a bug in uniconvertor. At least doing it this way
         # I get the same values as in inkscape.
         # This fixes Issue 236
         self._w, self._h = abs(x2)-abs(x1), abs(y2)-abs(y1)
         
         if not self.imageWidth:
             self.imageWidth = self._w
         if not self.imageHeight:
             self.imageHeight = self._h
     else:
         self._mode = None
         log.error("Vector image support not enabled,"
             " please install svglib and/or uniconvertor.")
     self.__ratio = float(self.imageWidth)/self.imageHeight
     if kind in ['direct','absolute']:
         self.drawWidth = width or self.imageWidth
         self.drawHeight = height or self.imageHeight
     elif kind in ['bound','proportional']:
         factor = min(float(width)/self.imageWidth,float(height)/self.imageHeight)
         self.drawWidth = self.imageWidth*factor
         self.drawHeight = self.imageHeight*factor
コード例 #49
0
 def __init__(self, filename, width=None, height=None, kind='direct',
                                  mask=None, lazy=True, srcinfo=None):
     Flowable.__init__(self)
     self._kind = kind
     self.xobj = xobj = self.load_xobj(srcinfo)
     self.imageWidth, self.imageHeight = imageWidth, imageHeight = xobj.w, xobj.h
     width = width or imageWidth
     height = height or imageHeight
     if kind in ['bound','proportional']:
         factor = min(float(width)/imageWidth,float(height)/imageHeight)
         width = factor * imageWidth
         height = factor * imageHeight
     self.drawWidth = width
     self.drawHeight = height
コード例 #50
0
ファイル: pdftools.py プロジェクト: neurospin/pyconnectomist
    def __init__(self, width, height, author, client, poweredby, project,
                 timepoint, subject, date, linespace=14):
        """ Initialize the 'Intro' class.

        Parameters
        ----------
        width: float (mandatory)
            the element width.
        height: float (mandatory)
            the element height.
        author: str (mandatory)
            the author name.
        client: str (mandatory)
            the client name.
        poweredby: str (mandatory)
            the tool used to produce the results.
        project: str (mandatory)
            the project name.
        timepoint: str (mandatory)
            the project timepoint.
        subject: str (mandatory)
            the subject identifier.
        date: str (mandatory)
            the study date.
        linespace: int (mandatory)
            the space between lines.
        """
        Flowable.__init__(self)
        self.width = width
        self.linespace = linespace
        self.left = [
            "Performed by: {0}".format(author),
            "Client: {0}".format(client),
            "Powered by: {0}".format(poweredby)
        ]
        self.right = [
            "Project: {0}".format(project),
            "Subject: {0}".format(subject),
            "Time step: {0}".format(timepoint),
            "QC date: {0}".format(date)
        ]
コード例 #51
0
ファイル: __init__.py プロジェクト: ddd332/presto
    def __init__(self, filename, width=None, height=None, kind='direct',
                                     mask=None, lazy=True, srcinfo=None):
        Flowable.__init__(self)
        self._kind = kind
        self.xobj = self.load_xobj(srcinfo)
        self.imageWidth = width
        self.imageHeight = height
        x1, y1, x2, y2 = self.xobj.BBox

        self._w, self._h = x2 - x1, y2 - y1
        if not self.imageWidth:
            self.imageWidth = self._w
        if not self.imageHeight:
            self.imageHeight = self._h
        self.__ratio = float(self.imageWidth)/self.imageHeight
        if kind in ['direct','absolute']:
            self.drawWidth = width or self.imageWidth
            self.drawHeight = height or self.imageHeight
        elif kind in ['bound','proportional']:
            factor = min(float(width)/self.imageWidth,float(height)/self.imageHeight)
            self.drawWidth = self.imageWidth*factor
            self.drawHeight = self.imageHeight*factor
コード例 #52
0
ファイル: make-forms.py プロジェクト: pobot/POBOT_Junior_Cup
 def __init__(self, tournament):
     Flowable.__init__(self)
     self.tournament = tournament
コード例 #53
0
ファイル: pdf.py プロジェクト: wilsonc86/ledger
 def __init__(self,current_x,current_y,invoice):
     Flowable.__init__(self)
     self.current_x = current_x
     self.current_y = current_y
     self.invoice = invoice
コード例 #54
0
 def __init__(self, width):
     Flowable.__init__(self)
     self.width = width
コード例 #55
0
ファイル: pdf.py プロジェクト: IMIO/imio.helpers
 def __init__(self, barcode, x, y):
     Flowable.__init__(self)
     self.barcode = barcode
     self.x = x
     self.y = y
コード例 #56
0
ファイル: flowables.py プロジェクト: migonzalvar/factura-pdf
 def __init__(self, width, height=0):
     Flowable.__init__(self)
     self.width = width
     self.height = height
コード例 #57
0
 def __init__(self, title):
     self.title = title
     Flowable.__init__(self)
コード例 #58
0
ファイル: layouts.py プロジェクト: 12foo/event-flyer-factory
 def __init__(self, width, margin):
     Flowable.__init__(self)
     self.width = width
     self.margin = margin
     self.hAlign = "CENTER"
     self.height = 0.5*inch
コード例 #59
0
    def __init__ (self, title, key) :
	self._title = title
	self._key   = key
	Flowable.__init__(self)