コード例 #1
0
    def draw(self):
        ptext = '<font size=10><b>Statement Date: {}' \
            '</b></font>'.format('01/01/2017')

        p = Paragraph(ptext, self.styles["Normal"])
        p.wrapOn(self.canv, self.width, self.height)
        p.drawOn(self.canv, *self.coord(110, 14, mm))

        ptext = '''<font size=10>
        <b>Member:</b> {member}<br/>
        <b>Member ID:</b> {member_id}<br/>
        <b>Group #:</b> {group_num}<br/>
        <b>Group name:</b> {group_name}<br/>
        </font>
        '''.format(member=self.xml_data.member_name,
                   member_id=self.xml_data.member_id,
                   group_num=self.xml_data.group_num,
                   group_name=self.xml_data.group_name
                   )
        p = Paragraph(ptext, self.styles["Normal"])
        p.wrapOn(self.canv, self.width, self.height)
        p.drawOn(self.canv, *self.coord(110, 35, mm))
        
        if self.logo:
            logo_obj = Image(self.logo, width=76.2, height=76.2)
            logo_obj.wrapOn(self.canv, self.width, self.height)
            logo_obj.drawOn(self.canv, *self.coord(15, 35, mm))
コード例 #2
0
def header(canvas, doc):
    width, height = doc.pagesize
    
    styles = getSampleStyleSheet()
    
    ptext = '<font size=10><b>Statement Date: {}' \
        '</b></font>'.format('01/01/2017')
    
    img = Image(doc.logo_path, width=76.2, height=76.2)
    img.wrapOn(canvas, width, height)
    img.drawOn(canvas, 100, 725)

    p = Paragraph(ptext, styles["Normal"])
    p.wrapOn(canvas, width, height)
    p.drawOn(canvas, 400, 800)

    ptext = '''<font size=10>
    <b>Member:</b> {member}<br/>
    <b>Member ID:</b> {member_id}<br/>
    <b>Group #:</b> {group_num}<br/>
    <b>Group name:</b> {group_name}<br/>
    </font>
    '''.format(member=doc.data.member_name,
               member_id=doc.data.member_id,
               group_num=doc.data.group_num,
               group_name=doc.data.group_name
               )
    p = Paragraph(ptext, styles["Normal"])
    p.wrapOn(canvas, width, height)
    p.drawOn(canvas, 400, 730)
コード例 #3
0
def header(canvas, doc):
    width, height = doc.pagesize

    styles = get_custom_stylesheet_1()

    if doc.logo_path:
        img = Image(doc.logo_path, width=76.2, height=76.2)
        img.wrapOn(canvas, width, height)
        img.drawOn(canvas, 100, 700)

    ptext = 'Statement Date: {}'.format('01/01/2017')
    p = Paragraph(ptext, styles["Bold"])
    p.wrapOn(canvas, width, height)
    p.drawOn(canvas, 400, 700)

    ptext = '''
    <b>Member:</b> {member}<br/>
    <b>Member ID:</b> {member_id}<br/>
    <b>Group #:</b> {group_num}<br/>
    <b>Group name:</b> {group_name}<br/>
    '''.format(member=doc.data.member_name,
               member_id=doc.data.member_id,
               group_num=doc.data.group_num,
               group_name=doc.data.group_name)
    p = Paragraph(ptext, styles["Normal"])
    p.wrapOn(canvas, width, height)
    p.drawOn(canvas, 400, 730)
コード例 #4
0
    def createDocument(self, canvas, doc):
        """
		Create the document
		"""
        self.c = canvas
        normal = self.styles["Normal"]
        centered = ParagraphStyle(name="centered", alignment=TA_CENTER)

        logo = imgPath + "khatemalogo.jpg"
        img = Image(logo, 50, 50)
        img.wrapOn(self.c, self.width, self.height)
        img.drawOn(self.c, *self.coord(10, 20, mm))

        header_text = "<font size=12><b>Khatmah Medical Factory</b></font>"
        p = Paragraph(header_text, normal)
        p.wrapOn(self.c, self.width, self.height)
        p.drawOn(self.c, *self.coord(30, 8, mm))

        ptext = "<font size=7><a>For the manufacture and maintenance of </a></font>"
        p = Paragraph(ptext, normal)
        p.wrapOn(self.c, self.width, self.height)
        p.drawOn(self.c, *self.coord(30, 13, mm))

        ptext = "<font size=7><a>tools support for people with special needs</a></font>"
        p = Paragraph(ptext, style=normal)
        p.wrapOn(self.c, self.width, self.height)
        p.drawOn(self.c, *self.coord(30, 16, mm))

        ptext = "<font size=8><a><b>First factory is specialized in the Gulf region</b></a></font>"
        p = Paragraph(ptext, style=normal)
        p.wrapOn(self.c, self.width, self.height)
        p.drawOn(self.c, *self.coord(30, 22, mm))

        ptext = "<font size=9><a><b>A Great Hope & Unlimited Ambition</b></a></font>"
        p = Paragraph(ptext, style=normal)
        p.wrapOn(self.c, self.width, self.height)
        p.drawOn(self.c, *self.coord(148, 22, mm))

        self.c.line(*self.coord(10, 22, mm), *self.coord(202, 22, mm))

        ptext = '<font size=10><u><b>All Raw Material </b></u></font>'
        p = Paragraph(ptext, style=normal)
        p.wrapOn(self.c, self.width, self.height)
        p.drawOn(self.c, *self.coord(12, 30, mm))

        datetimestr = datetime.now()
        timestampstr = datetimestr.strftime('%Y-%m-%d %H:%M:%S')
        ptext = "<font size=6><a>{} - </a></font>".format(
            self.refile) + "<font size=6><a>{} </a></font>".format(
                timestampstr)
        p = Paragraph(ptext, style=normal)
        p.wrapOn(self.c, self.width, self.height)
        p.drawOn(self.c, *self.coord(10, 286, mm))

        self.c.line(*self.coord(10, 285, mm), *self.coord(202, 285, mm))
        ptext = '<font size=10><p>CR:1010421226 - PC: 13217 - Wasel : 7966 - Tel & Fax: 014151557 - Mob: 0505721609 <br/>Website: www.khatmahfactory.com - E-mail : [email protected] - 3rd Industrial Area - Riyadh - Saudi Arabia </p></font>'
        p = Paragraph(ptext, centered)
        p.wrapOn(self.c, self.width, self.height)
        p.drawOn(self.c, *self.coord(0, 295, mm))
コード例 #5
0
ファイル: ug2.py プロジェクト: akmiller01/alexm-util
    def createDocument(self):
        """"""
        for page in self.e.findall("page"):
            for image in page.findall("image"):
                logo = Image(image.get("src"))
                logo.drawHeight = int(image.get("height"))
                logo.drawWidth = int(image.get("width"))
                logo.wrapOn(self.c, self.width, self.height)
                logo.drawOn(self.c, *self.coord(int(image.get("left")),int(image.get("top"))+int(image.get("height")) ))
            for text in page.findall("text"):
                if len(text.getchildren())==0:
                    font = self.fonts[text.get("font")]
                    style = ParagraphStyle(
                        'default',
                        fontName="Arial",
                        leading=int(font["size"])+7,
                        fontSize=font["size"],
                        textColor=font["color"],
                        backColor=font["background"],
                        firstLineIndent=int(font["indent"]),
                    )
                    self.createParagraph(text.text, int(text.get("left")), (int(text.get("top"))+int(text.get("height"))),style)
                else:
                    innerText = ElementTree.tostring(text.getchildren()[0])
                    font = self.fonts[text.get("font")]
                    style = ParagraphStyle(
                        'default',
                        fontName="Arial",
                        leading=int(font["size"])+7,
                        fontSize=font["size"],
                        textColor=font["color"],
                        backColor=font["background"],
                        firstLineIndent=int(font["indent"]),
                    )
                    self.createParagraph(innerText, int(text.get("left")), (int(text.get("top"))+int(text.get("height"))),style)
            for line in page.findall("line"):
                self.c.setDash(int(line.get("on")),int(line.get("off")))
                self.c.setStrokeColor(line.get("color"))
                self.c.line(int(line.get("x1")),self.height-int(line.get("y1")),int(line.get("x2")),self.height-int(line.get("y2")))
            for table in page.findall("table"):
                self.c.setDash(1,0)
                tabDat = dataDictionary[table.get("data")]
                if table.get("widths"):
                    colWidths = [float(width) for width in table.get("widths").split(",")]
                else:
                    colWidths = float(table.get("width"))/len(tabDat[0])
                if table.get("heights"):
                    rowHeights = [float(height) for height in table.get("heights").split(",")]
                else:
                    rowHeights = float(table.get("height"))/len(tabDat)
                t = Table(tabDat,colWidths,rowHeights,style=tableStyles[table.get("data")])
                t.wrapOn(self.c, self.width, self.height)
                t.drawOn(self.c, *self.coord(int(table.get("left")), int(table.get("top"))+int(table.get("height"))))

            self.c.showPage()
コード例 #6
0
    def footer(cls, canvas, doc):
        #width, height = doc.pagesize
        #ptext = """<font name=times-roman size=16 color="#028654">Grow A better Tommorrow </font><img src="{LogoPath}" width="112.5" height="54.75"/>""".format(
        #	LogoPath= doc.logo_path_footer)
        #p = Paragraph(ptext, cls.LABEL_STYLE)
        #p.wrapOn(canvas, width, height)
        #p.drawOn(canvas, 250, 35)

        width, height = doc.pagesize
        img = Image(doc.logo_path_footer, width=160, height=75)
        img.wrapOn(canvas, width, height)
        x, y = doc.Position
        img.drawOn(canvas, x - 30, y)
コード例 #7
0
    def create_header(self):
        logo_path = 'img\\logo.png'
        logo = Image(logo_path, 2.222 * inch, 1 * inch)
        logo.wrapOn(self.canvas, self.width, self.height)
        logo.drawOn(self.canvas, *self.coord(.5, 1.5, inch))

        ptext = '<font size=22><b>Soumission</b></font>'
        p = Paragraph(ptext, self.styles['Normal'])
        p.wrapOn(self.canvas, self.width, self.height)
        p.drawOn(self.canvas, *self.coord(3.5, 1))

        ptext = '''  <font size=10>
                    <b>Client:</b> MachinMachine <br/>
                    <b>Date:</b> {}<br/>
                    <b>Adresse:</b> 5 Rue des axes,<br/>
                    Granby, QC , J2J<br/>
                    <b>Tel:</b> (450) 123-1111<br/>
                    </font>
                    '''.format('01/01/2018')
        p = Paragraph(ptext, self.styles['Normal'])
        p.wrapOn(self.canvas, self.width, self.height)
        p.drawOn(self.canvas, *self.coord(1, 3, inch))

        ptext = '''  <font size=10>
                    <b>Fournisseur:</b> SuperShop <br/>
                    <b>Date:</b> {}<br/>
                    <b>Adresse:</b> 123 Rue des colonnes,<br/>
                    Granby, QC J2J<br/>
                    <b>Tel:</b> (450) 123-1234<br/>
                    </font>
                    '''.format('01/01/2018')
        p = Paragraph(ptext, self.styles['Normal'])
        p.wrapOn(self.canvas, self.width, self.height)
        p.drawOn(self.canvas, *self.coord(6, 3, inch))

        ptext = '''  <font size=10>
                    Monsieur Machin,<br/><br/>
                    Voici notre soumission pour l'usinage de vos beignes en titane<br/>
                    selon le dessin beignes_001293_revA.<br/><br/>
                    Prix: $1000.00 / chaque <br/>
                    Quantite: 1000 <br/>
                    Total: $1,000,000.00 <br/>
                    <br/>
                    Cordialement, <br/>
                    <br/>
                    Patrick Touchette
                    </font>
                    '''.format('01/01/2018')
        p = Paragraph(ptext, self.styles['Normal'])
        p.wrapOn(self.canvas, self.width, self.height)
        p.drawOn(self.canvas, *self.coord(1, 6, inch))
コード例 #8
0
ファイル: reporting.py プロジェクト: Lucterios2/core
 def parse_image(self, xmlimage, current_x, current_y, current_w, current_h):
     if xmlimage.text is not None:
         from PIL import ImageFile
         ImageFile.LOAD_TRUNCATED_IMAGES = True
         img_content = xmlimage.text.strip()
         is_base64 = img_content[:len(BASE64_PREFIX)] == BASE64_PREFIX
         if is_base64:
             img_file = open_from_base64(img_content)
         else:
             img_file = open(img_content, "rb")
         try:
             img = Image(img_file)
             if current_h is not None:
                 img.drawHeight = current_h
                 img.drawWidth = current_w
             else:
                 current_h = img.drawHeight
                 current_w = img.drawWidth
             _, new_current_h = img.wrapOn(self.pdf, current_w, current_h)
             img.drawOn(self.pdf, current_x, self.height - current_y - current_h)
             self.position_y = current_y + max(new_current_h, current_h)
             return img
         finally:
             if img_file is not None:
                 img_file.close()
     else:
         return None
コード例 #9
0
ファイル: reporting.py プロジェクト: loudubewe/core
 def parse_image(self, xmlimage, current_x, current_y, current_w,
                 current_h):
     if (xmlimage.text is not None) and (xmlimage.text.strip() != ''):
         from PIL import ImageFile
         ImageFile.LOAD_TRUNCATED_IMAGES = True
         img_content = xmlimage.text.strip()
         is_base64 = img_content[:len(BASE64_PREFIX)] == BASE64_PREFIX
         if is_base64:
             img_file = open_from_base64(img_content)
         else:
             img_file = open(img_content, "rb")
         try:
             img = Image(img_file)
             if current_h is not None:
                 img.drawHeight = current_h
                 img.drawWidth = current_w
             else:
                 current_h = img.drawHeight
                 current_w = img.drawWidth
             _, new_current_h = img.wrapOn(self.pdf, current_w, current_h)
             getLogger('lucterios.printing').debug(
                 "-- parse_image (x=%.2f/y=%.2f/h=%.2f/w=%.2f) --",
                 current_x, current_y, current_h, current_w)
             img.drawOn(self.pdf, current_x,
                        self.height - current_y - current_h)
             self.position_y = current_y + max(new_current_h, current_h)
             return img
         finally:
             if img_file is not None:
                 img_file.close()
     else:
         return None
コード例 #10
0
 def parse_image(self, xmlimage, current_x, current_y, current_w,
                 current_h):
     if xmlimage.text is not None:
         from PIL import ImageFile
         ImageFile.LOAD_TRUNCATED_IMAGES = True
         img_content = xmlimage.text.strip()
         is_base64 = img_content[:len(BASE64_PREFIX)] == BASE64_PREFIX
         if is_base64:
             img_file = open_from_base64(img_content)
         else:
             img_file = open(img_content, "rb")
         try:
             img = Image(img_file)
             if current_h is not None:
                 img.drawHeight = current_h
                 img.drawWidth = current_w
             else:
                 current_h = img.drawHeight
                 current_w = img.drawWidth
             _, new_current_h = img.wrapOn(self.pdf, current_w, current_h)
             img.drawOn(self.pdf, current_x,
                        self.height - current_y - current_h)
             self.position_y = current_y + max(new_current_h, current_h)
             return img
         finally:
             if img_file is not None:
                 img_file.close()
     else:
         return None
コード例 #11
0
    def draw_header(self, canvas, doc):
        """ Draws the static (non-flowable content """
        self.c = canvas

        # Header
        h1 = self.styles['h1']
        h1.fontName = 'Helvetica'
        normal = self.styles['Normal']

        iwidth, iheight = get_image_width_height(LOGO_IMG)
        logo = Image(LOGO_IMG, width=iwidth, height=iheight)
        logo.wrapOn(self.c, self.height, self.width)
        logo_y = iheight + (1 * cm)
        logo.drawOn(self.c, *self.coord(self.padding_x, logo_y))

        # Address
        pro = self.profile
        address_data = [
            u"{} {}".format(pro.first_name, pro.last_name),
            pro.business_name,
            pro.address,
            pro.city,
            pro.postal_code,
        ]
        address_y = logo_y * 1.1 + normal.leading * len(address_data)
        address = Paragraph(u"<br/>".join(address_data), style=normal)
        address.wrapOn(self.c, self.height, self.width)
        address.drawOn(self.c, *self.coord(self.padding_x, address_y))

        # Account/transaction info
        # account_data = [_(u'Account number: %s') % pro.get_account_number()]
        account_data = []
        if self.month:
            account_data.append(
                _(u'Transactions for: %(date)s') %
                {'date': date_format(self.month, "YEAR_MONTH_FORMAT")})
        else:
            account_data.append(_(u'Last 10 transactions'))
            account_data.append(
                _(u'Current balance:') +
                u' {0} {1}'.format(number_format(self.current_balance, 2),
                                   self.currency_symbol))
        account_y = address_y * 1.2 + normal.leading * len(account_data)
        account = Paragraph(u"<br/>".join(account_data), style=normal)
        account.wrapOn(self.c, self.height, self.width)
        account.drawOn(self.c, *self.coord(self.padding_x, account_y))
コード例 #12
0
    def createDocument(self, canvas, doc):

        self.c = canvas
        normal = self.styles['Normal']

        p = Paragraph('Bespoke Pricers Report', normal)
        p.wrapOn(self.c, self.width, self.height)
        p.drawOn(self.c, 250, 800)

        hist = Image(self.hist_name, width=380, height=380)
        hist.wrapOn(self.c, 1, 380)
        hist.drawOn(self.c, x=100, y=1)

        today_frame, monthend_frame = report_frame_creation(
            self.report_frame, self.path)
        freq_im_today = Image(today_frame, width=255, height=255)
        freq_im_ME = Image(monthend_frame, width=255, height=255)

        freq_im_today.wrapOn(self.c, 310, 255)
        freq_im_ME.wrapOn(self.c, 310, 255)

        freq_im_today.drawOn(self.c, 1, 380)
        freq_im_ME.drawOn(self.c, 305, 380)
コード例 #13
0
    def createDocument(self, canvas, doc):
        """
        Create the document
        """
        self.c = canvas
        normal = self.styles["Normal"]
 
        # Load logo file
        logo_name = "firm_logo.jpg"
        #current_dir = os.getcwd() # returns current working directory of a process
        #logo_dir_name = "%s\\utilities\\" % dirname
        logo_file = os.path.join(dirname, logo_name)
        #print "firm_logo directory: %s" %dirname
        #im = Image(r'C:\Local\wavesys\trunk\lab_utils\Test_Environment\Tools\Pic1.jpg', width=2.0*inch, height=0.9*inch)
        im = Image(logo_file, width=2.0*inch, height=0.9*inch)
        #im.hAlign = 'RIGHT'
        
        im.wrapOn(self.c, self.width, self.height)
        im.drawOn(self.c, *self.coord(15.7, 2.3, cm))
        #self.story.append(im)
        
        p = Paragraph(Title, normal)
        p.wrapOn(self.c, self.width, self.height)
        p.drawOn(self.c, *self.coord(8, 2.5, cm))
        #self.c.line(128,121,328,121)

        #Create header
        i = 40
        j = 0
        for field in Header:
            p = Paragraph(field, normal)
            p.wrapOn(self.c, self.width, self.height)
            p.drawOn(self.c, *self.coord(10, i, mm))
            
            p = Paragraph(str(self.Details[j]), normal)
            p.wrapOn(self.c, self.width, self.height)
            p.drawOn(self.c, *self.coord(60, i, mm))
            i=i+5
            j=j+1


        font_size = 12
        
        #SubTitles = [Sub1,Sub2,Sub3]
        SubTitles = [Sub2,Sub3]
        
        point = 0
        for item in SubTitles:
            text = "<font size=%s><b>%s</b></font>" % (font_size,item)
            p = Paragraph(text, style=normal)
            p.wrapOn(self.c, self.width, self.height)
            #p.wrapOn(self.c, self.width-50, self.height)
            #p.drawOn(self.c, 30, 700)
            p.drawOn(self.c, *self.coord(1, point+9.5, cm))
            point = point+9

        '''
        # General Table 1 - Not used
        #self.text_data = [["Test name", "Measured result", "Expected result", "Units", "Status"], ["TX output power", "20", "20", "dBm", "Pass"],["TX EVM", "-23", "-20", "dBm", "Pass"]]
        tableONE = Table(self.gen_data, colWidths=[4.55 * cm, 3 * cm, 3 * cm, 3* cm, 3 * cm])
        
        tableONE.setStyle(TableStyle([
                       ('INNERGRID', (0,0), (-1,-1), 0.25, colors.black),
                       ('BOX', (0,0), (-1,-1), 0.25, colors.black)
                       ]))
        
        tableONE.wrapOn(self.c, self.width, self.height)
        tableONE.drawOn(self.c, *self.coord(1.8, 13.5, cm))
        '''
        
        # System tests Table 2
        tableTWO = Table(self.text_data, colWidths=[4.15 * cm, 3.7 * cm, 3.7 * cm, 2.9 * cm, 1.7* cm, 1.7 * cm])
        
        tableTWO.setStyle(TableStyle([
                       ('INNERGRID', (0,0), (-1,-1), 0.25, colors.black),
                       ('BOX', (0,0), (-1,-1), 0.25, colors.black)
                       ]))
        
        tableTWO.wrapOn(self.c, self.width, self.height)
        tableTWO.drawOn(self.c, *self.coord(1.7, 13.5, cm))

        # GPS/WiFi pairing tests Table 3
        tableTHREE = Table(self.conn_data, colWidths=[4.25 * cm, 3 * cm, 3 * cm, 3 * cm, 1.7* cm, 1.7 * cm])
        
        tableTHREE.setStyle(TableStyle([
                       ('INNERGRID', (0,0), (-1,-1), 0.25, colors.black),
                       ('BOX', (0,0), (-1,-1), 0.25, colors.black)
                       ]))
        
        tableTHREE.wrapOn(self.c, self.width, self.height)
        tableTHREE.drawOn(self.c, *self.coord(1.7, 20.6, cm))
コード例 #14
0
    def createDocument(self):  # funzione che crea il documento
        """"""
        voffset = 65  # offset verticale

        # add a logo and size it
        logo = Image('Image_pdf/Meta-logo.jpg')  # indica la path dell'immagine
        logo.drawHeight = 3 * inch  # indica l'alteza dell'immagine
        logo.drawWidth = 3.5 * inch  # indica la larghezza dell'immagine
        logo.wrapOn(
            self.c, self.width,
            self.height)  # indica l'impostazione dell'immagine nel foglio
        logo.drawOn(self.c, *self.coord(
            65, 80, mm))  # disegna la foto a coordinate fissate 65,80, mm

        address = """<font size="24">
		Stazione di %s%s</font>
        """ % (self.namestation, self.id
               )  # indica il nome della stazione corrente
        p = Paragraph(
            address,
            self.styles["Normal"])  # creazione di un paragrafo di testo
        p.wrapOn(self.c, self.width,
                 self.height)  # importazione del testo nel foglio
        if len(
                self.namestation
        ) == 6:  # if fatti per centrare il nome della stazione nel foglio
            self.X = 188
        elif len(self.namestation) == 3:
            self.X = 223
        elif len(self.namestation) == 4:
            self.X = 214
        elif len(self.namestation) == 5:
            self.X = 205
        elif len(self.namestation) == 7:
            self.X = 180
        elif len(self.namestation) == 8:
            self.X = 175
        elif len(self.namestation) == 9:
            self.X = 172
        elif len(self.namestation) == 10:
            self.X = 168
        elif len(self.namestation) == 11:
            self.X = 164
        elif len(self.namestation) == 12:
            self.X = 160
        elif len(self.namestation) == 13:
            self.X = 156
        elif len(self.namestation) == 14:
            self.X = 152
        elif len(self.namestation) == 15:
            self.X = 148
        elif len(self.namestation) == 16:
            self.X = 144
        elif len(self.namestation) == 17:
            self.X = 140
        elif len(self.namestation) == 18:
            self.X = 136
        elif len(self.namestation) == 19:
            self.X = 132
        elif len(self.namestation) == 20:
            self.X = 128
        elif len(self.namestation) == 21:
            self.X = 124
        elif len(self.namestation) == 22:
            self.X = 120
        elif len(self.namestation) == 23:
            self.X = 116
        p.drawOn(self.c, *self.coord(self.X,
                                     195))  # diesgna il testo a coordinate...

        tMedia = """<font size="12">
		<b>Temperatura media</b></font>
		"""                  # paragrafo di testo
        self.createParagraph(tMedia, 18, voffset + 25)  # creazione paragrafo
        data = [[
            "Dati attesi", "Dati effettivi", "Percentuale di funzionamento"
        ], [valTot, valPresTMED, "%d" % (percTMED) + "%"]]  # dati per tabella
        table = Table(data, colWidths=2 * inch)  # inizializzazione tabella
        table.setStyle([("VALIGN", (-1, -1), (-1, -1), "TOP"),
                        ("GRID", (0, 0), (-1, -1), 1, colors.black),
                        ("GRID", (0, 0), (-1, 0), 1, colors.black)
                        ])  # stile tabella
        table.wrapOn(self.c, self.width,
                     self.height)  # importazione nel foglio della tabella
        table.drawOn(self.c,
                     *self.coord(18, 105,
                                 mm))  # disegno della tabella a coordinate...

        umid = """<font size="12">
		<b>Umidità</b></font>
		"""
        self.createParagraph(umid, 18, voffset + 50)
        data = [[
            "Dati attesi", "Dati effettivi", "Percentuale di funzionamento"
        ], [valTot, valPresUMID, "%d" % (percUMID) + "%"]]
        table = Table(data, colWidths=2 * inch)
        table.setStyle([("VALIGN", (0, 0), (0, 0), "TOP"),
                        ("GRID", (0, 0), (-1, -1), 1, colors.black),
                        ("GRID", (0, 0), (-1, 0), 1, colors.black)])
        table.wrapOn(self.c, self.width, self.height)
        table.drawOn(self.c, *self.coord(18, 130, mm))

        piogg = """<font size="12">
		<b>Pioggia</b></font>
		"""
        self.createParagraph(piogg, 18, voffset + 75)
        data = [[
            "Dati attesi", "Dati effettivi", "Percentuale di funzionamento"
        ], [valTot, valPresPG, "%d" % (percPG) + "%"]]
        table = Table(data, colWidths=2 * inch)
        table.setStyle([("VALIGN", (0, 0), (0, 0), "TOP"),
                        ("GRID", (0, 0), (-1, -1), 1, colors.black),
                        ("GRID", (0, 0), (-1, 0), 1, colors.black)])
        table.wrapOn(self.c, self.width, self.height)
        table.drawOn(self.c, *self.coord(18, 155, mm))

        bagnFogl = """<font size="12">
		<b>Bagnatura fogliare</b></font>
		"""
        self.createParagraph(bagnFogl, 18, voffset + 100)
        data = [[
            "Dati attesi", "Dati effettivi", "Percentuale di funzionamento"
        ], [valTot, valPresFB, "%d" % (percFB) + "%"]]
        table = Table(data, colWidths=2 * inch)
        table.setStyle([("VALIGN", (0, 0), (0, 0), "TOP"),
                        ("GRID", (0, 0), (-1, -1), 1, colors.black),
                        ("GRID", (0, 0), (-1, 0), 1, colors.black)])
        table.wrapOn(self.c, self.width, self.height)
        table.drawOn(self.c, *self.coord(18, 180, mm))

        velVento = """<font size="12">
		<b>Velocità vento</b></font>
		"""
        self.createParagraph(velVento, 18, voffset + 125)
        data = [[
            "Dati attesi", "Dati effettivi", "Percentuale di funzionamento"
        ], [valTot, valPresVenVel,
            "%d" % (percVenVel) + "%"]]
        table = Table(data, colWidths=2 * inch)
        table.setStyle([("VALIGN", (0, 0), (0, 0), "TOP"),
                        ("GRID", (0, 0), (-1, -1), 1, colors.black),
                        ("GRID", (0, 0), (-1, 0), 1, colors.black)])
        table.wrapOn(self.c, self.width, self.height)
        table.drawOn(self.c, *self.coord(18, 205, mm))

        radSolare = """<font size="12">
		<b>Radiazione solare</b></font>
		"""
        self.createParagraph(radSolare, 18, voffset + 150)
        data = [[
            "Dati attesi", "Dati effettivi", "Percentuale di funzionamento"
        ], [valTot, valPresRAD, "%d" % (percRAD) + "%"]]
        table = Table(data, colWidths=2 * inch)
        table.setStyle([("VALIGN", (0, 0), (0, 0), "TOP"),
                        ("GRID", (0, 0), (-1, -1), 1, colors.black),
                        ("GRID", (0, 0), (-1, 0), 1, colors.black)])
        table.wrapOn(self.c, self.width, self.height)
        table.drawOn(self.c, *self.coord(18, 230, mm))

        self.c.showPage()  # per iniziare una nuova pagina

        self.drawing = Drawing(200, 400)  # disegna figura vuota
        self.drawing.rotate(-90)  # ruota figura vuota
        self.data = [(percRAD, percVenVel, percFB, percPG, percUMID, percTMED)
                     ]  #dati per il grafico
        self.names = [
            "Radiazione solare", "Velocità vento", "Bagnatura fogliare",
            "Pioggia", "Umidità", "Temperatura media"
        ]  #nomi per grafico
        self.bc = HorizontalBarChart()  # inizializzazione grafico orizzontale
        self.bc.x = 20  # x del grafico
        self.bc.y = 50  # y del grafico
        self.bc.height = 400  # altezza del grafico
        self.bc.width = 600  # larghezza grafico
        self.bc.data = self.data  # dati del grafico sono uguali a data
        self.bc.strokeColor = colors.white  # colore del grafico
        self.bc.valueAxis.valueMin = 0  # valore minimo asse
        self.bc.valueAxis.valueMax = 100  # valore massimo asse
        self.bc.valueAxis.valueStep = 5  # step di 5 dell'asse
        self.bc.categoryAxis.labels.boxAnchor = 'ne'  # non importante
        self.bc.categoryAxis.labels.dx = -10  # etichettatura grafico
        self.bc.categoryAxis.labels.fontName = 'Helvetica'  # font garfico
        self.bc.categoryAxis.categoryNames = self.names  # asse dei nomi, quello sotto
        self.drawing.add(self.bc)  # aggiunta del grafico alla figura vuota
        renderPDF.draw(self.drawing, self.c, 40,
                       700)  # disegmo del grafico sul pdf

        self.d = Drawing(0, 0)
        self.d.rotate(-90)
        self.c.rotate(-90)
        self.c.setFont('Helvetica', 30)
        self.cb = self.c.drawString(
            -600, 525, "Percentuale di funzionamento"
        )  # creazione titolo per grafico ruotato di -90 gradi
        self.d.add(
            self.cb
        )  # la x è negativa perchè anche le coordinate cambiano in base al punto di orgine
        renderPDF.draw(self.d, self.c, 100, 100)
コード例 #15
0
    def create_document(self, canvas, doc):
        """
        Create the document
        """
        self.c = canvas
        normal = self.styles["Normal"]

        # Load logo file
        logo_name = self.test_data_dir + "firm_logo.jpg"

        logo_file = os.path.join(self.test_data_dir, logo_name)
        im = Image(logo_file, width=2.0*inch, height=0.9*inch)
        #im.hAlign = 'RIGHT'
        
        im.wrapOn(self.c, self.width, self.height)
        im.drawOn(self.c, *self.coord(15.7, 2.3, cm))
        #self.story.append(im)

        p = Paragraph(title, normal)
        p.wrapOn(self.c, self.width, self.height)
        p.drawOn(self.c, *self.coord(8, 2.5, cm))
        #self.c.line(128,121,328,121)
        

        #Create header
        i = 40
        j = 0
        for field in header:
            p = Paragraph(field, normal)
            p.wrapOn(self.c, self.width, self.height)
            p.drawOn(self.c, *self.coord(10, i, mm))
            p = Paragraph(str(self.details[j]), normal)
            p.wrapOn(self.c, self.width, self.height)
            p.drawOn(self.c, *self.coord(60, i, mm))
            i=i+5   # Adding 5 mm between header lines
            j=j+1


        font_size = 12

        # List of report subtitles sections
        sub_titles = [sub2, sub3]
        
        point = 0
        # Set table y coordinates
        if self.internal:
            shift = 11
            table2_coordinate_cm = 16
            table3_coordinate_cm = 22.6
        else:
            shift = 9
            table2_coordinate_cm = 13.5
            table3_coordinate_cm = 20.6

        for item in sub_titles:
            text = "<font size=%s><b>%s</b></font>" % (font_size,item)
            p = Paragraph(text, style=normal)
            p.wrapOn(self.c, self.width, self.height)
            p.drawOn(self.c, *self.coord(1, point+9.5, cm))
            point = point + shift

        '''
        # General Table 1 - Not used
        #self.results = [["Test name", "Measured result", "Expected result", "Units", "Status"], ["TX output power", "20", "20", "dBm", "Pass"],["TX EVM", "-23", "-20", "dBm", "Pass"]]
        tableONE = Table(self.gen_data, colWidths=[4.55 * cm, 3 * cm, 3 * cm, 3* cm, 3 * cm])
        
        tableONE.setStyle(TableStyle([
                       ('INNERGRID', (0,0), (-1,-1), 0.25, colors.black),
                       ('BOX', (0,0), (-1,-1), 0.25, colors.black)
                       ]))
        
        tableONE.wrapOn(self.c, self.width, self.height)
        tableONE.drawOn(self.c, *self.coord(1.8, 13.5, cm))
        '''

        
        # System tests Table 2
        #tableTWO = Table(self.results.insert(0,res_titles), colWidths=[4.15 * cm, 3.7 * cm, 3.7 * cm, 2.9 * cm, 1.7* cm, 1.7 * cm])
        self.results.insert(0,res_titles)
        tableTWO = Table(self.results, colWidths=[4.15 * cm, 3.7 * cm, 3.7 * cm, 2.9 * cm, 1.7* cm, 1.7 * cm])

        tableTWO.setStyle(TableStyle([
                       ('INNERGRID', (0,0), (-1,-1), 0.25, colors.black),
                       ('BOX', (0,0), (-1,-1), 0.25, colors.black)
                       ]))
        
        tableTWO.wrapOn(self.c, self.width, self.height)
        tableTWO.drawOn(self.c, *self.coord(1.7, table2_coordinate_cm, cm))

        # GPS/WiFi pairing tests Table 3
        tableTHREE = Table(self.connections, colWidths=[4.25 * cm, 3 * cm, 3 * cm, 3 * cm, 1.7* cm, 1.7 * cm])
        
        tableTHREE.setStyle(TableStyle([
                       ('INNERGRID', (0,0), (-1,-1), 0.25, colors.black),
                       ('BOX', (0,0), (-1,-1), 0.25, colors.black)
                       ]))
        
        tableTHREE.wrapOn(self.c, self.width, self.height)
        tableTHREE.drawOn(self.c, *self.coord(1.7, table3_coordinate_cm, cm))

        """
コード例 #16
0
    def createDocument(self):
        """"""
        for page in self.e.findall("page"):
            for image in page.findall("image"):
                if image.get("variable") == "True":
                    src = image.get("path") + self.country + "/" + image.get(
                        "src")
                    dest = image.get(
                        "path") + self.country + "/reduced_" + image.get("src")
                    pilImg = PILImage.open(src)
                    size = (pilImg.size[0] / 1.5, pilImg.size[1] / 1.5)
                    pilImg.thumbnail(size, PILImage.NEAREST)
                    pilImg.save(dest, optimize=True)
                else:
                    src = image.get("path") + image.get("src")
                    dest = src
                # logo = Image(dest)
                logo = Image(src)
                logo.drawHeight = int(image.get("height"))
                logo.drawWidth = int(image.get("width"))
                logo.wrapOn(self.c, self.width, self.height)
                logo.drawOn(
                    self.c,
                    *self.coord(
                        int(image.get("left")),
                        int(image.get("top")) + int(image.get("height"))))
            for text in page.findall("text"):
                if len(text.getchildren()) == 0:
                    font = self.fonts[text.get("font")]
                    if text.get("replace"):
                        replacement = dataDictionary[self.country][text.get(
                            "replace")]
                    else:
                        replacement = text.text

                    if text.get("shrink"):
                        fontSize = float(font["size"])
                        height = int(text.get("height"))
                        textLen = float(len(replacement))
                        divisor = max(((textLen / 25.0) + (2.0 / 3.0)), 1)
                        fontSizeAdj = int(fontSize / divisor)
                        fontSizeDiff = int(float(fontSize - fontSizeAdj) / 2.0)
                        heightAdj = height - fontSizeDiff
                    else:
                        fontSizeAdj = int(font["size"])
                        heightAdj = int(text.get("height"))

                    style = ParagraphStyle(
                        'default',
                        fontName="Arial",
                        leading=fontSizeAdj,
                        fontSize=fontSizeAdj,
                        borderPadding=int(font["padding"]),
                        textColor=font["color"],
                        backColor=font["background"],
                        firstLineIndent=int(font["indent"]),
                    )

                    self.createParagraph(replacement, int(text.get("left")),
                                         (int(text.get("top")) + heightAdj),
                                         style)
                else:
                    innerText = ElementTree.tostring(text.getchildren()[0])
                    font = self.fonts[text.get("font")]
                    if text.get("replace"):
                        replacement = dataDictionary[self.country][text.get(
                            "replace")]
                    else:
                        replacement = innerText

                    if text.get("shrink"):
                        fontSize = float(font["size"])
                        height = int(text.get("height"))
                        textLen = float(len(replacement))
                        divisor = max(((textLen / 25.0) + (2.0 / 3.0)), 1)
                        fontSizeAdj = int(fontSize / divisor)
                        fontSizeDiff = int(float(fontSize - fontSizeAdj) / 2.0)
                        heightAdj = height - fontSizeDiff
                    else:
                        fontSizeAdj = int(font["size"])
                        heightAdj = int(text.get("height"))

                    style = ParagraphStyle(
                        'default',
                        fontName="Arial",
                        leading=fontSizeAdj,
                        fontSize=fontSizeAdj,
                        borderPadding=int(font["padding"]),
                        textColor=font["color"],
                        backColor=font["background"],
                        firstLineIndent=int(font["indent"]),
                    )

                    self.createParagraph(replacement, int(text.get("left")),
                                         (int(text.get("top")) + heightAdj),
                                         style)
            for line in page.findall("line"):
                self.c.setDash(int(line.get("on")), int(line.get("off")))
                self.c.setStrokeColor(line.get("color"))
                self.c.line(int(line.get("x1")),
                            self.height - int(line.get("y1")),
                            int(line.get("x2")),
                            self.height - int(line.get("y2")))
            for table in page.findall("table"):
                self.c.setDash(1, 0)
                tabDat = dataDictionary[self.country][table.get("data")]
                if table.get("widths"):
                    colWidths = [
                        float(width)
                        for width in table.get("widths").split(",")
                    ]
                else:
                    colWidths = float(table.get("width")) / len(tabDat[0])
                if table.get("heights"):
                    rowHeights = [
                        float(height)
                        for height in table.get("heights").split(",")
                    ]
                else:
                    rowHeights = float(table.get("height")) / len(tabDat)
                t = Table(tabDat,
                          colWidths,
                          rowHeights,
                          style=tableStyles[table.get("data")])
                t.wrapOn(self.c, self.width, self.height)
                t.drawOn(
                    self.c,
                    *self.coord(
                        int(table.get("left")),
                        int(table.get("top")) + int(table.get("height"))))

            self.c.showPage()
コード例 #17
0
def F2s_CrearPDF(factura, detalle, AIU):
    ##from f2scodigo import ObjCode128
    import f2s_cod128
    import uuid
    import os
    import f2s_funciones
    from reportlab.graphics import renderPDF
    from reportlab.lib.utils import ImageReader
    from reportlab.lib.pagesizes import letter
    from reportlab.pdfgen import canvas
    from reportlab.pdfbase import pdfmetrics
    from reportlab.pdfbase.ttfonts import TTFont
    from reportlab.platypus import Paragraph, Image
    from reportlab.lib.styles import ParagraphStyle
    ##from reportlab.lib.styles import getSampleStyleSheet

    #factura
    rutaimgs = os.path.join(
        request.folder,
        "uploads",
        "{}".format(factura.created_on.year),
        "{}".format(factura.created_on.month),
    )
    #factura.arch_siesa)
    #Letras Definidas
    rutafont = os.path.join(request.folder, "static", "fonts")
    pdfmetrics.registerFont(
        TTFont('Ubuntu', os.path.join(rutafont, 'Ubuntu-R.ttf')))
    pdfmetrics.registerFont(
        TTFont('Ubuntu-Bold', os.path.join(rutafont, 'Ubuntu-B.ttf')))
    pdfmetrics.registerFont(
        TTFont('Ubuntu-Cond', os.path.join(rutafont, 'Ubuntu-C.ttf')))
    pdfmetrics.registerFont(
        TTFont('Cod128', os.path.join(rutafont, 'Codigo128.ttf')))
    #Creacion del archivo de datos factura posicionado
    datos_pdf = os.path.join("/tmp", "{}{}.pdf".format(uuid.uuid4(),
                                                       factura.nrofac))
    pdf_f2s = canvas.Canvas(datos_pdf, pagesize=letter)
    #Resoluucion Dian
    angulo = 90
    pdf_f2s.rotate(angulo)
    pdf_f2s.setFont("Ubuntu", 6)
    pdf_f2s.drawString(215, -512, factura.resolucion.decode('cp437').strip())
    pdf_f2s.rotate(angulo * -1)

    #encabezado
    pdf_f2s.setFont("Ubuntu-Bold", 15)
    posy = 629
    posx = 525
    pdf_f2s.drawRightString(
        posx - 5, posy, "{}-".format(factura.prefijo.decode('cp437').strip()))
    pdf_f2s.drawString(posx, posy, "{}".format(factura.nrofac))
    posx = 30
    pdf_f2s.setFont("Ubuntu-Bold", 9)
    posy = 670
    pdf_f2s.drawString(posx, posy, factura.empresa.decode('cp437').strip())
    pdf_f2s.setFont("Ubuntu", 8)
    posy = 660
    pdf_f2s.drawString(posx, posy,
                       factura.representante.decode('cp437').strip())
    pdf_f2s.drawString(posx, posy - 9, factura.nitfac.decode('cp437').strip())
    pdf_f2s.drawString(
        posx + 160, posy - 9,
        "Tel:{}".format(factura.telefono.decode('cp437')).strip())
    pdf_f2s.drawString(posx, posy - 18,
                       factura.direccion.decode('cp437').strip())
    pdf_f2s.drawString(posx, posy - 27, factura.ciudad.decode('cp437').strip())
    pdf_f2s.drawString(posx, posy - 36, factura.barrio.decode('cp437').strip())
    #Fecha Factura
    posy = 664
    posx = 345
    pdf_f2s.drawString(posx, posy, factura.fecfac[8:10].strip())
    pdf_f2s.drawString(posx + 30, posy, factura.fecfac[5:7].strip())
    pdf_f2s.drawString(posx + 70, posy, factura.fecfac[:4].strip())
    #Fecha Vencimiento
    posy = 625
    pdf_f2s.drawString(posx, posy, factura.fecfac[8:10].strip())
    pdf_f2s.drawString(posx + 30, posy, factura.fecfac[5:7].strip())
    pdf_f2s.drawString(posx + 70, posy, factura.fecfac[:4].strip())

    #Detalle:
    posy = 590
    posx = 30
    for item in detalle:
        pdf_f2s.drawString(posx, posy, item.item.decode('cp437').strip())
        pdf_f2s.drawString(posx + 65, posy,
                           item.detalle.decode('cp437').strip())
        pdf_f2s.drawString(posx + 65, posy - 9,
                           item.detalle1.decode('cp437').strip())
        pdf_f2s.drawRightString(posx + 310, posy,
                                "{:,.0f}".format(item.cantidad))
        pdf_f2s.drawRightString(posx + 385, posy,
                                "{:,.0f}".format(item.unitario))
        pdf_f2s.drawRightString(posx + 470, posy,
                                "{:,.0f}".format(item.valortotal))
        posy -= 22
    #pie
    posy = 295
    posx = 30
    #pdf_f2s.drawString(posx, posy,factura.son.decode('cp437').strip() )
    style = ParagraphStyle(
        name='Normal',
        fontName='Ubuntu',
        fontSize=8,
        leading=10,
    )
    p = Paragraph(factura.son.decode('cp437').strip(), style)
    w, h = p.wrapOn(pdf_f2s, 464, 100)
    p.drawOn(pdf_f2s, posx, posy - h)

    posy = 260
    posx = 30
    style = ParagraphStyle(
        name='Normal',
        fontName='Ubuntu',
        fontSize=8,
        leading=9,
    )
    p = Paragraph(factura.observaciones.decode('cp437').strip(), style)
    w, h = p.wrapOn(pdf_f2s, 280, 100)
    p.drawOn(pdf_f2s, posx, posy - h)

    posy = 264
    posx = 320
    pdf_f2s.setFont("Ubuntu", 7)
    pdf_f2s.drawString(posx, posy,
                       "cufe:{}".format(factura.cufe.decode('cp437').strip()))
    pdf_f2s.setFont("Ubuntu", 8)
    posy = 250
    posx = 490
    pdf_f2s.drawRightString(posx, posy, "{:,.0f}".format(factura.valfac))
    pdf_f2s.drawRightString(posx, posy - 10, "{:,.0f}".format(factura.valiva))
    pdf_f2s.setFont("Ubuntu-Bold", 10)
    pdf_f2s.drawRightString(posx, posy - 32, "{:,.0f}".format(factura.valtot))

    posy = 116
    posx = 30
    pdf_f2s.setFont("Ubuntu", 7)
    pdf_f2s.drawString(posx, posy, factura.empresa.decode('cp437').strip())
    pdf_f2s.drawString(posx + 150, posy, "{}".format(factura.nrofac))
    pdf_f2s.drawString(posx + 230, posy,
                       factura.nitfac.decode('cp437').strip())
    pdf_f2s.drawString(posx + 307, posy, "{:,.0f}".format(factura.valtot))
    pdf_f2s.drawString(posx + 358, posy, factura.fecfac[8:10].strip())
    pdf_f2s.drawString(posx + 385, posy, factura.fecfac[5:7].strip())
    pdf_f2s.drawString(posx + 412, posy, factura.fecfac[:4].strip())

    #codigo de barras
    posy = 15
    posx = 75
    pdf_f2s.setFont("Ubuntu", 7)
    codigo = "(415)7709998015937(8020){:06d}{:018d}(3900){:010d}(96){}{}{}".format(
        factura.nrofac, int(factura.nitfac.strip()), int(factura.valtot),
        factura.fecfac[8:10], factura.fecfac[5:7], factura.fecfac[:4])
    pdf_f2s.drawString(posx, posy, codigo)
    posy = 25
    posx = 10
    codigobar = f2s_cod128.code128_image(chr(102) + codigo)
    pdf_f2s.drawImage(ImageReader(codigobar), posx, posy, width=450, height=35)

    #qr
    posy = 670
    posx = 503
    rutaimagenes = os.path.join(request.folder, "uploads",
                                str(factura.created_on.year),
                                str(factura.created_on.month), factura.arch_qr)
    logo = Image(rutaimagenes)
    logo.drawHeight = logo.drawHeight - 32
    logo.drawWidth = logo.drawWidth - 32
    logo.wrapOn(pdf_f2s, logo.drawWidth, logo.drawHeight)
    logo.drawOn(pdf_f2s, posx, posy)

    #Activar aui
    if AIU:
        posy = 300
        posx = 30
        pdf_f2s.setFont("Ubuntu", 7)
        pdf_f2s.drawString(
            posx, posy, "AIU 10%:{:,.0f} Tomado desde Subtotal".format(
                factura.valfac * .1))

    #Fin
    pdf_f2s.showPage()
    pdf_f2s.save()
    return datos_pdf
コード例 #18
0
    def createDocument(self):
        """"""
        voffset = 30

        # create header data
        header = """<font size="9">
        5 Year Maintenance Certificate<br/>
        %s_C%s<br/>
        Rev%s</font>
        """ % (self.job, self.report, self.revision)
        p = Paragraph(header, myStyle)

        # create header logo and size it
        logo = Image("img/image1.png")
        logo.drawHeight = 0.75 * inch
        logo.drawWidth = 3.43 * inch

        # combine logo and header data into array for table creation
        data = [[logo, p]]

        # create table for placement in header region, and define location
        table = Table(data, colWidths=4 * inch)
        table.setStyle([("VALIGN", (0, 0), (0, 0), "TOP"),
                        ("VALIGN", (-1, -1), (-1, -1), "CENTER"),
                        ("ALIGN", (-1, -1), (-1, -1), "RIGHT")])
        table.wrapOn(self.c, self.width - 100, self.height)
        table.drawOn(self.c, *self.coord(5, 25, mm))

        # create Certificate title
        ptext = "<b>Certificate of Inspection & Compatibility</b>"
        self.createParagraph(ptext, 0, voffset + 8, TitleStyle)

        # create body text of the certificate and style
        if self.isRemote == 'no':
            ptext = """
            <b><i>Offshore Technical Compliance LLC</i></b> was present for the following 5 Year Maintenance Inspection of the equipment listed below. 
             The inspections were conducted per <b>%s’s</b> Preventative Maintenance (PM) program and the equipment 
             manufacture’s guidelines.
            """ % self.organization
        else:
            ptext = """
            <b><i>Offshore Technical Compliance LLC</i></b> has verified the following 5 Year Maintenance Inspection of the equipment listed below. 
             The inspections were conducted per <b>%s’s</b> Preventative Maintenance (PM) program and the equipment 
             manufacture’s guidelines.
            """ % self.organization
        p = Paragraph(ptext, self.styles["Normal"])
        p.wrapOn(self.c, self.width - 70, self.height)
        p.drawOn(self.c, *self.coord(15, voffset + 25, mm))

        # create first table
        # create data structure for table parsing
        data = self.dataPrepTable1(self.jobdata, self.certdata)
        table = Table(data, colWidths=3.6 * inch)
        table.setStyle([("VALIGN", (0, 0), (0, 0), "TOP"),
                        ("ALIGN", (0, 0), (0, 0), "CENTER"),
                        ('BACKGROUND', (0, 0), (0, 0), HexColor(0x3a3b3d)),
                        ('BACKGROUND', (0, 7), (0, 7), HexColor(0x595959)),
                        ('SPAN', (0, 0), (1, 0)),
                        ('INNERGRID', (0, 0), (-1, -1), 0.25, colors.black),
                        ('BOX', (0, 0), (-1, -1), 0.25, colors.black)])
        table.wrapOn(self.c, self.width, self.height)
        table.drawOn(self.c, *self.coord(15, voffset + 80, mm))

        # create second table
        data = self.dataPrepTable2(self.certdata)
        table = Table(data, colWidths=3.6 * inch)
        if len(self.certdata[1]) > 45:
            table.setStyle([("VALIGN", (0, 0), (0, 0), "TOP"),
                            ("ALIGN", (0, 0), (0, 0), "CENTER"),
                            ('BACKGROUND', (0, 0), (0, 0), HexColor(0x3a3b3d)),
                            ('SPAN', (0, 0), (1, 0)),
                            ('INNERGRID', (0, 0), (-1, -1), 0.25,
                             colors.black), ('FONTSIZE', (1, 1), (1, 1), 8),
                            ('BOX', (0, 0), (-1, -1), 0.25, colors.black)])
        else:
            table.setStyle([("VALIGN", (0, 0), (0, 0), "TOP"),
                            ("ALIGN", (0, 0), (0, 0), "CENTER"),
                            ('BACKGROUND', (0, 0), (0, 0), HexColor(0x3a3b3d)),
                            ('SPAN', (0, 0), (1, 0)),
                            ('INNERGRID', (0, 0), (-1, -1), 0.25,
                             colors.black),
                            ('BOX', (0, 0), (-1, -1), 0.25, colors.black)])
        table.wrapOn(self.c, self.width, self.height)
        table.drawOn(self.c, *self.coord(15, voffset + 130, mm))

        # # create third table
        # data = self.dataPrepTable3(self.certdata)
        # table = Table(data, colWidths=3.6 * inch)
        # table.setStyle([("VALIGN", (0, 0), (0, 0), "TOP"),
        #                 ("ALIGN", (0, 0), (0, 0), "CENTER"),
        #                 ('BACKGROUND', (0, 0), (0, 0), HexColor(0x3a3b3d)),
        #                 ('SPAN', (0, 0), (1, 0)),
        #                 ('INNERGRID', (0, 0), (-1, -1), 0.25, colors.black),
        #                ('BOX', (0, 0), (-1, -1), 0.25, colors.black)])
        # table.wrapOn(self.c, self.width, self.height)
        # table.drawOn(self.c, *self.coord(15, voffset + 167, mm))

        # create signature area (table)
        if self.isRemote == 'no':
            data = [[
                'Witness:', self.Witness, 'Date:',
                datetime.date.today().strftime('%d %b %Y')
            ], [],
                    [
                        'Engineering Approval:', self.Engineering, 'Date:',
                        datetime.date.today().strftime('%d %b %Y')
                    ]]
        else:
            data = [[
                'Verification:', self.Witness, 'Date:',
                datetime.date.today().strftime('%d %b %Y')
            ], [],
                    [
                        'Engineering Approval:', self.Engineering, 'Date:',
                        datetime.date.today().strftime('%d %b %Y')
                    ]]
        table = Table(data,
                      colWidths=(1.5 * inch, 3.75 * inch, 0.6 * inch,
                                 1.35 * inch))
        table.setStyle([("VALIGN", (0, 0), (0, 0), "TOP"),
                        ("ALIGN", (0, 0), (0, 1), "RIGHT"),
                        ("ALIGN", (1, 0), (1, 2), "RIGHT")])
        table.wrapOn(self.c, self.width, self.height)
        table.drawOn(self.c, *self.coord(15, voffset + 200, mm))

        # add in signatures
        logo = Image("img/signatures/" + self.WitnessSig)
        logo.drawHeight = .5 * inch
        logo.drawWidth = 1.5 * inch
        logo.wrapOn(self.c, self.width, self.height)
        logo.drawOn(self.c, *self.coord(65, voffset + 187, mm))

        logo = Image("img/signatures/" + self.EngineeringSig)
        logo.drawHeight = .5 * inch
        logo.drawWidth = 1.5 * inch
        logo.wrapOn(self.c, self.width, self.height)
        logo.drawOn(self.c, *self.coord(65, voffset + 202, mm))

        # create footer area (table)
        data = [['www.otcompliance.com', 'PROPRIETARY/CONFIDENTIAL', '1']]
        table = Table(data, colWidths=(2.7 * inch, 2.7 * inch, 2.7 * inch))
        table.setStyle([
            ("VALIGN", (0, 0), (0, 0), "TOP"),
            ("ALIGN", (1, 0), (1, 0), "CENTER"),
            ("ALIGN", (-1, -1), (-1, -1), "RIGHT"),
        ])
        table.wrapOn(self.c, self.width, self.height)
        table.drawOn(self.c, *self.coord(5, voffset + 245, mm))
        self.drawLine()
コード例 #19
0
	def createDocument(self):													# funzione che crea il documento
		""""""
		voffset = 65															# offset verticale

		# add a logo and size it
		logo = Image('Image_pdf/Meta-logo.jpg')									# indica la path dell'immagine
		logo.drawHeight = 3*inch												# indica l'alteza dell'immagine
		logo.drawWidth = 3.5*inch												# indica la larghezza dell'immagine
		logo.wrapOn(self.c, self.width, self.height)							# indica l'impostazione dell'immagine nel foglio
		logo.drawOn(self.c, *self.coord(65, 80, mm))
																				# disegna la foto a coordinate fissate 65,80, mm
		tMedia = """<font size="12">
		<b>Data riferimento: 01/01/2017 a 31/12/2017</b></font>
		"""																		# paragrafo di testo
		self.createParagraph(tMedia, 18, voffset+10)
		data = [["Nome stazione", "Temperatura media", "Umidità", "Pioggia", "Bagnatura fogliare", "Velocità vento", "Radiazione solare"],
				[bb[0], bb[1], bb[2], bb[3], bb[4], bb[5], bb[6]],
				[bb[7], bb[8], bb[9], bb[10], bb[11], bb[12], bb[13]],
				[bb[14], bb[15], bb[16], bb[17], bb[18], bb[19], bb[20]],
				[bb[21], bb[22], bb[23], bb[24], bb[25], bb[26], bb[27]],
				[bb[28], bb[29], bb[30], bb[31], bb[32], bb[33], bb[34]],
				[bb[35], bb[36], bb[37], bb[38], bb[39], bb[40], bb[41]],
				[bb[42], bb[43], bb[44], bb[45], bb[46], bb[47], bb[48]],
				[bb[49], bb[50], bb[51], bb[52], bb[53], bb[54], bb[55]],
				[bb[56], bb[57], bb[58], bb[59], bb[60], bb[61], bb[62]],
				[bb[63], bb[64], bb[65], bb[66], bb[67], bb[68], bb[69]],
				[bb[70], bb[71], bb[72], bb[73], bb[74], bb[75], bb[76]],
				[bb[77], bb[78], bb[79], bb[80], bb[81], bb[82], bb[83]],
				[bb[84], bb[85], bb[86], bb[87], bb[88], bb[89], bb[90]],
				[bb[91], bb[92], bb[93], bb[94], bb[95], bb[96], bb[97]],
				[bb[98], bb[99], bb[100], bb[101], bb[102], bb[103], bb[104]],
				["Caldonazzo Brina", "0", "0", "0", "0", "0", "0"],
				[bb[112], bb[113], bb[114], bb[115], bb[116], bb[117], bb[118]],
				[bb[119], bb[120], bb[121], bb[122], bb[123], bb[124], bb[125]],
				[bb[126], bb[127], bb[128], bb[129], bb[130], bb[131], bb[132]],
				[bb[133], bb[134], bb[135], bb[136], bb[137], bb[138], bb[139]],
				[bb[140], bb[141], bb[142], bb[143], bb[144], bb[145], bb[146]],
				[bb[147], bb[148], bb[149], bb[150], bb[151], bb[152], bb[153]],
				[bb[154], bb[155], bb[156], bb[157], bb[158], bb[159], bb[160]],
				[bb[161], bb[162], bb[163], bb[164], bb[165], bb[166], bb[167]],
				[bb[168], bb[169], bb[170], bb[171], bb[172], bb[173], bb[174]],
				[bb[175], bb[176], bb[177], bb[178], bb[179], bb[180], bb[181]]]						# dati per tabella
		table = Table(data, colWidths=inch)									# inizializzazione tabella
		table.setStyle([("VALIGN", (-1,-1), (-1,-1), "TOP"),
						("GRID", (0,0), (-1,-1), 1, colors.black),
						("GRID", (0,0), (-1,0), 1, colors.black),
						("FONTSIZE", (0,0), (-1,-1), 7),
						("ALIGN", (0,0), (-1,-1), "CENTER")])				# stile tabella
		table.wrapOn(self.c, self.width, self.height)							# importazione nel foglio della tabella
		table.drawOn(self.c, *self.coord(18, 250, mm))							# disegno della tabella a coordinate...

		self.c.showPage()

		data1 = [["Nome stazione", "Temperatura media", "Umidità", "Pioggia", "Bagnatura fogliare", "Velocità vento", "Radiazione solare"],
				[bb[182], bb[183], bb[184], bb[185], bb[186], bb[187], bb[188]],
				[bb[189], bb[190], bb[191], bb[192], bb[193], bb[194], bb[195]],
				[bb[196], bb[197], bb[198], bb[199], bb[200], bb[201], bb[202]],
				[bb[203], bb[204], bb[205], bb[206], bb[207], bb[208], bb[209]],
				[bb[210], bb[211], bb[212], bb[213], bb[214], bb[215], bb[216]],
				[bb[217], bb[218], bb[219], bb[220], bb[221], bb[222], bb[223]],
				[bb[224], bb[225], bb[226], bb[227], bb[228], bb[229], bb[230]],
				[bb[231], bb[232], bb[233], bb[234], bb[235], bb[236], bb[237]],
				[bb[238], bb[239], bb[240], bb[241], bb[242], bb[243], bb[244]],
				[bb[245], bb[246], bb[247], bb[248], bb[249], bb[250], bb[251]],
				[bb[252], bb[253], bb[254], bb[255], bb[256], bb[257], bb[258]],
				[bb[259], bb[260], bb[261], bb[262], bb[263], bb[264], bb[265]],
				[bb[266], bb[267], bb[268], bb[269], bb[270], bb[271], bb[272]],
				[bb[273], bb[274], bb[275], bb[276], bb[277], bb[278], bb[279]],
				["Mezzocorona Piovi", bb[281], bb[282], bb[283], bb[284], bb[285], bb[286]],
				[bb[287], bb[288], bb[289], bb[290], bb[291], bb[292], bb[293]],
				[bb[294], bb[295], bb[296], bb[297], bb[298], bb[299], bb[300]],
				[bb[301], bb[302], bb[303], bb[304], bb[305], bb[306], bb[307]],
				[bb[308], bb[309], bb[310], bb[311], bb[312], bb[313], bb[314]],
				[bb[315], bb[316], bb[317], bb[318], bb[319], bb[320], bb[321]],
				[bb[322], bb[323], bb[324], bb[325], bb[326], bb[327], bb[328]],
				[bb[329], bb[330], bb[331], bb[332], bb[333], bb[334], bb[335]],
				[bb[336], bb[337], bb[338], bb[339], bb[340], bb[341], bb[342]],
				[bb[343], bb[344], bb[345], bb[346], bb[347], bb[348], bb[349]],
				[bb[350], bb[351], bb[352], bb[353], bb[354], bb[355], bb[356]],
				[bb[357], bb[358], bb[359], bb[360], bb[361], bb[362], bb[363]],
				[bb[364], bb[365], bb[366], bb[367], bb[368], bb[369], bb[370]],
				[bb[371], bb[372], bb[373], bb[374], bb[375], bb[376], bb[377]],
				[bb[378], bb[379], bb[380], bb[381], bb[382], bb[383], bb[384]],
				[bb[385], bb[386], bb[387], bb[388], bb[389], bb[390], bb[391]],
				[bb[392], bb[393], bb[394], bb[395], bb[396], bb[397], bb[398]],
				[bb[399], bb[400], bb[401], bb[402], bb[403], bb[404], bb[405]],
				[bb[406], bb[407], bb[408], bb[409], bb[410], bb[411], bb[412]],
				[bb[413], bb[414], bb[415], bb[416], bb[417], bb[418], bb[419]]]
		table1 = Table(data1, colWidths=inch)									# inizializzazione tabella
		table1.setStyle([("VALIGN", (-1,-1), (-1,-1), "TOP"),
						("GRID", (0,0), (-1,-1), 1, colors.black),
						("GRID", (0,0), (-1,0), 1, colors.black),
						("FONTSIZE", (0,0), (-1,-1), 7),
						("ALIGN", (0,0), (-1,-1), "CENTER")])				# stile tabella
		table1.wrapOn(self.c, self.width, self.height)							# importazione nel foglio della tabella
		table1.drawOn(self.c, *self.coord(18, 250, mm))							# disegno della tabella a coordinate...

		self.c.showPage()
		data2 = [["Nome stazione", "Temperatura media", "Umidità", "Pioggia", "Bagnatura fogliare", "Velocità vento", "Radiazione solare"],
				[bb[420], bb[421], bb[422], bb[423], bb[424], bb[425], bb[426]],
				[bb[427], bb[428], bb[429], bb[430], bb[431], bb[432], bb[433]],
				[bb[434], bb[435], bb[436], bb[437], bb[438], bb[439], bb[440]],
				[bb[441], bb[442], bb[443], bb[444], bb[445], bb[446], bb[447]],
				[bb[448], bb[449], bb[450], bb[451], bb[452], bb[453], bb[454]],
				[bb[455], bb[456], bb[457], bb[458], bb[459], bb[460], bb[461]],
				[bb[462], bb[463], bb[464], bb[465], bb[466], bb[467], bb[468]],
				[bb[469], bb[470], bb[471], bb[472], bb[473], bb[474], bb[475]],
				[bb[476], bb[477], bb[478], bb[479], bb[480], bb[481], bb[482]],
				[bb[483], bb[484], bb[485], bb[486], bb[487], bb[488], bb[489]],
				[bb[490], bb[491], bb[492], bb[493], bb[494], bb[495], bb[496]],
				[bb[497], bb[498], bb[499], bb[500], bb[501], bb[502], bb[503]],
				[bb[504], bb[505], bb[506], bb[507], bb[508], bb[509], bb[510]],
				[bb[511], bb[512], bb[513], bb[514], bb[515], bb[516], bb[517]],
				[bb[518], bb[519], bb[520], bb[521], bb[522], bb[523], bb[524]],
				[bb[525], bb[526], bb[527], bb[528], bb[529], bb[530], bb[531]],
				[bb[532], bb[533], bb[534], bb[535], bb[536], bb[537], bb[538]],
				[bb[539], bb[540], bb[541], bb[542], bb[543], bb[544], bb[545]],
				[bb[546], bb[547], bb[548], bb[549], bb[550], bb[551], bb[552]],
				[bb[553], bb[554], bb[555], bb[556], bb[557], bb[558], bb[559]],
				[bb[560], bb[561], bb[562], bb[563], bb[564], bb[565], bb[566]],
				[bb[567], bb[568], bb[569], bb[570], bb[571], bb[572], bb[573]],
				[bb[574], bb[575], bb[576], bb[577], bb[578], bb[579], bb[580]],
				[bb[581], bb[582], bb[583], bb[584], bb[585], bb[586], bb[587]],
				[bb[588], bb[589], bb[590], bb[591], bb[592], bb[593], bb[594]],
				[bb[595], bb[596], bb[597], bb[598], bb[599], bb[600], bb[601]],]
		table2 = Table(data2, colWidths=inch)									# inizializzazione tabella
		table2.setStyle([("VALIGN", (-1,-1), (-1,-1), "TOP"),
						("GRID", (0,0), (-1,-1), 1, colors.black),
						("GRID", (0,0), (-1,0), 1, colors.black),
						("FONTSIZE", (0,0), (-1,-1), 7),
						("ALIGN", (0,0), (-1,-1), "CENTER")])				# stile tabella
		table2.wrapOn(self.c, self.width, self.height)							# importazione nel foglio della tabella
		table2.drawOn(self.c, *self.coord(18, 200, mm))							# disegno della tabella a coordinate...
コード例 #20
0
    def Export(self, filename):
        pageWidth = 9.0 * cm
        pageHeight = 5.0 * cm

        doc = canvas.Canvas(filename, pagesize=(pageWidth, pageHeight))

        pdfmetrics.registerFont(TTFont('Arial', 'arial.ttf'))
        pdfmetrics.registerFont(TTFont('ArialBold', "arial_bold.ttf"))

        imageRatio = 1.41
        imageHeight = pageHeight / 2.0  #imageWidth*imageRatio
        imageWidth = pageWidth / 4.5

        im = Image("logo.png", imageWidth, imageHeight)
        im.wrapOn(doc, 0, 0)
        im.drawOn(doc, (pageWidth / 2.0 - imageWidth) / 2.0,
                  (pageHeight - imageHeight) / 2.0)

        line = doc.beginPath()
        line.moveTo(pageWidth / 2.0, pageHeight / 8.0)
        line.lineTo(pageWidth / 2.0, 7.0 * pageHeight / 8.0)
        line.close()
        doc.drawPath(line)

        textPos_X = 9.0 * pageWidth / 16.0

        function2MoveVal = 0.0
        if (self.function2 == ""):
            function2MoveVal = 0.2

        textObj = doc.beginText()
        textObj.setTextOrigin(textPos_X, 6.6 * pageHeight / 8.0)
        textObj.setFont("ArialBold", 8)
        textObj.textOut(self.name)
        doc.drawText(textObj)

        textObj = doc.beginText()
        textObj.setTextOrigin(textPos_X, 6.2 * pageHeight / 8.0)
        textObj.setFont("Arial", 6)
        textObj.textOut(self.function1)
        doc.drawText(textObj)

        textObj = doc.beginText()
        textObj.setTextOrigin(textPos_X, 5.8 * pageHeight / 8.0)
        textObj.setFont("Arial", 6)
        textObj.textOut(self.function2)
        doc.drawText(textObj)

        textObj = doc.beginText()
        textObj.setTextOrigin(textPos_X,
                              (4.6 + function2MoveVal) * pageHeight / 8.0)
        textObj.setFont("ArialBold", 8)
        textObj.textOut(self.company)
        doc.drawText(textObj)

        textObj = doc.beginText()
        textObj.setTextOrigin(textPos_X,
                              (4.2 + function2MoveVal) * pageHeight / 8.0)
        textObj.setFont("Arial", 6)
        textObj.textOut(self.postal_city)
        doc.drawText(textObj)

        textObj = doc.beginText()
        textObj.setTextOrigin(textPos_X,
                              (3.8 + function2MoveVal) * pageHeight / 8.0)
        textObj.setFont("Arial", 6)
        textObj.textOut(self.street)
        doc.drawText(textObj)

        textObj = doc.beginText()
        textObj.setTextOrigin(textPos_X,
                              (3.0 + function2MoveVal) * pageHeight / 8.0)
        textObj.setFont("Arial", 6)
        textObj.textOut(self.stationary)
        doc.drawText(textObj)

        textObj = doc.beginText()
        textObj.setTextOrigin(textPos_X,
                              (2.6 + function2MoveVal) * pageHeight / 8.0)
        textObj.setFont("Arial", 6)
        textObj.textOut(self.mobile)
        doc.drawText(textObj)

        textObj = doc.beginText()
        textObj.setTextOrigin(textPos_X,
                              (2.2 + function2MoveVal) * pageHeight / 8.0)
        textObj.setFont("Arial", 6)
        textObj.textOut(self.mail)
        doc.drawText(textObj)

        textObj = doc.beginText()
        textObj.setTextOrigin(textPos_X, 1.0 * pageHeight / 8.0)
        textObj.setFont("ArialBold", 6)
        textObj.textOut(self.web)
        doc.drawText(textObj)

        doc.showPage()

        im = Image("logo.png", imageWidth, imageHeight)
        im.wrapOn(doc, 0, 0)
        im.drawOn(doc, (pageWidth / 2.0 - imageWidth) / 2.0,
                  (pageHeight - imageHeight) / 2.0)

        line = doc.beginPath()
        line.moveTo(pageWidth / 2.0, pageHeight / 8.0)
        line.lineTo(pageWidth / 2.0, 7.0 * pageHeight / 8.0)
        line.close()
        doc.drawPath(line)

        maxLinesCount = 14
        linesCount = len(self.description)
        if linesCount > maxLinesCount:
            linesCount = maxLinesCount

        textPos_Y = ((maxLinesCount - linesCount) / 2 +
                     linesCount) * 0.4 * pageHeight / 8.0 + pageHeight / 8.0

        for textLine in range(linesCount):
            textObj = doc.beginText()
            textObj.setTextOrigin(textPos_X, textPos_Y)

            for style in self.descriptionStyles[textLine]:
                if style[2] == 0:
                    textObj.setFont('Arial', 6)
                    textObj.textOut(
                        self.description[textLine][style[0]:style[1] + 1])
                else:
                    textObj.setFont('ArialBold', 6)
                    textObj.textOut(
                        self.description[textLine][style[0]:style[1] + 1])

            #if self.description[textLine][1]==0:
            #   textObj.setFont("Arial",6)
            #elif self.description[textLine][1]==1:
            #	textObj.setFont("ArialBold",6)
            #textObj.textOut(self.description[textLine][0])
            doc.drawText(textObj)

            textPos_Y -= 0.4 * pageHeight / 8.0

        doc.save()

        return doc
コード例 #21
0
ファイル: render.py プロジェクト: akmiller01/alexm-util
    def createDocument(self):
        """"""
        for page in self.e.findall("page"):
            for image in page.findall("image"):
                if image.get("variable")=="True":
                    src = image.get("path")+self.country+"/"+image.get("src")
                    dest = image.get("path")+self.country+"/reduced_"+image.get("src")
                    pilImg = PILImage.open(src)
                    size = (pilImg.size[0]/1.5,pilImg.size[1]/1.5)
                    pilImg.thumbnail(size,PILImage.NEAREST)
                    pilImg.save(dest,optimize=True)
                else:
                    src = image.get("path")+image.get("src")
                    dest = src
                # logo = Image(dest)
                logo = Image(src)
                logo.drawHeight = int(image.get("height"))
                logo.drawWidth = int(image.get("width"))
                logo.wrapOn(self.c, self.width, self.height)
                logo.drawOn(self.c, *self.coord(int(image.get("left")),int(image.get("top"))+int(image.get("height")) ))
            for text in page.findall("text"):
                if len(text.getchildren())==0:
                    font = self.fonts[text.get("font")]
                    if text.get("replace"):
                        replacement = dataDictionary[self.country][text.get("replace")]
                    else:
                        replacement = text.text
                        
                    if text.get("shrink"):
                        fontSize = float(font["size"])
                        height = int(text.get("height"))
                        textLen = float(len(replacement))
                        divisor = max(((textLen/25.0)+(2.0/3.0)),1)
                        fontSizeAdj = int(fontSize / divisor)
                        fontSizeDiff = int(float(fontSize-fontSizeAdj)/2.0)
                        heightAdj = height-fontSizeDiff
                    else:
                        fontSizeAdj = int(font["size"])
                        heightAdj = int(text.get("height"))
                        
                    style = ParagraphStyle(
                        'default',
                        fontName="Arial",
                        leading=fontSizeAdj,
                        fontSize=fontSizeAdj,
                        borderPadding = int(font["padding"]),
                        textColor=font["color"],
                        backColor=font["background"],
                        firstLineIndent=int(font["indent"]),
                    )
                    
                    self.createParagraph(replacement, int(text.get("left")), (int(text.get("top"))+heightAdj),style)
                else:
                    innerText = ElementTree.tostring(text.getchildren()[0])
                    font = self.fonts[text.get("font")]
                    if text.get("replace"):
                        replacement = dataDictionary[self.country][text.get("replace")]
                    else:
                        replacement = innerText
                        
                    if text.get("shrink"):
                        fontSize = float(font["size"])
                        height = int(text.get("height"))
                        textLen = float(len(replacement))
                        divisor = max(((textLen/25.0)+(2.0/3.0)),1)
                        fontSizeAdj = int(fontSize / divisor)
                        fontSizeDiff = int(float(fontSize-fontSizeAdj)/2.0)
                        heightAdj = height-fontSizeDiff
                    else:
                        fontSizeAdj = int(font["size"])
                        heightAdj = int(text.get("height"))
                        
                    style = ParagraphStyle(
                        'default',
                        fontName="Arial",
                        leading=fontSizeAdj,
                        fontSize=fontSizeAdj,
                        borderPadding = int(font["padding"]),
                        textColor=font["color"],
                        backColor=font["background"],
                        firstLineIndent=int(font["indent"]),
                    )
                    
                    self.createParagraph(replacement, int(text.get("left")), (int(text.get("top"))+heightAdj),style)
            for line in page.findall("line"):
                self.c.setDash(int(line.get("on")),int(line.get("off")))
                self.c.setStrokeColor(line.get("color"))
                self.c.line(int(line.get("x1")),self.height-int(line.get("y1")),int(line.get("x2")),self.height-int(line.get("y2")))
            for table in page.findall("table"):
                self.c.setDash(1,0)
                tabDat = dataDictionary[self.country][table.get("data")]
                if table.get("widths"):
                    colWidths = [float(width) for width in table.get("widths").split(",")]
                else:
                    colWidths = float(table.get("width"))/len(tabDat[0])
                if table.get("heights"):
                    rowHeights = [float(height) for height in table.get("heights").split(",")]
                else:
                    rowHeights = float(table.get("height"))/len(tabDat)
                t = Table(tabDat,colWidths,rowHeights,style=tableStyles[table.get("data")])
                t.wrapOn(self.c, self.width, self.height)
                t.drawOn(self.c, *self.coord(int(table.get("left")), int(table.get("top"))+int(table.get("height"))))

            self.c.showPage()
コード例 #22
0
    def createDocument(self):
        """"""
        for page in progressbar.progressbar(self.e.findall("page")):
            self.width, self.height = int(page.get("width")), int(
                page.get("height"))
            self.c.setPageSize((self.width, self.height))
            for image in page.findall("image"):
                src = self.template_folder + "/" + image.get("src")
                if "charts" in src:
                    chart_name = basename(src)
                    chart_path = dirname(src)
                    dest = chart_path + "/reduced_" + chart_name
                    if not isfile(dest):
                        pilImg = PILImage.open(src)
                        size = (pilImg.size[0] / 1.5, pilImg.size[1] / 1.5)
                        pilImg.thumbnail(size, PILImage.NEAREST)
                        pilImg.save(dest, optimize=True)
                else:
                    dest = src
                logo = Image(dest)
                logo.drawHeight = int(image.get("height"))
                logo.drawWidth = int(image.get("width"))
                logo.wrapOn(self.c, self.width, self.height)
                logo.drawOn(
                    self.c,
                    *self.coord(
                        int(image.get("left")),
                        int(image.get("top")) + int(image.get("height"))))
            for text in page.findall("text"):
                if len(text.getchildren()) == 0:
                    font = self.fonts[text.get("font")]
                    replacement = text.text

                    if text.get("shrink"):
                        textLen = float(len(replacement))
                        fontSizeAdj = int(font["size"])
                        heightAdj = int(
                            text.get("height")) * 2 if textLen > 30 else int(
                                text.get("height"))
                        width = int(text.get("width"))
                    else:
                        fontSizeAdj = int(font["size"])
                        heightAdj = int(text.get("height"))
                        width = self.width

                    style = ParagraphStyle(
                        'default',
                        fontName="Geomanist",
                        leading=fontSizeAdj,
                        fontSize=fontSizeAdj,
                        borderPadding=int(font["padding"]),
                        textColor=font["color"],
                        backColor=font["background"],
                        firstLineIndent=int(font["indent"]),
                    )

                    self.createParagraph(replacement, int(text.get("left")),
                                         (int(text.get("top")) + heightAdj),
                                         width, style)
                else:
                    innerText = ElementTree.tostring(text.getchildren()[0])
                    font = self.fonts[text.get("font")]
                    replacement = innerText

                    if text.get("shrink"):
                        textLen = float(len(replacement))
                        fontSizeAdj = int(font["size"])
                        heightAdj = int(
                            text.get("height")) * 2 if textLen > 30 else int(
                                text.get("height"))
                        width = int(text.get("width"))
                    else:
                        fontSizeAdj = int(font["size"])
                        heightAdj = int(text.get("height"))
                        width = self.width

                    style = ParagraphStyle(
                        'default',
                        fontName="Geomanist",
                        leading=fontSizeAdj,
                        fontSize=fontSizeAdj,
                        borderPadding=int(font["padding"]),
                        textColor=font["color"],
                        backColor=font["background"],
                        firstLineIndent=int(font["indent"]),
                    )

                    self.createParagraph(replacement, int(text.get("left")),
                                         (int(text.get("top")) + heightAdj),
                                         width, style)
            for line in page.findall("line"):
                self.c.setDash(int(line.get("on")), int(line.get("off")))
                self.c.setStrokeColor(line.get("color"))
                self.c.line(int(line.get("x1")),
                            self.height - int(line.get("y1")),
                            int(line.get("x2")),
                            self.height - int(line.get("y2")))
            for button in page.findall("button"):
                padtop = int(button.get("pt")) if button.get("pt") else 0
                padbottom = int(button.get("pb")) if button.get("pb") else 0
                padleft = int(button.get("pl")) if button.get("pl") else 0
                padright = int(button.get("pr")) if button.get("pr") else 0
                top = (self.height - int(button.get("top"))) + padtop
                bottom = (
                    (top - padtop) - int(button.get("height"))) - padbottom
                left = int(button.get("left")) - padleft
                right = (
                    (left + padleft) + int(button.get("width"))) + padright
                rect = (left, bottom, right, top)
                self.c.linkAbsolute("",
                                    button.get("href"),
                                    rect,
                                    Border='[0 0 0]')
            for bookmark in page.findall("bookmark"):
                self.c.bookmarkPage(bookmark.get("name"),
                                    fit="FitR",
                                    left=1,
                                    right=self.width,
                                    bottom=self.height - self.width,
                                    top=self.height)

            self.c.showPage()
コード例 #23
0
ファイル: create_pdf_report.py プロジェクト: seftiz/V2X-ATE
    def createDocument(self, canvas, doc):
        """
        Create the document
        """
        self.c = canvas
        normal = self.styles["Normal"]

        #current_dir = os.getcwd() # returns current working directory of a process
        #logo_dir_name = "%s\\utilities\\" % dirname
        logo_file = os.path.join(dirname, logo_name)
        #im = Image(r'C:\Local\wavesys\trunk\lab_utils\Test_Environment\Tools\Pic1.jpg', width=2.0*inch, height=0.9*inch)
        im = Image(logo_file, width=2.0 * inch, height=0.9 * inch)
        #im.hAlign = 'RIGHT'

        im.wrapOn(self.c, self.width, self.height)
        im.drawOn(self.c, *self.coord(15.7, 2.3, cm))
        #self.story.append(im)

        p = Paragraph(Title, normal)
        p.wrapOn(self.c, self.width, self.height)
        p.drawOn(self.c, *self.coord(8, 2.5, cm))
        #self.c.line(128,121,328,121)

        #Create header
        i = 40
        j = 0
        for field in Header:
            p = Paragraph(field, normal)
            p.wrapOn(self.c, self.width, self.height)
            p.drawOn(self.c, *self.coord(10, i, mm))
            p = Paragraph(str(self.details[j]), normal)
            p.wrapOn(self.c, self.width, self.height)
            p.drawOn(self.c, *self.coord(60, i, mm))
            i = i + 5  # Adding 5 mm between header lines
            j = j + 1

        font_size = 12

        # List of report subtitles sections
        SubTitles = [Sub2, Sub3]

        point = 0
        # Set table y coordinates
        if self.internal:
            shift = 11
            table2_coordinate_cm = 17
            table3_coordinate_cm = 22.6
        else:
            shift = 9
            table2_coordinate_cm = 13.5
            table3_coordinate_cm = 20.6

        for item in SubTitles:
            text = "<font size=%s><b>%s</b></font>" % (font_size, item)
            p = Paragraph(text, style=normal)
            p.wrapOn(self.c, self.width, self.height)
            p.drawOn(self.c, *self.coord(1, point + 9.5, cm))
            point = point + shift
        '''
        # General Table 1 - Not used
        #self.text_data = [["Test name", "Measured result", "Expected result", "Units", "Status"], ["TX output power", "20", "20", "dBm", "Pass"],["TX EVM", "-23", "-20", "dBm", "Pass"]]
        tableONE = Table(self.gen_data, colWidths=[4.55 * cm, 3 * cm, 3 * cm, 3* cm, 3 * cm])
        
        tableONE.setStyle(TableStyle([
                       ('INNERGRID', (0,0), (-1,-1), 0.25, colors.black),
                       ('BOX', (0,0), (-1,-1), 0.25, colors.black)
                       ]))
        
        tableONE.wrapOn(self.c, self.width, self.height)
        tableONE.drawOn(self.c, *self.coord(1.8, 13.5, cm))
        '''

        # System tests Table 2
        tableTWO = Table(self.text_data.insert(0, res_titles),
                         colWidths=[
                             4.15 * cm, 3.7 * cm, 3.7 * cm, 2.9 * cm, 1.7 * cm,
                             1.7 * cm
                         ])

        tableTWO.setStyle(
            TableStyle([('INNERGRID', (0, 0), (-1, -1), 0.25, colors.black),
                        ('BOX', (0, 0), (-1, -1), 0.25, colors.black)]))

        tableTWO.wrapOn(self.c, self.width, self.height)
        tableTWO.drawOn(self.c, *self.coord(1.7, table2_coordinate_cm, cm))

        # GPS/WiFi pairing tests Table 3
        tableTHREE = Table(
            self.connections,
            colWidths=[4.25 * cm, 3 * cm, 3 * cm, 3 * cm, 1.7 * cm, 1.7 * cm])

        tableTHREE.setStyle(
            TableStyle([('INNERGRID', (0, 0), (-1, -1), 0.25, colors.black),
                        ('BOX', (0, 0), (-1, -1), 0.25, colors.black)]))

        tableTHREE.wrapOn(self.c, self.width, self.height)
        tableTHREE.drawOn(self.c, *self.coord(1.7, table3_coordinate_cm, cm))

        # Additional measurements results for internal use
        if self.internal:
            # Add text lines - LO leakage results
            point = 0
            #text_line = "<font size=%s><b>%s</b></font>" % (font_size-2,self.additional_res)
            text_LO_0 = " * LO leakage at TX output power " + str(
                consts.common['LO_LEAKAGE_POW_LIST_DBM']) + "dBm chA"
            text_LO_1 = " * LO leakage at TX output power " + str(
                consts.common['LO_LEAKAGE_POW_LIST_DBM']) + "dBm chB"
            text_line_0 = "<font size=%s>%s:  %s</font>" % (
                font_size - 4, text_LO_0, self.additional_res_LO[0])
            text_line_1 = "<font size=%s>%s:  %s</font>" % (
                font_size - 4, text_LO_1, self.additional_res_LO[1])
            p = Paragraph(text_line_0, style=normal)
            p.wrapOn(self.c, self.width, self.height)
            p.drawOn(self.c, *self.coord(1.7, 17.8, cm))

            p = Paragraph(text_line_1, style=normal)
            p.wrapOn(self.c, self.width, self.height)
            p.drawOn(self.c, *self.coord(1.7, 18.3, cm))

            # Add text lines - DC DAC results
            text_DC = " * DC DAC regs " + str(
                consts.common['RX1_DC_IQ_REGS_HEX'] +
                consts.common['RX2_DC_IQ_REGS_HEX']) + " status"
            text_line = "<font size=%s>%s:  %s</font>" % (
                font_size - 4, text_DC, self.additional_res_DC)
            p = Paragraph(text_line, style=normal)
            p.wrapOn(self.c, self.width, self.height)
            p.drawOn(self.c, *self.coord(1.7, 18.8, cm))

            # Add text lines - Sample gain results
            text_sg = " * Sample gain results [chA,chB]"
            text_line = "<font size=%s>%s:  %s</font>" % (
                font_size - 4, text_sg, str(self.sample_gain_res))
            p = Paragraph(text_line, style=normal)
            p.wrapOn(self.c, self.width, self.height)
            p.drawOn(self.c, *self.coord(1.7, 19.3, cm))
        else:
            pass
コード例 #24
0
 def AddLogoHeader(self, canv, doc):
     width, height = doc.pagesize
     img = Image(doc.logo_path_header, width=113, height=28)
     img.wrapOn(canv, width, height)
     x, y = doc.Position
     img.drawOn(canv, x, y)
コード例 #25
0
    def createDocument(self, canvas, doc):
        """
        Create the document
        """
        self.c = canvas
        normal = self.styles["Normal"]

        # Load logo file
        logo_name = "firm_logo.jpg"
        #current_dir = os.getcwd() # returns current working directory of a process
        #logo_dir_name = "%s\\utilities\\" % dirname
        logo_file = os.path.join(dirname, logo_name)
        #im = Image(r'C:\Local\wavesys\trunk\lab_utils\Test_Environment\Tools\Pic1.jpg', width=2.0*inch, height=0.9*inch)
        im = Image(logo_file, width=2.0 * inch, height=0.9 * inch)
        #im.hAlign = 'RIGHT'

        im.wrapOn(self.c, self.width, self.height)
        im.drawOn(self.c, *self.coord(15.7, 2.3, cm))
        #self.story.append(im)

        p = Paragraph(Title, normal)
        p.wrapOn(self.c, self.width, self.height)
        p.drawOn(self.c, *self.coord(8, 2.5, cm))
        #self.c.line(128,121,328,121)

        #Create header
        i = 40
        j = 0
        for field in Header:
            p = Paragraph(field, normal)
            p.wrapOn(self.c, self.width, self.height)
            p.drawOn(self.c, *self.coord(10, i, mm))
            p = Paragraph(str(self.Details[j]), normal)
            p.wrapOn(self.c, self.width, self.height)
            p.drawOn(self.c, *self.coord(60, i, mm))
            i = i + 5
            j = j + 1

        font_size = 12

        SubTitles = [Sub2, Sub3]

        point = 0
        for item in SubTitles:
            text = "<font size=%s><b>%s</b></font>" % (font_size, item)
            p = Paragraph(text, style=normal)
            p.wrapOn(self.c, self.width, self.height)
            p.drawOn(self.c, *self.coord(1, point + 9, cm))
            point = point + 11
        '''
        # General Table 1 - Not used
        #self.text_data = [["Test name", "Measured result", "Expected result", "Units", "Status"], ["TX output power", "20", "20", "dBm", "Pass"],["TX EVM", "-23", "-20", "dBm", "Pass"]]
        tableONE = Table(self.gen_data, colWidths=[4.55 * cm, 3 * cm, 3 * cm, 3* cm, 3 * cm])
        
        tableONE.setStyle(TableStyle([
                       ('INNERGRID', (0,0), (-1,-1), 0.25, colors.black),
                       ('BOX', (0,0), (-1,-1), 0.25, colors.black)
                       ]))
        
        tableONE.wrapOn(self.c, self.width, self.height)
        tableONE.drawOn(self.c, *self.coord(1.8, 13.5, cm))
        '''

        # System tests Table 2
        tableTWO = Table(self.text_data,
                         colWidths=[
                             4.15 * cm, 3.7 * cm, 3.7 * cm, 2.9 * cm, 1.7 * cm,
                             1.7 * cm
                         ])

        tableTWO.setStyle(
            TableStyle([('INNERGRID', (0, 0), (-1, -1), 0.25, colors.black),
                        ('BOX', (0, 0), (-1, -1), 0.25, colors.black)]))

        tableTWO.wrapOn(self.c, self.width, self.height)
        tableTWO.drawOn(self.c, *self.coord(1.7, 16.9, cm))

        # GPS/WiFi pairing tests Table 3
        tableTHREE = Table(
            self.conn_data,
            colWidths=[4.25 * cm, 3 * cm, 3 * cm, 3 * cm, 1.7 * cm, 1.7 * cm])

        tableTHREE.setStyle(
            TableStyle([('INNERGRID', (0, 0), (-1, -1), 0.25, colors.black),
                        ('BOX', (0, 0), (-1, -1), 0.25, colors.black)]))

        tableTHREE.wrapOn(self.c, self.width, self.height)
        tableTHREE.drawOn(self.c, *self.coord(1.7, 22.6, cm))

        # Add text lines - LO leakage results
        point = 0
        #text_line = "<font size=%s><b>%s</b></font>" % (font_size-2,self.additional_res)
        text_LO_0 = " * LO leakage at TX output power [23,20,15,12,10,8,5]dBm chA"
        text_LO_1 = " * LO leakage at TX output power [23,20,15,12,10,8,5]dBm chB"
        text_line_0 = "<font size=%s>%s:  %s</font>" % (
            font_size - 4, text_LO_0, self.additional_res_LO[0])
        text_line_1 = "<font size=%s>%s:  %s</font>" % (
            font_size - 4, text_LO_1, self.additional_res_LO[1])
        p = Paragraph(text_line_0, style=normal)
        p.wrapOn(self.c, self.width, self.height)
        p.drawOn(self.c, *self.coord(1.7, 17.8, cm))

        p = Paragraph(text_line_1, style=normal)
        p.wrapOn(self.c, self.width, self.height)
        p.drawOn(self.c, *self.coord(1.7, 18.3, cm))

        # Add text lines - DC DAC results
        text_DC = " * DC DAC regs hex[1070,1071,1074,1076,1370,1371,1374,1376] status"
        text_line = "<font size=%s>%s:  %s</font>" % (font_size - 4, text_DC,
                                                      self.additional_res_DC)
        p = Paragraph(text_line, style=normal)
        p.wrapOn(self.c, self.width, self.height)
        p.drawOn(self.c, *self.coord(1.7, 18.8, cm))

        # Add text lines - Sample gain results
        text_sg = " * Sample gain results [chA,chB]"
        text_line = "<font size=%s>%s:  %s</font>" % (
            font_size - 4, text_sg, str(self.sample_gain_res))
        p = Paragraph(text_line, style=normal)
        p.wrapOn(self.c, self.width, self.height)
        p.drawOn(self.c, *self.coord(1.7, 19.3, cm))
コード例 #26
0
def CreatePDF(filename_, name_, surname_, year_, data_, baseFreeDays_,
              freeDaysLastYear_):
    pdfmetrics.registerFont(
        TTFont('Arial', ConfigFile.mainDirectory + 'arial.ttf'))
    pdfmetrics.registerFont(
        TTFont('ArialBold', ConfigFile.mainDirectory + "arial_bold.ttf"))

    data = [[i for i in range(35)] for j in range(12)]

    widthTab = 35 * [0.7 * cm]
    widthTab[0] = 2.0 * cm
    widthTab[32] = 1.5 * cm
    widthTab[33] = 2.0 * cm
    widthTab[34] = 1.5 * cm

    data[0][0] = 'Styczeń'
    data[1][0] = 'Luty'
    data[2][0] = 'Marzec'
    data[3][0] = 'Kwiecień'
    data[4][0] = 'Maj'
    data[5][0] = 'Czerwiec'
    data[6][0] = 'Lipiec'
    data[7][0] = 'Sierpień'
    data[8][0] = 'Wrzesień'
    data[9][0] = 'Październik'
    data[10][0] = 'Listopad'
    data[11][0] = 'Grudzień'

    overallSumUrlopy = 0
    overallSumZwolnienia = 0
    overallSumUrlopyOkolicz = 0
    overallPozostaleUrlopy = 0
    for i in range(12):
        sumUrlopy = 0
        sumZwolnienia = 0
        sumUrlopyOkolicz = 0
        for j in range(31):
            if data_[i][j] == 1:
                sumUrlopy += 1
            elif data_[i][j] == 2:
                sumZwolnienia += 1
            elif data_[i][j] == 3:
                sumUrlopyOkolicz += 1

        data[i][32] = sumUrlopy
        data[i][33] = sumZwolnienia
        data[i][34] = sumUrlopyOkolicz

        overallSumUrlopy += sumUrlopy
        overallSumZwolnienia += sumZwolnienia
        overallSumUrlopyOkolicz += sumUrlopyOkolicz

    overallPozostaleUrlopy = baseFreeDays_ + freeDaysLastYear_ - overallSumUrlopy

    t = Table(data, widthTab, 12 * [0.7 * cm])

    t.setStyle(
        TableStyle([('INNERGRID', (0, 0), (-1, -1), 0.25, colors.black),
                    ('FONT', (0, 0), (-1, -1), "Arial"),
                    ('ALIGN', (0, 0), (-1, -1), 'CENTER'),
                    ('VALIGN', (0, 0), (-1, -1), 'MIDDLE'),
                    ('BOX', (0, 0), (-1, -1), 0.25, colors.black)]))

    for i in range(12):
        for j in range(31):
            if data_[i][j] == 1:
                t.setStyle(
                    TableStyle([('BACKGROUND', (j + 1, i), (j + 1, i),
                                 colors.green)]))
            elif data_[i][j] == 2:
                t.setStyle(
                    TableStyle([('BACKGROUND', (j + 1, i), (j + 1, i),
                                 colors.red)]))
            elif data_[i][j] == 3:
                t.setStyle(
                    TableStyle([('BACKGROUND', (j + 1, i), (j + 1, i),
                                 colors.yellow)]))

    data2 = [['suma\nurlopy', 'suma\nzwolnienia', 'suma\nurlopy\nokolicz.']]

    t2 = Table(data2, [1.5 * cm, 2.0 * cm, 1.5 * cm], 1 * [1.4 * cm])

    t2.setStyle(
        TableStyle([('INNERGRID', (0, 0), (-1, -1), 0.25, colors.black),
                    ('FONT', (0, 0), (-1, -1), "Arial"),
                    ('ALIGN', (0, 0), (-1, -1), "CENTER"),
                    ('VALIGN', (0, 0), (-1, -1), 'MIDDLE'),
                    ('BOX', (0, 0), (-1, -1), 0.25, colors.black)]))

    data3 = [['', '-', 'urlopy']]

    t3 = Table(data3, [0.7 * cm, 1.0 * cm, 3.0 * cm], [0.7 * cm])
    t3.setStyle(
        TableStyle([('FONT', (0, 0), (-1, -1), "Arial"),
                    ('ALIGN', (0, 0), (1, 0), "CENTER"),
                    ('ALIGN', (2, 0), (2, 0), "LEFT"),
                    ('BACKGROUND', (0, 0), (0, 0), colors.green)]))

    data3[0][2] = 'zwolnienia'
    t4 = Table(data3, [0.7 * cm, 1.0 * cm, 3.0 * cm], [0.7 * cm])
    t4.setStyle(
        TableStyle([('FONT', (0, 0), (-1, -1), "Arial"),
                    ('ALIGN', (0, 0), (1, 0), "CENTER"),
                    ('ALIGN', (2, 0), (2, 0), "LEFT"),
                    ('BACKGROUND', (0, 0), (0, 0), colors.red)]))

    data3[0][2] = 'urlopy okolicznościowe'
    t5 = Table(data3, [0.7 * cm, 1.0 * cm, 3.0 * cm], [0.7 * cm])
    t5.setStyle(
        TableStyle([('FONT', (0, 0), (-1, -1), "Arial"),
                    ('ALIGN', (0, 0), (1, 0), "CENTER"),
                    ('ALIGN', (2, 0), (2, 0), "LEFT"),
                    ('BACKGROUND', (0, 0), (0, 0), colors.yellow)]))

    data4 = [[
        'Łącznie', overallSumUrlopy, overallSumZwolnienia,
        overallSumUrlopyOkolicz
    ]]
    t6 = Table(data4, [2.0 * cm, 1.5 * cm, 2.0 * cm, 1.5 * cm], [1.0 * cm])
    t6.setStyle(
        TableStyle([('INNERGRID', (1, 0), (-1, -1), 0.25, colors.black),
                    ('FONT', (0, 0), (-1, -1), "Arial"),
                    ('ALIGN', (0, 0), (-1, -1), "CENTER"),
                    ('VALIGN', (0, 0), (-1, -1), 'MIDDLE'),
                    ('BOX', (1, 0), (-1, -1), 0.25, colors.black)]))

    data5 = [['Pozostałych dni urlopu:', overallPozostaleUrlopy]]
    t7 = Table(data5, [5.0 * cm, 1.0 * cm], [1.4 * cm])
    t7.setStyle(
        TableStyle([('FONT', (0, 0), (-1, -1), "ArialBold"),
                    ('ALIGN', (0, 0), (-1, -1), "CENTER"),
                    ('VALIGN', (0, 0), (-1, -1), 'MIDDLE')]))

    doc = canvas.Canvas(filename_, pagesize=landscape(A4))

    t.wrapOn(doc, 0, 0)
    t.drawOn(doc, 0.5 * cm, 5.6 * cm)

    t2.wrapOn(doc, 0, 0)
    t2.drawOn(doc, 24.2 * cm, 14.0 * cm)

    t3.wrapOn(doc, 0, 0)
    t3.drawOn(doc, 13 * cm, 4 * cm)

    t4.wrapOn(doc, 0, 0)
    t4.drawOn(doc, 13 * cm, 3 * cm)

    t5.wrapOn(doc, 0, 0)
    t5.drawOn(doc, 13 * cm, 2 * cm)

    t6.wrapOn(doc, 0, 0)
    t6.drawOn(doc, 22.2 * cm, 4.6 * cm)

    t7.wrapOn(doc, 0, 0)
    t7.drawOn(doc, 22.0 * cm, 3.3 * cm)

    doc.setFont('ArialBold', 14)

    year = "ROK "
    year += year_
    textwidth = stringWidth(year, "ArialBold", 14)
    yearPos = (29.7 * cm - textwidth) / 2
    textObject = doc.beginText()
    textObject.setTextOrigin(yearPos, 15.4 * cm)
    textObject.textLine(text=year)
    doc.drawText(textObject)

    name = name_
    surname = surname_
    namePos = 0.5 * cm

    textObject = doc.beginText()
    textObject.setTextOrigin(0.5 * cm, 17.4 * cm)
    textObject.setFont("ArialBold", 14)
    textObject.textOut("Imię: ")
    textObject.setFont("Arial", 14)
    textObject.textOut(name)
    textObject.textLine("")
    textObject.getStartOfLine()
    textObject.setFont("ArialBold", 14)
    textObject.textOut("Nazwisko: ")
    textObject.setFont("Arial", 14)
    textObject.textOut(surname)
    textObject.getStartOfLine()
    doc.drawText(textObject)

    doc.setFont("ArialBold", size=16)
    title = "Wykaz urlopów i zwolnień"
    textwidth = stringWidth(title, "ArialBold", 16)
    titlePos = (29.7 * cm - textwidth) / 2
    textObject = doc.beginText()
    textObject.setTextOrigin(titlePos, 19.4 * cm)
    textObject.textLine(title)
    doc.drawText(textObject)

    im = utils.ImageReader(ConfigFile.mainDirectory + "logo2.png")
    iw, ih = im.getSize()
    aspect = ih / float(iw)

    imageWidth = 3 * cm
    imageHeight = imageWidth * aspect
    im = Image(ConfigFile.mainDirectory + "logo2.png", imageWidth, imageHeight)

    im.wrapOn(doc, 0, 0)
    im.drawOn(doc, 26.2 * cm, 16.3 * cm)

    doc.save()