示例#1
1
文件: pdf_convert.py 项目: hank/life
def pdf_convert(fname, data):
    pdf = FPDF()
    pdf.set_margins(left=10, top=15, right=10)
    pdf.add_page()
    pdf.add_font('calibri', fname=r'c:\Windows\Fonts\calibri.ttf', uni=True)
    pdf.image('gables.jpg', x=90, w=30)
    pdf.set_font("calibri", size=12)
    pdf.multi_cell(0, 5, txt=data)
    pdf.output(fname)
示例#2
0
def generate(pdfname):
    datamanager = DataManager('127.0.0.1', 27017) 

    pdf = FPDF()

    pdf.add_page()
    pdf.set_author('GRE Master')
    pdf.set_title('GRE Word')
    #pdf.set_font('Arial', 'B', 16)

    pdf.add_font('eunjin', '', 'Eunjin.ttf', uni=True)
    pdf.set_font('eunjin', '', 16)

    pdf.add_font('bangwool', '', 'Bangwool.ttf', uni=True)
    pdf.set_font('bangwool', '', 16)

    #pdf.add_font('DejaVu', '', 'DejaVuSansCondensed.ttf', uni=True)
    #pdf.set_font('DejaVu', '', 16)

    for row in datamanager.find():
        text = row['text']
        meanings = row['meaning']
        synonyms = row['synonyms']

        meaning = ','.join(meanings)
        synonym = u','.join(synonyms)

        line = '%s : %s \n synonyms : %s' % (text, meaning, synonym)

        #pdf.cell(20, 10, row['text'], 0, 0)# + '  ' + ','.join(row['meaning']))
        pdf.multi_cell(0, 8, line, 1, 'J')
    pdf.output(pdfname, 'F')
示例#3
0
def generate_salary_list(Hall):
    """
    Print list of all employees and respective salary details for specified hall
    Take dict of Worker objects as parameter
    """

    pdf = FPDF('P', 'mm', 'A4')
    pdf.add_page('P')
    pdf.set_font('Times', 'B', 14)

    pdf.multi_cell(0, 5, ('Hall Salary List: Hall %s' % Hall.hall_ID))
    pdf.ln()

    worker_list = dbr.rebuild("worker")
    title = "Role"
    wage = 0
    for key in worker_list:
        if worker_list[key].hall_ID == Hall.hall_ID:
            if isinstance(worker_list[key], mess_manager.MessManager):
                title = "Mess Manager"
                wage = worker_list[key].monthly_salary
            elif isinstance(worker_list[key], clerk.Clerk):
                title = "Clerk"
                wage = worker_list[key].monthly_salary
            elif isinstance(worker_list[key], attendant.Attendant):
                title = "Attendant"
                wage = worker_list[key].daily_wage

            pdf.multi_cell(0, 5, ('%s: %s (%s) - Rs. %s' % (worker_list[key].worker_ID,
                                  worker_list[key].name, title, wage)))
            pdf.ln()

    # Write generated output file to PDF
    pdf.output(('hall_salary_%s.pdf' % Hall.hall_ID), 'F')
示例#4
0
class Document(object):

    def __init__(self, **kwargs):
        self.pdf = FPDF(**kwargs)
        self.pdf.add_page()
        self.pdf.set_margins(20, 20, 0)
        self.pdf.ln()
        self._add_font('DejaVu', 'DejaVuSansCondensed.ttf')
        self._add_font('DejaVu-Bold', 'DejaVuSansCondensed-Bold.ttf')

    def _add_font(self, font_name, file_name):
        self.pdf.add_font(font_name, '', asset_path(file_name), uni=True)

    def _font(self, size, bold=False):
        font_name = 'DejaVu' if not bold else 'DejaVu-Bold'
        self.pdf.set_font(font_name, '', size)

    def _text_cell(self, w, h, text, size=10, bold=False, align='L', border=BORDER_DEBUG):
        self._font(size, bold=bold)
        self.pdf.cell(w, h, text, align=align, border=border)

    def _multi_cell(self, w, h, text, size=10, bold=False, align='L', border=BORDER_DEBUG):
        self._font(size, bold=bold)
        self.pdf.multi_cell(w, h, text, align=align, border=border)

    def output(self):
        return self.pdf.output(dest='S')
示例#5
0
def createPDF(values):
    pdf = FPDF()
    pdf.add_page()
    pdf.set_font("Arial", "B", 24)
    pdf.cell(0, 20, TITLE_PDF, border=0,align="C", ln=1)
    #pdf.image(LETTERHEAD_PNG,5, 5, 0, 0)     #### COMENTED OUT TO DUE NO IMAGE
    pdf.set_font("Courier", "", 10)
    i = 0
    for i in range(len(values)):
        pdf.multi_cell(0, 6, values["res"+str(i)], border=1)  ## Must be dynamic
        i += 1

    curUTC = strftime("%Y-%m-%dT%H-%M-%SZ", gmtime(time()))
    pdf.output(PDF_SAVE_TEMPLATE + "-" + curUTC + ".pdf", "F")
    def run(self):
        ran_array = np.random.randn(3, 5)
        sum_all_val = np.sum(ran_array)
        sum_column = np.sum(ran_array, axis=0)
        sum_row = np.sum(ran_array, axis=1)

        pdf = FPDF()
        pdf.add_page()
        pdf.set_font('Arial', 'B', 10)
        pdf.multi_cell(
            400, 5, 'Sum all every value:' + str(sum_all_val) + '\n' +
            'Sum of the column values:' + str(sum_column) + '\n' +
            'Sum of the row values:' + str(sum_row))
        pdf.output(self.output().path, 'F')
示例#7
0
        def pdf(list,length):
        
            desktop = os.path.join(os.path.join(os.environ['USERPROFILE']), 'Desktop')
            pdf = FPDF()

            pdf.set_margins(4,5, 2)

            pdf.add_page()

            pdf.set_font("Times",'B', size=30)

            pdf.cell(200, 10, txt="Test Paper", ln=15, align="C")

 

            pdf.ln(5)

            pdf.set_font('Times', 'B', 20)

            pdf.cell(200, 10, txt="Short Answers", ln=15, align="C")

            pdf.ln(8)

            pdf.set_font('Times', 'I', 10)

            pdf.multi_cell(200, 10, txt="This test has been generated using the Questionnaire software.No answers are provided to the questions and it is upto the discretion of the candidate to decide upon the right answers.A short answer is of 3-4 sentences,so the answers should be brief",align ='J')

            pdf.ln(10)

            pdf.set_font('Times', 'B', 15)
        
        

            for i in range(length):

                pdf.multi_cell(200, 10, txt=str(i+1) + "." + "     " + list[i])

                pdf.ln(10)

                x = pdf.get_x()

                y = pdf.get_y()

                pdf.dashed_line(x,y,x+175,y,6)

                pdf.ln(10)
                
                
            pdf.output(desktop + "/" + "Questions" + ".pdf") 
示例#8
0
def parameters_and_thresholds(params):
	
	pdf = FPDF()
	pdf.add_page()
	pdf.set_margins(20, 10, 20)
	pdf.set_font('Arial', 'B', 24)
	pdf.set_x(20)
	pdf.multi_cell(0, 30, "Parameters and Thresholds", 0, 1, 'L')
	pdf.line(20, 32, 190, 32)
	pdf.set_font('Arial', '', 16)
	for key in params:
		if key not in ['inputPLINK', 'phenoFile', 'outDir', 'projectName', 'config']:
			pdf.multi_cell(0, 8, str(key)+':     '+str(params[key]), 0, 1, 'L')

	return pdf
def createPDF(_d: list, _PdfN: str):
    pdf = FPDF()

    if not type(_d) is list:
        raise TypeError(f"Required type {list} for arg _d")
    if not type(_PdfN) is str:
        raise TypeError(f"Required type {str} for arg _PdfN")
    # Setup
    pdf.add_page()
    pdf.set_font("Courier", size=12)

    for x in _d:
        pdf.multi_cell(200, 5, txt=x, align='L')

    pdf.output(_PdfN)
示例#10
0
def createpdf(default):
    check_version()
    # Loading config
    config = configparser.ConfigParser()
    config_file = os.path.join(os.path.dirname(__file__), 'config.ini')

    rodo_txt = os.path.join(os.path.dirname(__file__), 'klauzura.txt')
    config.read(config_file)

    document_format = config['Default']['document_format']
    font_text = config['Default']['font_text']
    font_size = config['Default']['font_size']
    align_font = config['Default']['align_font']
    maring_left = config['Default']['maring_left']
    margin_right = config['Default']['margin_right']
    line_spacing = config['Default']['line_spacing']
    new_file_cv_name = config['Default']['new_file_cv_name']

    LOWER_font_text = font_text.lower()

    font_ttf = fonts.fonts_manager.get_font(LOWER_font_text)

    path = os.path.join(os.path.dirname(__file__))
    full_font = path + "/fonts/" + font_ttf

    if default is False:
        with open(rodo_txt, 'r') as rt:
            rodo = rt.read()
    else:
        rodo = default_enclosure()

    pdf = FPDF(format=document_format, orientation="P")
    pdf.l_margin = int(maring_left)
    pdf.add_page()
    pdf.add_font(font_text, '', full_font, uni=True)
    pdf.set_font(font_text, "", size=int(font_size))
    pdf.multi_cell(int(margin_right),
                   int(line_spacing),
                   txt=str(rodo),
                   align=align_font)

    pdf.output(os.path.join(os.path.dirname(__file__), "temp.pdf"))

    temp_pdf_path = (os.path.join(os.path.dirname(__file__), "temp.pdf"))

    merge_pdf(temp_pdf_path, new_file_cv_name)

    return
示例#11
0
def generateDicePDF():
    # save FPDF() class into
    # a variable pdf
    pdf = FPDF()
    pdf.add_page()
    pdf.add_font('Braille', '', 'static/Swell-Braille.ttf', uni=True)

    # set style and size of font
    # that you want in the pdf

    pdf.set_font("Arial", size=30)
    pdf.multi_cell(200,
                   5,
                   txt='Braille Labels for Dice/Spinner\n\n',
                   align='C')
    pdf.set_font("Arial", size=10)
    pdf.multi_cell(
        200,
        5,
        txt='Cut out Braille labels and paste them onto the dice/spinner.\n\n',
        align='C')

    index = 0
    theText = ['0', '0']
    f = open("static/userData/brailleForDice.txt", "r")
    # insert the texts in pdf
    theX = pdf.get_x()
    theY = pdf.get_y()
    for x in f:
        if theX >= 170:
            theX = 5
            theY += 15
            if theY >= 260:
                pdf.add_page()
                theY = 15
        if index == 0:
            pdf.set_xy(theX - 5, theY)
        if index > 0:
            pdf.set_xy(theX + 17, theY)
        if index % 6 == 0:
            if int(theText[0]) > 9:
                theY += 15
            theX = 5
            pdf.set_xy(theX, theY)
        theX = pdf.get_x()
        theY = pdf.get_y()
        theText = x.split(':')
        pdf.set_font("Arial", size=8)
        pdf.multi_cell(15, 10, txt=theText[0], align='R')
        pdf.set_font('Braille', '', size=24)
        pdf.set_xy(theX + 15, theY)
        theX = pdf.get_x()
        theY = pdf.get_y()
        pdf.multi_cell(27, 10, txt=theText[1], align='L', border=1)
        index += 1

    # save the pdf with name .pdf
    pdf.output("static/userData/theDiceSpinner.pdf")
示例#12
0
def generatePDF(userid, maxportfolioid):
    sql_statement = "SELECT symbol, purchase_price, lot_size from portfolio where userid = %s and portfolioid = %s"
    data = (userid, maxportfolioid)
    connection = DBconnection(sql_statement, data)
    Symbol = [i[0] for i in connection]
    PurchasePrice = [i[1] for i in connection]
    Lot_Size = [i[2] for i in connection]

    pdf = FPDF()

    #header of the pdf file
    header = 'Specifically curated for ' + str(userid)
    pdf.add_page()
    pdf.set_font('Arial', 'B', 16)
    w = pdf.get_string_width(header) + 6
    pdf.set_x((210 - w) / 2)
    pdf.cell(w, 9, header, 0, 0, 'C')
    pdf.line(20, 18, 210 - 20, 18)

    pdf.ln(10)
    pdf.set_font('Times', '', 12)
    pdf.multi_cell(
        0, 5,
        'Here is a list of suggested financial instruments for your peruse.')

    for i in range(len(Symbol)):
        pdf.ln()
        pdf.set_font('Arial', '', 12)
        pdf.set_fill_color(200, 220, 255)
        pdf.cell(
            0, 6, 'Financial Instrument ' + str(i + 1) + ": " +
            str(Symbol[i]) + " Unit Price " + str(PurchasePrice[i]) +
            " Lot Size " + str(Lot_Size[i]), 0, 1, 'L', 1)

        pdf.ln()
        pdf.set_font('Courier', 'B', 12)
        pdf.multi_cell(
            0, 5, 'A detailed analysis on ' + Symbol[i] + '---------------')

    #pdf.set_y(0) #on top of the page
    pdf.set_y(-30)  #30 CM from the bottom of the page
    pdf.set_font('Arial', '', 8)
    pdf.set_text_color(0)
    pdf.cell(0, 5, 'Page ' + str(pdf.page_no()), 0, 0, 'C')

    pdf.output(str(userid) + '.pdf', 'F')
    return pdf
示例#13
0
    def pdfReadAndWrite(self):
        file = open("ornek.txt", "r+")
        fileData = file.readlines()
        pdf = FPDF()
        # Add a page
        pdf.add_page()
        # set style and size of font
        # that you want in the pdf
        pdf.add_font('DejaVu', '', 'DejaVuSans.ttf', uni=True)
        pdf.set_font("DejaVu", size=11)
        # create a cell
        for x in fileData:
            if ("(RECEIVER)" in x):
                x = x.replace("(RECEIVER)", self.RECEIVER)
            if ("(SENDER)" in x):
                x = x.replace("(SENDER)", self.SENDER)
            if ("(POSITION)" in x):
                x = x.replace("(POSITION)", self.POSITION)
            if ("(SENDER_ADDRESS)" in x):
                x = x.replace("(SENDER_ADDRESS)", self.SENDER_ADDRESS)
            if ("(RECEIVER_ADDRESS)" in x):
                x = x.replace("(RECEIVER_ADDRESS)", self.RECEIVER_ADDRESS)
            if ("(DATE)" in x):
                x = x.replace("(DATE)", self.DATE)
            if ("(UNIVERSITY)" in x):
                x = x.replace("(UNIVERSITY)", self.UNIVERSITY)
            if ("(FACULTY)" in x):
                x = x.replace("(FACULTY)", self.FACULTY)
            if ("(PHONE)" in x):
                x = x.replace("(PHONE)", self.PHONE)
            if ("(TOP_SKILLS)" in x):
                top_skills = ""
                if (self.TOP_SKILLS != []):
                    top_skills = self.listToString(self.TOP_SKILLS)
                    x = x.replace(
                        "(TOP_SKILLS)", "I also have experiences in" +
                        top_skills + "as appropriate.")
                else:
                    x = x.replace("(TOP_SKILLS)", "")

            if ("(SENDER_MORE)" in x):
                x = x.replace("(SENDER_MORE)", self.SENDER_MORE)

            pdf.multi_cell(185, 5, txt=x, align='L')
            # save the pdf with name .pdf

        pdf.output(self.OUTPUT_PDF)
示例#14
0
        def helper(*args, **kwargs):
            lines = inspect.getsource(func)
            sig = signature(func)
            f = io.StringIO()
            with redirect_stdout(f):
                str(func(*args, **kwargs))

            i = 0
            for line in lines.split('\n'):
                if 'print(' in line:
                    i += 1
            i -= 1
            i = str(i)
            compl = '{print: ' + i + '}'

            pdf = FPDF()

            pdf.add_page()
            pdf.set_font("Arial", size=12)
            pdf.cell(200, 10, txt=func.__name__ + 'Object', ln=1, align="L")
            pdf.cell(200, 10, txt='Name: ' + func.__name__, ln=1, align="L")
            pdf.cell(200, 10, txt='Type: ' + str(type(func)), ln=1, align="L")
            pdf.cell(200, 10, txt='Sign: ' + str(sig), ln=1, align="L")
            pdf.cell(200,
                     10,
                     txt='Args: ' + str({
                         k: v.default
                         for k, v in sig.parameters.items()
                         if v.default is not inspect.Parameter.empty
                     }),
                     ln=1,
                     align="L")
            pdf.cell(200, 10, txt='Doc: ', ln=1, align="L")
            pdf.multi_cell(0, 5, str(inspect.getdoc(func)))
            pdf.cell(200, 10, txt='Complx: ' + compl, ln=1, align="L")
            pdf.cell(200, 10, txt='Source: ', ln=1, align="L")
            pdf.multi_cell(0, 5, lines)
            if output:
                pdf.cell(200,
                         10,
                         txt='Output: ' + f.getvalue(),
                         ln=1,
                         align="L")
            filename = func.__name__ + "_object.pdf"
            pdf.output(filename)
            filelist.append(filename)
            return func
示例#15
0
文件: app.py 项目: swasher/vdp
def markirovka():
    input_file = session['input_file']
    places = session['places']
    pile = session['pile']
    perekladka_filename = 'perekladka_' + os.path.splitext(
        input_file)[0] + '_' + str(places) + 'x' + str(pile) + '.csv'
    do_perekladka(input_file, perekladka_filename)

    pdf_name = 'mark.pdf'

    # if pdf_name.ex
    # os.remove(pdf_name)

    pdf = FPDF('P', 'mm', [100, 60])
    if os.getenv("FLASK_ENV") == 'production':
        font_path = '/app/static/DejaVuSans.ttf'
        encoding = 'utf-8'
    else:
        font_path = 'C:\\Windows\\Fonts\\DejaVuSans.ttf'
        encoding = 'windows-1251'
    pdf.add_font('DejaVuSans', '', font_path, uni=True)
    pdf.set_font('DejaVuSans', '', 12)
    pdf.set_auto_page_break(False, 0)

    with open(perekladka_filename, 'r', encoding=encoding) as f:
        reader = csv.DictReader(f)
        for row in reader:
            pdf.add_page()

            txt = '\n'.join([
                row['order'], row['privertka'], row['pachka'], row['amount'],
                row['pers']
            ])

            # pdf.cell(0, 0, row['order'], ln=2)
            # pdf.cell(0, 0, row['privertka'], ln=2)
            # pdf.cell(0, 0, row['pachka'], ln=2)
            # pdf.cell(0, 0, row['amount'], ln=2)
            # pdf.cell(0, 0, row['pers'], ln=2)

            pdf.set_xy(20, 15)
            pdf.multi_cell(0, 5, txt, 0, 'L')
            pdf.rect(0.1, 0.1, 99.8, 59.9)

    pdf.output(pdf_name, 'F')

    return send_file(pdf_name, as_attachment=True, mimetype='application/pdf')
示例#16
0
def get_centered_start_y(text_width, text):
    test_pdf = FPDF('P', METRIC, DOCUMENT_SIZE)
    test_pdf.add_font(FONT_NAME, '', FONT_LOCATION, uni=True)
    test_pdf.set_font(FONT_NAME, size=FONT_SIZE)
    test_pdf.set_auto_page_break(False)
    test_pdf.add_page()
    initial_y = test_pdf.get_y()
    test_pdf.multi_cell(
        text_width,
        TEXT_HEIGHT,
        text,
        0,
        'C',
    )
    multi_cell_height = test_pdf.get_y() - initial_y
    start_y = int(round(0.5 * (DOCUMENT_SIZE[1] - multi_cell_height)))
    return int(round(0.5 * (DOCUMENT_SIZE[1] - multi_cell_height)))
示例#17
0
文件: label.py 项目: jrile/hddinfo
 def group_label(self, group_id, name, location, notes):
     pdf = FPDF(format=(80,65), unit='mm')
     pdf.set_margins(5, 5)
     pdf.add_page()
     self.create_barcode(group_id)
     pdf.image('barcode.png', x=0, y=0, h=30)
     pdf.set_font('Arial', '', 14)
     pdf.cell(30)
     pdf.cell(40,0, location, 0, 2)
     pdf.ln(10)
     pdf.cell(30)
     pdf.cell(21, 4, str(group_id) + ": " + name, 0, 1)
     pdf.ln(10)
     pdf.set_font('Arial', '', 8)
     pdf.multi_cell(0, 5, notes, 0, 2)
     pdf.output('barcodes/group_label.pdf')
     self.print_barcode('barcodes/group_label.pdf')
示例#18
0
def make_pdf(keyphrases, directory):
    with open(directory + 'summary.txt', 'r', encoding='utf-8') as f:
        text = f.read()

    pdf = FPDF()
    pdf.add_page()
    pdf.add_font('DejaVu', '', 'DejaVuSansCondensed.ttf', uni=True)
    pdf.set_font('DejaVu', '', 12)

    pdf.cell(40, 10, 'Key Phrases', align='C', ln=2)
    for key in keyphrases:
        pdf.cell(0, 10, key, align='L', ln=2)

    pdf.add_page()
    pdf.cell(40, 10, 'Summary', align='C', ln=2)
    pdf.multi_cell(0, 10, text, align='L')
    pdf.output(directory + 'Summary.pdf', 'F')
    def run(self):
        ran_array_2 = np.random.randn(5, 5)
        df = pd.DataFrame({
            'Column1': ran_array_2[:, 0],
            'Column2': ran_array_2[:, 1],
            'Column3': ran_array_2[:, 2],
            'Column4': ran_array_2[:, 3],
            'Column5': ran_array_2[:, 4]
        })
        df.sort_values(by='Column2', inplace=True)

        pdf = FPDF()
        pdf.add_page()
        pdf.set_font('Arial', 'B', 10)
        print(df)
        pdf.multi_cell(400, 5, str(df))
        pdf.output(self.output().path, 'F')
示例#20
0
def createPDF(a, local, visitante):
    pdf = FPDF(format='A4', unit='cm')
    pdf.add_page()
    epw = pdf.w - 2 * pdf.l_margin
    #titulo
    pdf.set_font('Times', 'B', 14.0)
    pdf.cell(epw, 0.0, 'League Football Results', align='C')
    pdf.ln(1)

    pdf.set_font('Times', '', 10.0)
    pdf.multi_cell(20, 1, '%s' % (a), align='L')
    pdf.ln(1)
    pdf.image('../Outputs/mediaGoles{}{}.png'.format(local, visitante), 1, 6,
              9, 8)
    pdf.image('../Outputs/maxGoles{}{}.png'.format(local, visitante), 10, 6, 9,
              8)
    pdf.ln(1)
    pdf.output('../Outputs/PDFResutados.pdf')
示例#21
0
    def createSummary(self, summaries, properNouns, links, n_summary):
        pdf = FPDF()
        pdf.set_font(self.font, size=self.fontSize)

        pdf.add_page()
        pdf.cell(0, 10, txt="Summary", ln=2, align="C")

        for para in summaries:
            pdf.multi_cell(0, 10, txt=para, align="J", ln=1)

        pdf.add_page()
        pdf.cell(0, 10, txt="Important Keywords", ln=2, align="C")

        for i in range(len(properNouns)):
            pdf.cell(0, 10, txt=properNouns[i], ln=1, link=links[i])
            pdf.multi_cell(0, 10, txt=n_summary[i], ln=2)

        pdf.output(f"{self.ID}_Summary.pdf")
 def save_as_pdf(self):
     if os.path.exists("text.txt"):
         root = Tk()
         root.withdraw()
         files = [('PDF Files', '*.pdf')]
         file = asksaveasfile(filetypes=files, defaultextension=files)
         print(file.name)
         root.destroy()
         f = open("text.txt", "r")
         texts = f.read()
         pdf = FPDF(orientation='L')
         pdf.add_page()
         pdf.set_xy(0, 0)
         pdf.set_font('arial', 'B', 13.0)
         pdf.multi_cell(0, 6, txt=texts, border=0)
         pdf.output(file.name, 'F')
     else:
         pass
示例#23
0
    def introProtocol(self):
        pdf = FPDF()
        pdf.set_font('Arial', 'B', 20)
        pdf.add_page()

        header = "Protocol for " + self.config['name']
        pdf.cell(100, 0, header, ln=1)
        pdf.cell(100, 10, "", ln=1)
        pdf.set_font('Courier', 'B', 9)
        temp = "1. About the scenario:\n\n"
        content = "2. Tasks used in the scenario:\n\n" + self.tasksToTable(
        ) + "\n\n3.Agents used in the scenario:\n\n" + self.agentsToTable(
        ) + "\n\n4. grid world used in the scenario:\n\n"
        full = temp + self.config['about'] + "\n\n" + content
        pdf.multi_cell(w=0, h=3, txt=full)
        pdf.image("img/world.png", x=0, y=150, w=100, h=74)

        return pdf
示例#24
0
    def format_pdf(data):
        date_time = 1
        issue = 2
        discipline = 3
        document = 4
        uid = 5
        project = 6
        sentiment = 7
        status = 8

        pdf = FPDF(format='A4', unit='in')
        pdf.add_page()

        effective_page_width = pdf.w - 2 * pdf.l_margin

        for item in data:
            pdf.set_font('Times', 'B', 15.0)
            pdf.cell(effective_page_width,
                     0.0,
                     'Project: {}'.format(item[project]),
                     align='C')
            pdf.ln(0.6)
            break

        for item in data:
            pdf.set_font('Times', 'B', 10.0)
            pdf.cell(
                1.0, 0.0,
                'ID: {} - Logged in: {}'.format(item[uid], item[date_time]))
            pdf.ln(0.15)
            pdf.cell(1.0, 0.0, 'Document: {}'.format(item[document]))
            pdf.ln(0.15)
            pdf.cell(1.0, 0.0, 'Discipline: {}'.format(item[discipline]))
            pdf.ln(0.15)
            pdf.cell(1.0, 0.0, 'Status: {}'.format(item[status]))
            pdf.ln(0.15)
            pdf.cell(1.0, 0.0, 'Sentiment: {}'.format(item[sentiment]))
            pdf.ln(0.25)

            pdf.set_font('Times', '', 10.0)
            pdf.multi_cell(effective_page_width, 0.15, item[issue])
            pdf.ln(0.5)

        return pdf
示例#25
0
def TXTtoPDF(_in, _out):
    file_in = os.path.abspath(_in)
    file_out = os.path.abspath(_out)
    file = open(file_in, 'r', encoding='utf-8', errors='ignore')

    pdf = FPDF(format='A4')
    pdf.add_page()
    pdf.add_font('DejaVu', '', 'DejaVuSansCondensed.ttf', uni=True)
    for text in file:
        #text=text.encode('latin1','ignore').decode('iso-8859-1')
        text = u'' + text
        if len(text) <= 30:  #title
            pdf.set_font('DejaVu', '', size=15)
            pdf.multi_cell(w=200, h=10, txt=text, align='C')
        else:  #paragraph
            pdf.set_font('DejaVu', size=12)
            pdf.multi_cell(w=0, h=10, txt=text, align='L')

    pdf.output(file_out)
示例#26
0
def convert_to_pdf(problem):
    pdf = FPDF()
    pdf.add_page()
    pdf.set_font("Arial", size=15)
    # Replace character that aren't in latin-1 character set
    title = problem["title"].encode('latin-1', 'replace').decode('latin-1')
    statement = problem["statement"].encode('latin-1',
                                            'replace').decode('latin-1')
    test_case = problem["test_case"].encode('latin-1',
                                            'replace').decode('latin-1')
    url = problem["url"]
    # add sections to pdf
    pdf.cell(200, 10, txt=title, ln=1, align='C')
    pdf.multi_cell(200, 10, txt=statement, align='L')
    pdf.multi_cell(200, 10, txt=test_case, align='L')
    pdf.write(5, 'Problem_Link: ')
    pdf.write(5, url, url)

    pdf.output(title + ".pdf")
示例#27
0
def createPDF(moviereport):
    pdf = FPDF()
    pdf.add_page()
    pdf.set_font('Arial', 'B', 16)
    pdf.multi_cell(0, 10, 'Movie Recommendation', align='C')
    pdf.ln(10)
    pdf.set_font('Arial', '', 12)
    text = "No sé que es esto."

    pdf.multi_cell(0,
                   5,
                   text.format(moviereport.genres,
                               moviereport.original_language,
                               moviereport.original_title,
                               moviereport.release_date, moviereport.runtime,
                               moviereport.vote_average),
                   align='L')
    pdf.ln(10)
    pdf.output('pruebo.pdf', 'F')
示例#28
0
def text_to_pdf(file):
    '''
    Function to convert text to PDF.
    :param file: Text file of the audio
    :return: PDF file 
    '''
    pdf = FPDF(format='letter', unit='in')
    pdf.add_page()
    pdf.set_font("Arial", size=12)
    effective_page_width = pdf.w - 2 * pdf.l_margin
    #open text file in read mode
    f = open(file, "r")
    #write the pdf
    for x in f:
        pdf.multi_cell(effective_page_width, 0.15, x)
        pdf.ln(1)

    #save the pdf
    pdf.output("../Video to PDF(CLI)/my_pdf.pdf")
示例#29
0
def to_pdf(problem):
    pdf = FPDF()
    pdf.add_page()
    pdf.set_font("Arial", size = 15)
    #set title 
    title=problem["title"].encode('latin-1', 'replace').decode('latin-1')
    #set statement
    statement=problem["statement"].encode('latin-1', 'replace').decode('latin-1')
    #set test cases
    test_case=problem["test_case"].encode('latin-1', 'replace').decode('latin-1')
    #set url
    url=problem["url"]
    pdf.cell(200, 10, txt =title, ln = 1, align = 'C')
    pdf.multi_cell(200, 10, txt =statement, align = 'L')
    pdf.multi_cell(200, 10, txt =test_case, align = 'L')
    pdf.write(5, 'Problem_Link: ')
    pdf.write(5,url,url)
    title = title.rstrip()
    pdf.output("./LeetCode-Scrapper/"+title+".pdf")   
示例#30
0
def create_pdf(text_chuncks, filename, company_name=""):
    pdf = FPDF()
    pdf.add_page()
    pdf.set_font("Arial", size=12)
    pdf.multi_cell(0, 5, txt=company_name, align="C", border=1)
    for title, text in text_chuncks.items():
        print(text)
        pdf.multi_cell(0, 5)
        pdf.multi_cell(0, 5, txt=title, align="C")
        pdf.multi_cell(0, 5, txt=text)
        pdf.cell(0, 5, txt=("-" * 300), align="C")
    pdf.output(filename)
示例#31
0
def customize_pdf(template, date, company, name, position, cover_letter_dir):
    # customize string
    template = template.replace("[Date]", date)
    template = template.replace("[Company]", company)
    template = template.replace("[Full Name]", name)
    template = template.replace("[Position]", position)
    # write to pdf
    pdf = FPDF('P','in','Letter')
    pdf.add_page()
    pdf.set_font('Times', '', 12)
    pdf.multi_cell(0, 0.25, template)

    if cover_letter_dir != None:
        cover_letter_name = f'{cover_letter_dir}/{company}_cover_letter.pdf'
    else: cover_letter_name = f'{company}_cover_letter.pdf'

    pdf.output(cover_letter_name, 'F').encode("latin-1")

    return cover_letter_name
示例#32
0
def receipt_gen(share, key, ticket):

    ipsum = """ Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. """

    qr_gen(share, key, ticket)
    #Setup page
    receipt = FPDF('P', 'mm', (100, 350))
    receipt.add_page()
    dynamic_widith = receipt.w - 2 * receipt.l_margin

    #Header
    receipt.set_font('Arial', '', 26)
    receipt.cell(0, 11, 'Poll Receipt', ln=2, align='C')

    #Print date time
    receipt.set_font('Arial', '', 10)
    receipt.cell(0, 5, time.strftime("%d/%m/%Y"), align='C', ln=2)
    receipt.cell(0, 10, time.strftime("%H:%M:%S"), align='C', ln=2, border='B')
    #spacer
    receipt.cell(0, 5, ln=2)

    #Body
    receipt.set_font('Arial', '', 22)

    #Personal Share
    receipt.cell(0, 10, 'Share', align='C', ln=1)
    receipt.image('share.png', w=50, x=25)
    #Private key
    receipt.cell(0, 10, 'Private Key', align='C', ln=1)
    receipt.image('key.png', w=50, x=25)
    #Personal Share
    receipt.cell(0, 10, 'Ticket', align='C', ln=1)
    receipt.image('ticket.png', w=50, x=25)

    #Spacer
    receipt.cell(0, 5, ln=1, border='B')
    receipt.cell(0, 10, ln=1)

    #Instructions
    receipt.set_font('Arial', '', 12)
    receipt.multi_cell(dynamic_widith, 4, ipsum, align='L')
    #Save pdf
    receipt.output('Poll Receipt.pdf')
示例#33
0
def createPDF(dateI, dateF, cont):
    pdf = FPDF()
    pdf.add_page()
    pdf.set_font('Arial', 'B', 16)
    pdf.multi_cell(0, 10, 'Analisis de contaminacion en Madrid', align='C')
    pdf.ln(10)
    pdf.set_font('Arial', '', 12)
    text = "La siguente grafica muestra la presencia del contaminante {} en el aire de madrid entre las fechas {}-{}-{} y {}-{}-{}. También se muestr el nivel de lluvia en esas mismas fechas."

    pdf.multi_cell(0,
                   5,
                   text.format(cont, dateI.day, dateI.month, dateI.year,
                               dateF.day, dateF.month, dateF.year),
                   align='L')
    pdf.ln(10)
    pdf.image('../Output/fig.png', w=150, h=100)
    pdf.output(
        '../Output/Analisis_Contaminacion_{}-{}-{}.pdf'.format(
            dateI.day, dateI.month, dateI.year), 'F')
示例#34
0
    def _generate_pdf(self):
        """
        Generates a pdf report with results of the compute
        method as well as an image of the resultant plot.

        Creates PDF_FILE.
        """

        logger.info("Generating %s" % PDF_FILE)

        pdf = FPDF('P', 'mm', 'A4')
        pdf.set_font('Arial', 'B', 50)
        pdf.set_margins(left=20, top=20, right=-1)

        pdf.add_page()
        pdf.cell(w=100, h=100, txt=PDF_REPORT_TITLE, border=0, ln=2)

        pdf.set_font('Arial', 'B', 25)

        self._generate_images()

        for category, results_ in self.results.items():
            for result in results_:
                pdf.add_page()
                pdf.cell(w=100,
                         h=10,
                         txt=str(result['metric']),
                         border=0,
                         ln=1)
                pdf.ln()

                txt = \
                    """
                    The value of the metric is:\n
                    {}. \n
                    """.format(result['value'])
                pdf.set_font('Arial', style='', size=16)
                pdf.multi_cell(w=0, h=3, txt=txt)
                pdf.image(self.write_to + '/' + IMAGES_DIR + '/' +
                          "_".join(str(result['metric']).split()) + '.png',
                          w=200)

        pdf.output(self.write_to + '/' + PDF_FILE, 'F')
示例#35
0
def formattedpdf(input_malware):
    malware_file,ISO8601, hashvalue, arch, importeddlls, imphash, fuzzyhash,warnings, ent = malwaresignature(input_malware)
    os.chdir('/home/kali/Downloads/webserverup')
    pdf = FPDF()
    pdf.add_page()
    pdf.set_font("Arial", size=10)
    pdf.cell(200, 10, txt=os.path.basename(malware_file) , ln=1, align="C")
    pdf.cell(0,10,txt="SHA256: " + hashvalue, ln=2, align = "L")
    pdf.cell(0,10, txt="IMPHASH: " + imphash, ln=3, align="L")
    pdf.cell(0,10,txt="Fuzzy: " + fuzzyhash, ln=4, align="L")
    pdf.cell(0,10, txt="Imported dlls: " +', '.join(importeddlls), ln=5, align="L")
    if arch == 332:
        pdf.cell(0,10, txt="Architecture: " + "32-bit binary", ln=6, align="L")
    else:
        pdf.cell(0,10,txt="Architecture: " + "64-bit binary", ln=6, align="L")
    pdf.cell(0,10,txt="Timestamp: " + ISO8601 , ln=7, align="L")
    pdf.cell(0,10,txt="Entropy: " + str(ent), ln=8, align="L")
    pdf.multi_cell(0,10,txt="File warnings: " + (str(warnings).strip('[]')),align="L")
    pdf.output("Sample.pdf")
示例#36
0
文件: render.py 项目: kogan/eClaire
def generate_pdf(card):
    """
    Make a PDF from a card

    :param card: dict from fetcher.py
    :return: Binary PDF buffer
    """
    from eclaire.base import SPECIAL_LABELS

    pdf = FPDF('L', 'mm', (62, 140))
    pdf.set_margins(2.8, 2.8, 2.8)
    pdf.set_auto_page_break(False, margin=0)

    pdf.add_page()

    font = pkg_resources.resource_filename('eclaire', 'font/Clairifont.ttf')
    pdf.add_font('Clairifont', fname=font, uni=True)
    pdf.set_font('Clairifont', size=48)

    pdf.multi_cell(0, 18, txt=card.name.upper(), align='L')

    qrcode = generate_qr_code(card.url)
    qrcode_file = mktemp(suffix='.png', prefix='trello_qr_')
    qrcode.save(qrcode_file)
    pdf.image(qrcode_file, 118, 35, 20, 20)
    os.unlink(qrcode_file)

    # May we never speak of this again.
    pdf.set_fill_color(255, 255, 255)
    pdf.rect(0, 55, 140, 20, 'F')

    pdf.set_font('Clairifont', '', 16)
    pdf.set_y(-4)
    labels = ', '.join([label.name for label in card.labels
                        if label.name not in SPECIAL_LABELS])
    pdf.multi_cell(0, 0, labels, 0, 'R')

    return pdf.output(dest='S')
示例#37
0
def issue_cheque(name, amount):
    """
    Print salary and payment cheques with worker_ID
    Print hall payment cheques with hall_ID
    """

    pdf = FPDF('P', 'mm', 'A4')
    pdf.add_page('P')
    pdf.set_font('Times', 'B', 14)

    pdf.multi_cell(0, 5, 'Cheque Payment System')
    pdf.ln()
    pdf.multi_cell(0, 5, ('Pay: %s' % name))
    pdf.ln()
    pdf.multi_cell(0, 5, ('The amount of: Rs. %s' % str(amount)))
    pdf.ln()
    pdf.multi_cell(0, 5, ('Issued on: %s' % str(time.strftime("%d/%m/%Y"))))
    pdf.ln()

    # Write generated output file to PDF
    pdf.output(('cheque_%s.pdf' % name), 'F')
示例#38
0
def print_receipt(Student):
    """
    Print receipts related to specified Student
    Contain all three amounts paid - mess fees, room rent, amenities charge
    """

    pdf = FPDF('P', 'mm', 'A4')
    pdf.add_page('P')
    pdf.set_font('Times', 'B', 14)

    pdf.multi_cell(0, 5, 'Student Dues Payment Receipt')
    pdf.ln()
    pdf.multi_cell(0, 5, ('Student ID: %s' % Student.student_ID))
    pdf.ln()
    pdf.multi_cell(0, 5, ('Name: %s' % Student.name))
    pdf.ln()
    pdf.multi_cell(0, 5, ('Mess Fees: %s' % Student.mess_charge))
    pdf.ln()

    if Student.room_type == "S":
        room_rent = db.get("hall", Student.hall_ID, "single_room_rent")[0]
    elif Student.room_type == "D":
        room_rent = db.get("hall", Student.hall_ID, "double_room_rent")[0]

    pdf.multi_cell(0, 5, ('Room Rent: %s' % room_rent))
    pdf.ln()

    pdf.multi_cell(0, 5, ('Amenities Charge: %s' % str(db.get("hall", Student.hall_ID, "amenities_charge")[0])))
    pdf.ln()

    pdf.multi_cell(0, 5, ('Total Amount Paid: %s' % str(Student.total_dues)))
    pdf.ln()

    # Write generated output file to PDF
    pdf.output(('receipt_%s.pdf' % Student.hall_ID), 'F')
示例#39
0
    def ImrimirPDF(self, saleId):
	# Obtener los datos de la base de datos (datos de la venta y los elementos)
	datos = db.Salerecord(saleId)
	# guardar los datos de la venta en datos_sale
	datos_sale  = datos[0]
	#Guardar los datos de los elementos de la venta en datos_items 
	datos_items = datos[1]
	# Formatear el numero de la venta (ej: 0000000023)
	facturaNumero = str(("0"*(10-len(str(saleId))))+str(saleId))
	# Obtener los datos de la tienda/empresa desde la base de datos
	Datos = db.SelectConfigNS()
	
	logo = self.ResourcePath('logo.png')
	pdf = FPDF()
	pdf.add_page()
#	pdf.add_font('courier', '', 'cour.ttf', uni=True)
#	pdf.add_font('courier', '', 'cour.ttf', uni=True)
	pdf.set_font('courier', '', 13.0)
	pdf.set_xy(105.0, 16.0)
	pdf.cell(ln=0, h=22.0, align='L', w=75.0, txt='', border=0)
	pdf.set_line_width(0.0)
	pdf.rect(15.0, 45.0, 180.0, 90.0) # Marco Principal
	pdf.set_line_width(0.0)
	#pdf.rect(95.0, 15.0, 10.0, 10.0) # cuadrito 
    # LOGOTIPO
	pdf.image(logo, 27.0, 10.0, link='', type='', w=0, h=20)
	pdf.set_font('courier', 'B', 16.0)
	pdf.set_xy(95.0, 18.0)
	#pdf.cell(ln=0, h=2.0, align='C', w=10.0, txt='Hola 1', border=0)
    # DATOS DE LA EMPRESA
	pdf.set_font('courier', '', 8.0)
	pdf.set_xy(115.0, 25.0)
	pdf.cell(ln=0, h=4.0, align='L', w=75.0, txt="Tel:              "+str(Datos[3]), border=0)
	pdf.set_xy(115.0, 28.0)
	pdf.cell(ln=0, h=4.0, align='L', w=75.0, txt="Web:              "+str(Datos[4]), border=0)
	pdf.set_xy(115.0, 31.0)
	pdf.cell(ln=0, h=4.0, align='L', w=75.0, txt="E-mail:           "+Datos[7], border=0)
	pdf.set_xy(115.0, 34.0)
	pdf.cell(ln=0, h=4.0, align='L', w=75.0, txt="NIT:              "+str(Datos[8]), border=0)
	pdf.set_font('courier', '', 7.0)

	pdf.set_xy(115.0, 35.0)
	pdf.cell(ln=0, h=7.0, align='L', w=60.0, txt='Fecha:', border=0)
	pdf.set_xy(145.0, 35.0)
	pdf.cell(ln=0, h=7.0, align='L', w=40.0, txt=datos_sale[1], border=0)

	pdf.rect(15.0, 9.0, 180.0, 35.8) # header datos principales

	pdf.set_xy(95.0, 21.5)
	pdf.set_line_width(0.0)
	pdf.set_font('arial', 'B', 13.0)
	pdf.set_xy(15.0, 10.5)
	pdf.cell(ln=0, h=5.5, align='C', w=180.0, txt='Comprobante de venta', border=0)
#	pdf.line(100.0, 25.0, 100.0, 57.0) #linea vertical header
	pdf.set_font('arial', 'B', 14.0)
	pdf.set_xy(143.0, 15.5)
	pdf.cell(ln=0, h=9.5, align='L', w=60.0, txt=facturaNumero, border=0)
	pdf.set_xy(115.0, 17.5)
	pdf.cell(ln=0, h=5.5, align='L', w=10.0, txt='N\xba: ', border=0)
	pdf.set_font('courier', 'B', 12.0)
	pdf.set_xy(17.0, 30.5)
	pdf.cell(ln=0, h=5.0, align='L', w=98.0, txt=Datos[1], border=0)#Datos[1] nombre
	pdf.set_font('courier', '', 12.0)
	pdf.set_xy(17.0, 26.5)
	pdf.set_font('courier', '', 8.0)
	pdf.cell(ln=0, h=5.0, align='L', w=98.0, txt="", border=0) #Datos[2] slogan
	pdf.set_xy(17.0, 34.5)
	pdf.set_font('courier', '', 8.0)
	pdf.multi_cell( h=4.0, align='L', w=80.0, txt=Datos[5], border=0, )
	pdf.set_xy(115.0, 39.5)
	pdf.set_font('courier', '', 8.0)
	pdf.multi_cell( h=4.0, align='L', w=80.0, txt="Atendido por: ", border=0, )
	pdf.set_xy(145.0, 39.5)
	pdf.multi_cell( h=4.0, align='L', w=80.0, txt=db.SelectUser(datos_items[0][7])[0][1], border=0, )
	
    #Datos del cliente
	nombre = ""
	for i in datos_sale[3].split(" "): nombre = nombre+i.capitalize()+" "

	
	if(str(datos[0][4])=="1"):
		pdf.set_fill_color(244, 244,244 )
	else:
		pdf.set_fill_color(255, 255,204 )

	pdf.set_xy(15.0, 45.0)
	pdf.cell(ln=0, h=5.0, align='L', w=180.0, txt='', fill=1)

	pdf.set_line_width(0.0)
	pdf.line(15.0, 50.0, 185.0, 50.0) #Linea de cabecera
	pdf.set_font('courier', '', 10.0)

	pdf.set_xy(17.0, 44.3)
	pdf.cell(ln=0, h=6.0, align='L', w=13.0, txt='Cliente: '+nombre, border=0)

	pdf.set_xy(110.0, 44.3)
	pdf.cell(ln=0, h=6.0, align='L', w=18.0, txt='Nit: '+datos_sale[5].upper(), border=0)

	pdf.set_xy(163.0, 44.3)
	if(str(datos[0][4])=="1"):
		est = "CREDITO"
	else:
		est = "PAGADO"
	pdf.cell(ln=0, h=6.0, align='L', w=18.0, txt=est, border=0)


	pdf.set_xy(133.0, 69.0)
	#pdf.cell(ln=0, h=6.0, align='L', w=42.0, txt='Springfield', border=0)
	pdf.set_line_width(0.0)
	pdf.line(15.0, 50.0, 195.0, 50.0) #linea header de productos
	pdf.set_line_width(0.0)
	pdf.line(35.0, 50.0, 35.0, 130.0) #Separador 3
	pdf.line(50.0, 50.0, 50.0,   130.0) #Separador 2
	pdf.line(150.0, 50.0, 150.0, 130.0) #Separador 4
	pdf.line(172.0, 50.0, 172.0, 135.0) #Separador 5
	pdf.set_font('courier', '', 8.0)
	pdf.set_xy(14.0, 50.0)
	pdf.cell(ln=0, h=5.0, align='C', w=15.0, txt='Codigo', border=0)
	pdf.set_xy(35.0, 50.0)
	pdf.cell(ln=0, h=5.0, align='L', w=125.0, txt='Cantidad', border=0)
	pdf.set_xy(50.0, 50.0)
	pdf.cell(ln=0, h=5.0, align='L', w=125.0, txt='Producto', border=0)
	pdf.set_xy(150.0, 50.0)
	pdf.cell(ln=0, h=5.0, align='L', w=125.0, txt='Precio', border=0)
	pdf.set_xy(173.0, 50.0)
	pdf.cell(ln=0, h=5.0, align='L', w=20.0, txt='Total', border=0)

	pdf.set_line_width(0.0)
	pdf.line(15.0, 55.0, 195.0, 55.0)

	lineaN = 55.0
	contador = 0
	for elemento in datos_items:
		contador = contador+1
		pdf.set_xy(15.0, lineaN)
		pdf.set_font('courier', '', 8.0)
		if len(elemento[6]) > 10:
			elemento[6] = elemento[6][:10]
		pdf.cell(ln=0, h=5.0, align='L', w=15.0, txt=elemento[6].upper(), border=0) # CODIGO

		pdf.set_xy(35.0, lineaN)
		pdf.cell(ln=0, h=5.0, align='C', w=15.0, txt=str(elemento[4]), border=0)  # CANTIDAD


		pdf.set_xy(35.0+15, lineaN)
		if len(elemento[5]) > 57:
			pdf.cell( h=5.0, align='L', w=100.0, txt=elemento[5][:57], border=0) # NOMBRE
		else:
			pdf.cell(ln=0, h=5.0, align='L', w=100.0, txt=elemento[5], border=0) # NOMBRE

		pdf.set_xy(150.0, lineaN)
		pdf.cell(ln=0, h=5.0, align='L', w=125.0, txt=self.TSep(self.formatCant(elemento[3])), border=0) # PRECIO

		pdf.set_xy(173.0, lineaN)
		pdf.cell(ln=0, h=5.0, align='L', w=20.0, txt=self.TSep(self.formatCant(elemento[3]*elemento[4])), border=0) # TOTAL
		lineaN = lineaN+4

	pdf.set_line_width(0.0)
	pdf.line(15.0, 130.0, 195.0, 130.0)

	pdf.set_xy(70.0, 130.0)
	pdf.cell(ln=0, h=5.0, align='L', w=125.0, txt='Total', border=0)

	pdf.set_xy(173.0, 130.0)
	pdf.cell(ln=0, h=5.0, align='L', w=125.0, txt=self.TSep(self.formatCant(datos_sale[2])), border=0)


	
#------------ SEGUNDA PARTE ---------------#

	ln2 = 141
	pdf.set_line_width(0.0)
	pdf.rect(15.0, ln2+45.0, 180.0, 90.0) # Marco Principal

	pdf.rect(15.0, ln2+9.0, 180.0, 35.8) # header datos principales
	pdf.set_font('arial', 'B', 13.0)
	pdf.set_xy(15.0, ln2+10.5)
	pdf.cell(ln=0, h=5.5, align='C', w=180.0, txt='Comprobante de venta', border=0)
 # LOGOTIPO
	pdf.image(logo, 27.0, ln2+10.0, link='', type='', w=0, h=20)
	pdf.set_font('courier', 'B', 16.0)
	pdf.set_xy(ln2+95.0, 18.0)
	#pdf.cell(ln=0, h=2.0, align='C', w=10.0, txt='Hola 1', border=0)
    # DATOS DE LA EMPRESA
	pdf.set_font('courier', '', 8.0)
	pdf.set_xy(115.0, ln2+25.0)
	pdf.cell(ln=0, h=4.0, align='L', w=75.0, txt="Tel:              "+str(Datos[3]), border=0)
	pdf.set_xy(115.0, ln2+28.0)
	pdf.cell(ln=0, h=4.0, align='L', w=75.0, txt="Web:              "+str(Datos[4]), border=0)
	pdf.set_xy(115.0, ln2+31.0)
	pdf.cell(ln=0, h=4.0, align='L', w=75.0, txt="E-mail:           "+Datos[7], border=0)
	pdf.set_xy(115.0, ln2+34.0)
	pdf.cell(ln=0, h=4.0, align='L', w=75.0, txt="NIT:              "+str(Datos[8]), border=0)

	pdf.set_font('courier', '', 7.0)
	pdf.set_xy(115.0, ln2+35.0)
	pdf.cell(ln=0, h=7.0, align='L', w=60.0, txt='Fecha:', border=0)
	pdf.set_xy(145.0, ln2+35.0)
	pdf.cell(ln=0, h=7.0, align='L', w=40.0, txt=datos_sale[1], border=0)

	pdf.set_xy(95.0, ln2+21.5)
	pdf.set_line_width(0.0)
#	pdf.line(100.0, 25.0, 100.0, 57.0) #linea vertical header
	pdf.set_font('arial', 'B', 14.0)
	pdf.set_xy(143.0, ln2+15.5)
	pdf.cell(ln=0, h=9.5, align='L', w=60.0, txt=facturaNumero, border=0)
	pdf.set_xy(115.0, ln2+17.5)
	pdf.cell(ln=0, h=5.5, align='L', w=10.0, txt='N\xba: ', border=0)
	pdf.set_font('courier', 'B', 12.0)
	pdf.set_xy(17.0, ln2+30.5)
	pdf.cell(ln=0, h=5.0, align='L', w=98.0, txt=Datos[1], border=0)#Datos[1] nombre
	pdf.set_font('courier', '', 12.0)
	pdf.set_xy(17.0, ln2+26.5)
	pdf.set_font('courier', '', 8.0)
	pdf.cell(ln=0, h=5.0, align='L', w=98.0, txt="", border=0) #Datos[2] slogan
	pdf.set_xy(17.0, ln2+34.5)
	pdf.set_font('courier', '', 8.0)
	pdf.multi_cell( h=4.0, align='L', w=80.0, txt=Datos[5], border=0, )

	pdf.set_xy(115.0, ln2+39.5)
	pdf.set_font('courier', '', 8.0)
	pdf.multi_cell( h=4.0, align='L', w=80.0, txt="Atendido por: ", border=0, )
	pdf.set_xy(145.0, ln2+39.5)
	pdf.multi_cell( h=4.0, align='L', w=80.0, txt=db.SelectUser(datos_items[0][7])[0][1], border=0, )



    #Datos del cliente
	nombre = ""
	for i in datos_sale[3].split(" "): nombre = nombre+i.capitalize()+" "

	if(str(datos[0][4])=="1"):
		pdf.set_fill_color(244, 244,244 )
	else:
		pdf.set_fill_color(255, 255,204 )


	pdf.set_xy(15.0, ln2+45.0)
	pdf.cell(ln=0, h=5.0, align='L', w=180.0, txt='', fill=1)

	pdf.set_line_width(0.0)
	pdf.line(15.0, ln2+50.0, 195.0, ln2+50.0) #Linea de cabecera
	pdf.set_font('courier', '', 10.0)

	pdf.set_xy(17.0, ln2+44.3)
	pdf.cell(ln=0, h=6.0, align='L', w=13.0, txt='Cliente: '+nombre, border=0)

	pdf.set_xy(110.0, ln2+44.3)
	pdf.cell(ln=0, h=6.0, align='L', w=18.0, txt='Nit: '+datos_sale[5].upper(), border=0)

	pdf.set_xy(163.0, ln2+44.3)
	pdf.cell(ln=0, h=6.0, align='L', w=18.0, txt=est, border=0)


	pdf.set_xy(133.0, ln2+69.0)
	#pdf.cell(ln=0, h=6.0, align='L', w=42.0, txt='Springfield', border=0)
	pdf.set_line_width(0.0)
	pdf.line(15.0, ln2+50.0, 195.0, ln2+50.0) #linea header de productos
	pdf.set_line_width(0.0)
	pdf.line(35.0, ln2+50.0, 35.0, ln2+130.0) #Separador 3
	pdf.line(50.0, ln2+50.0, 50.0,   ln2+130.0) #Separador 2
	pdf.line(150.0, ln2+50.0, 150.0, ln2+130.0) #Separador 4
	pdf.line(172.0, ln2+50.0, 172.0, ln2+135.0) #Separador 5
	pdf.set_font('courier', '', 8.0)

	pdf.set_xy(14.0, ln2+50.0)
	pdf.cell(ln=0, h=5.0, align='C', w=15.0, txt='Codigo', border=0)

	pdf.set_xy(35.0, ln2+50.0)
	pdf.cell(ln=0, h=5.0, align='L', w=125.0, txt='Cantidad', border=0)

	pdf.set_xy(50.0, ln2+50.0)
	pdf.cell(ln=0, h=5.0, align='L', w=125.0, txt='Producto', border=0)

	pdf.set_xy(150.0, ln2+50.0)
	pdf.cell(ln=0, h=5.0, align='L', w=125.0, txt='Precio', border=0)

	pdf.set_xy(173.0, ln2+50.0)
	pdf.cell(ln=0, h=5.0, align='L', w=20.0, txt='Total', border=0)

	pdf.set_line_width(0.0)
	pdf.line(15.0, ln2+55.0, 195.0, ln2+55.0)

	lineaN = ln2+55.0
	contador = 0
	for elemento in datos_items:
		contador = contador+1
		pdf.set_xy(15.0, lineaN)
		pdf.set_font('courier', '', 8.0)
		if len(elemento[6]) > 10:
			elemento[6] = elemento[6][:10]
		pdf.cell(ln=0, h=5.0, align='L', w=15.0, txt=elemento[6].upper(), border=0) # CODIGO

		pdf.set_xy(35.0, lineaN)
		pdf.cell(ln=0, h=5.0, align='C', w=15.0, txt=str(elemento[4]), border=0)  # CANTIDAD


		pdf.set_xy(35.0+15, lineaN)
		if len(elemento[5]) > 57:
			pdf.cell( h=5.0, align='L', w=100.0, txt=elemento[5][:57], border=0) # NOMBRE
		else:
			pdf.cell(ln=0, h=5.0, align='L', w=100.0, txt=elemento[5], border=0) # NOMBRE

		pdf.set_xy(150.0, lineaN)
		pdf.cell(ln=0, h=5.0, align='L', w=125.0, txt=self.TSep(self.formatCant(elemento[3])), border=0) # PRECIO

		pdf.set_xy(173.0, lineaN)
		pdf.cell(ln=0, h=5.0, align='L', w=20.0, txt=self.TSep(self.formatCant(elemento[3]*elemento[4])), border=0) # TOTAL
		lineaN = lineaN+4

	pdf.set_line_width(0.0)
	pdf.line(15.0, ln2+130.0, 195.0, ln2+130.0)

	pdf.set_xy(70.0, ln2+130.0)
	pdf.cell(ln=0, h=5.0, align='L', w=125.0, txt='Total', border=0)

	pdf.set_xy(173.0, ln2+130.0)
	pdf.cell(ln=0, h=5.0, align='L', w=125.0, txt=self.TSep(self.formatCant(datos_sale[2])), border=0)




	pdf.output('invoice.pdf', 'F')
	if sys.platform.startswith("linux"):
		os.system("evince ./invoice.pdf")
	else:
		#os.system("invoice.pdf")
		import subprocess
		subprocess.Popen("invoice.pdf", shell=True, bufsize=255, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
示例#40
0
def novoAluguel(nomelocador, nomelocatario, fiadorI, ecI, profI, rgI, cpfI, ruaI, numI, bairroI, cidadeI, ufI, conjugueI, rgconjugueI, cpfconjugueI, fiadorII, ecII, profII, rgII, cpfII, ruaII, numII, bairroII, cidadeII, ufII, conjugueII, rgconjugueII, cpfconjugueII ,registro,prazo, inicio, fim, valor, vencimento):
    pdf=FPDF()
    pdf=FPDF('P','mm','A4')
    pdf.set_margins(10, 10, 10)
    #Adicionando página
    pdf.add_page()
    #Adicionando configurações de Fonte
    pdf.set_font('Arial','B',16)
    #Inserindo linhas cell by cell.
    contrato = 'CONTRATO DE LOCAÇÃO RESIDENCIAL'
    utxt1 = unicode (contrato, 'UTF-8')
    stxt1 = utxt1.encode ('iso-8859-1')
    pdf.cell(0,10,stxt1, 1,1 , 'C')
    pdf.ln(10)

    pdf.set_font('Arial','B',8)

    locador = 'LOCADOR(A):'+nomelocador+''
    utxt2 = unicode (locador, 'UTF-8')
    stxt2 = utxt2.encode ('iso-8859-1') 
    pdf.multi_cell(0,5,stxt2, 0,'J')
    pdf.ln(1)

    locatario = 'LOCATÁRIO(A):'+nomelocatario+''
    utxt3 = unicode (locatario, 'UTF-8')
    stxt3 = utxt3.encode ('iso-8859-1') 
    pdf.multi_cell(0,5,stxt3, 0,'J')
    pdf.ln(1)
    
    pdf.set_font('Arial','',8)
    fiadoresI = 'FIADOR I: '+fiadorI+', brasileiro(a), '+ecI+', '+profI+', portador(a) do R.G. nº '+rgI+', e inscrito(a) no CPF/MF sob nº '+cpfI+', residente e'
    fiadoresI +=' domiciliado(a) à '+ruaI+', '+numI+', '+bairroI+', '+cidadeI+', '+ufI+', e conjugue '+conjugueI+', brasileiro(a), portador(a) do R.G. nº '+rgconjugueI+' e CPF/MF nº '+cpfconjugueI+''
    utxt4 = unicode (fiadoresI, 'UTF-8')
    stxt4 = utxt4.encode ('iso-8859-1') 
    pdf.multi_cell(0,5,stxt4, 0,'J')
    pdf.ln(1)

    fiadoresII = 'FIADOR II: '+fiadorII+', brasileiro(a), '+ecII+', '+profII+', portador(a) do R.G. nº '+rgII+', e inscrito(a) no CPF/MF sob nº '+cpfII+', residente e'
    fiadoresII +=' domiciliado(a) à '+ruaII+', '+numII+', '+bairroII+', '+cidadeII+', '+ufII+', e conjugue '+conjugueII+', brasileiro(a), portador(a) do R.G. nº '+rgconjugueII+' e CPF/MF nº '+cpfconjugueII+''
    utxt5 = unicode (fiadoresII, 'UTF-8')
    stxt5 = utxt5.encode ('iso-8859-1') 
    pdf.cell(33,5,stxt5, 1,1 , 'L')
    pdf.ln(5)

    pdf.set_font('Arial','B',8)
    objeto = 'O IMÓVEL SOB Nº '+registro+' com suas benfeitorias e instalações vontade,'
    objeto +='Por este particular instrumento, as partes supraqualificadas resolvem, de comum acordo e de livre e espontânea'
    objeto +='firmar um Contrato de Locação, tendo por objeto o imóvel declinado no preâmbulo, a reger-se pelas seguintes cláusulas e condições'
    utxt6 = unicode (objeto, 'UTF-8')
    stxt6 = utxt6.encode ('iso-8859-1') 
    pdf.multi_cell(0,5,stxt6, 0,'J')
    pdf.ln(3)

    pdf.set_font('Arial','',8)
    primeira = 'CLÁUSULA PRIMEIRA:'
    utxt7 = unicode (primeira, 'UTF-8')
    stxt7 = utxt7.encode ('iso-8859-1') 
    pdf.cell(33,5,stxt7, 1,1 , 'L')
    pdf.ln(1)
    
    clausulaPrimeira ='O prazo da locação é de '+prazo+', iniciando-se '+inicio+' e findando-se em '+fim+',quando e será considerada finda, independentemente ' 
    clausulaPrimeira +='de notificação judicial ou extrajudicial, obrigando-se o(a) LOCATÁRIO(A) a restituir o imóvel, completamente livre e desocupado.'
    utxt8 = unicode (clausulaPrimeira, 'UTF-8')
    stxt8 = utxt8.encode ('iso-8859-1') 
    pdf.multi_cell(0,5,stxt8, 0,'J')
    pdf.ln(3)
    
    segunda = 'CLÁUSULA SEGUNDA:'
    utxt9 = unicode (segunda, 'UTF-8')
    stxt9 = utxt9.encode ('iso-8859-1') 
    pdf.cell(33,5,stxt9, 1,1 , 'L')
    pdf.ln(1)
    
    clausulaSegunda = 'O aluguel convencionado é de R$ '+valor+' mensais, que deverão ser pagos até o dia '+vencimento+', do mês subseqüente ao vencimento,com depósito'
    clausulaSegunda += 'em conta corrente do Locador(a), com recibo, devendo, o(a) Locatário(a), fazer prova de quitação do mesmo, se for o caso, e das parcelas de I.P.T.U,' 
    clausulaSegunda += 'sob pena de não o fazendo, não considera-se integralmente pago o aluguel, ensejando ação de despejo por falta de pagamento.'
    utxt10 = unicode (clausulaSegunda, 'UTF-8')
    stxt10 = utxt10.encode ('iso-8859-1') 
    pdf.multi_cell(0,5,stxt10, 0,'J')
    pdf.ln(3)
    
    terceira = 'CLÁUSULA TERCEIRA:'
    utxt11 = unicode (terceira, 'UTF-8')
    stxt11 = utxt11.encode ('iso-8859-1') 
    pdf.cell(33,5,stxt11, 1,1 , 'L')
    pdf.ln(1)
    
    clausulaTerceira = 'A não observância do prazo estabelecido na cláusula segunda,implicará na incidência de multa diária de 1% sobre o valor ,do aluguel'
    clausulaTerceira += 'até o limite de 20%, acrescido de juros de mora de 10% ao mês além da correção monetária monetária.'
    utxt12 = unicode (clausulaTerceira, 'UTF-8')
    stxt12 = utxt12.encode ('iso-8859-1') 
    pdf.multi_cell(0,5,stxt12, 0,'J')
    pdf.ln(3)
    
    quarta = 'CLÁUSULA QUARTA:'
    utxt13 = unicode (quarta, 'UTF-8')
    stxt13 = utxt13.encode ('iso-8859-1') 
    pdf.cell(33,5,stxt13, 1,1 , 'L')
    pdf.ln(1)
    
    clausulaQuarta = 'O imóvel objeto deste instrumento é locado exclusivamente para servir de residência ao(à) LOCATÁRIO(A) e sua família,'
    clausulaQuarta +='não podendo sua destinação ser alterada, ou acrescida de qualquer outra, sem prévia e expressa anuência do(a) LOCADOR(A).'
    clausulaQuarta +='Fica vedado, outrossim, a sublocação, cessão ou transferência deste contrato, bem como o empréstimo,'
    clausulaQuarta +='parcial ou total do imóvel locado, que dependerão também, de prévia e expressa anuência do(a) LOCADOR(A).'
    utxt14 = unicode (clausulaQuarta, 'UTF-8')
    stxt14 = utxt14.encode ('iso-8859-1') 
    pdf.multi_cell(0,5,stxt14, 0,'J')
    pdf.ln(3)

    quinta = 'CLÁUSULA QUINTA:'
    utxt15 = unicode (quinta, 'UTF-8')
    stxt15 = utxt15.encode ('iso-8859-1') 
    pdf.cell(33,5,stxt15, 1,1 , 'L')
    pdf.ln(1)
    
    clausulaQuinta = '(1) O imóvel objeto deste, foi entregue ao(a) LOCATÁRIO(A)nas condições descritas no Termo de Vistoria, obrigando-se a devolvê-lo, uma vez '
    clausulaQuinta += 'finda a locação, nas mesmas condições em que o recebeu, razão pela qual, no momento da restituição das chaves, proceder-se-á a uma nova, vistoria.'
    dois = '(2) devidamente vistoriado pelo(a) LOCATÁRIO(A), que constatou encontrar-se em perfeitas condições de habitabilidade, com pintura nova, portas '
    dois += 'com fechaduras em funcionamento e munidas das correspondentes chaves,azulejos e porcelanas da cozinha e banheiro inteiros, aberturas com  '
    dois += 'ferragens em condições e vidros inteiros, instalação elétrica e hidráulica em condições, obrigando-se a devolvê-lo, uma vez finda a locação, '
    dois += 'nas mesmas condições em que o recebeu, razão pela qual, no momento da restituição das chaves, proceder-se-á a uma nova vistoria.'
    unico = 'ÚNICO: Constatadas eventuais irregularidades e a necessidade de reparos no imóvel em decorrência de uso indevido, fará o(a) LOCADOR(A) '
    unico += 'apresentar de imediato ao(à) LOCATÁRIO(A), um orçamento prévio assinado por profissional do ramo, sendo-lhe facultado pagar o valor nele declinado,'
    cont = 'liberando-se assim de eventuais ônus em razão de demora e/ou imperfeições nos serviços.Caso contrário, poderá contratar por sua própria'
    cont += 'conta e risco mão-de-obra especializada, arcando nessa condição com os riscos de eventuais imperfeições dos serviços e pelo pagamento do '
    cont1 = 'aluguel dos dias despendidos para a sua execução, cessando a locação unicamente com o Termo de Entrega de Chaves e Vistoria,  firmado pelo(a) LOCADOR(A)ou seu(sua) administrador(a)'
    utxt161 = unicode (clausulaQuinta, 'UTF-8')
    stxt161 = utxt161.encode ('iso-8859-1') 
    pdf.multi_cell(0,5,stxt161, 0,'J')
    utxt162 = unicode (dois, 'UTF-8')
    stxt162 = utxt162.encode ('iso-8859-1') 
    pdf.multi_cell(0,5,stxt162, 0,'J')
    utxt163 = unicode (unico, 'UTF-8')
    stxt163 = utxt163.encode ('iso-8859-1') 
    pdf.multi_cell(0,5,stxt163, 0,'J') 
    utxt164 = unicode (cont, 'UTF-8')
    stxt164 = utxt164.encode ('iso-8859-1') 
    pdf.multi_cell(0,5,stxt164, 0,'J')
    utxt165 = unicode (cont1, 'UTF-8')
    stxt165 = utxt165.encode ('iso-8859-1') 
    pdf.multi_cell(0,5,stxt165, 0,'J')
    pdf.ln(3)
    
    sexta = 'CLÁUSULA SEXTA:'
    utxt17 = unicode (sexta, 'UTF-8')
    stxt17 = utxt17.encode ('iso-8859-1') 
    pdf.cell(33,5,stxt17, 1,1 , 'L')
    pdf.ln(1)
    
    clausulaSexta = 'Obriga-se o(a) LOCATÁRIO(A) a manter o imóvel sempre limpo e bem cuidado na vigência da locação,, correndo por sua conta e risco,não só os pequenos'
    clausulaSexta += 'reparos tendentes a sua conservação, mas também as multas a que der causa, por inobservância de quaisquer leis, decretos e/ou regulamentos. '
    utxt18 = unicode (clausulaSexta, 'UTF-8')
    stxt18 = utxt18.encode ('iso-8859-1') 
    pdf.multi_cell(0,5,stxt18, 0,'J')
    pdf.ln(3)
    
    setima = 'CLÁUSULA SÉTIMA:'
    utxt19 = unicode (setima, 'UTF-8')
    stxt19 = utxt19.encode ('iso-8859-1') 
    pdf.cell(33,5,stxt19, 1,1 , 'L')
    pdf.ln(1)
    
    clausulaSetima ='O(A) LOCATÁRIO(A) não poderá fazer no imóvel ou em suas dependências, quaisquer obras ou benfeitorias, sem prévia e expressa anuência do(a) LOCADOR(A),'
    clausulaSetima += 'não lhe cabendo direito de retenção, por aquelas que, mesmo necessárias ou consentidas, venham a ser realizadas.'
    paragrafo = '§ ÚNICO: Caso não convenha ao(à) LOCADOR(A) a permanência de quaisquer obras ou benfeitorias benfeitorias realizadas pelo(a) LOCATÁRIO(A),'
    paragrafo += 'mesmo necessárias ou consentidas, deverá este(a), uma vez finda a locação, removê-las às suas expensas, de modo a devolver o imóvel nas mesmas condições em que o recebeu. '
    utxt20 = unicode (clausulaSetima, 'UTF-8')
    stxt20 = utxt20.encode ('iso-8859-1') 
    pdf.multi_cell(0,5,stxt20, 0,'J')
    utxt21 = unicode (paragrafo, 'UTF-8')
    stxt21 = utxt21.encode ('iso-8859-1') 
    pdf.multi_cell(0,5,stxt21, 0,'J')
    pdf.ln(3)
    
    oitava = 'CLÁUSULA OITAVA:'
    utxt22 = unicode (oitava, 'UTF-8')
    stxt22 = utxt22.encode ('iso-8859-1') 
    pdf.cell(33,5,stxt22, 1,1 , 'L')
    pdf.ln(1)
    
    clausulaOitava = 'Obriga-se desde já o(a) LOCATÁRIO(A), a respeitar os regulamentos e as leis vigentes, bem como o direito de vizinhança, evitando a prática de quaisquer atos que possam'
    clausulaOitava +=' perturbar a tranqüilidade ou ameaçar a saúde pública.'
    utxt23 = unicode (clausulaOitava, 'UTF-8')
    stxt23 = utxt23.encode ('iso-8859-1') 
    pdf.multi_cell(0,5,stxt23, 0,'J')
    pdf.ln(3)

    nona = 'CLÁUSULA NONA:'
    utxt24 = unicode (nona, 'UTF-8')
    stxt24 = utxt24.encode ('iso-8859-1') 
    pdf.cell(33,5,stxt24, 1,1 , 'L')
    pdf.ln(1)
    
    clausulaNona = 'Qualquer tolerância ou concessão, com o fito de resolver extrajudicialmente questão legal ou contratual, não se constituirá em precedente invocável pelo(a)'
    clausulaNona += ' LOCATÁRIO(A) e nem modificará quaisquer das condições estabelecidas neste instrumento. '
    utxt25 = unicode (clausulaNona, 'UTF-8')
    stxt25 = utxt25.encode ('iso-8859-1') 
    pdf.multi_cell(0,5,stxt25, 0,'J')
    pdf.ln(3)
    
    decima = 'CLÁUSULA DÉCIMA:'
    utxt26 = unicode (decima, 'UTF-8')
    stxt26 = utxt26.encode ('iso-8859-1') 
    pdf.cell(33,5,stxt26, 1,1 , 'L')
    pdf.ln(1)
    
    clausulaDecima = 'Em caso de morte, exoneração, falência ou insolvência de quaisquer dos fiadores, obriga-se o(a) LOCATÁRIO(A)num prazo de quinze (15) dias, contados,'
    clausulaDecima += ' da verificação do fato, a apresentar substituto idôneo ao(à) LOCADOR(A), à juízo deste(a) (apenas se a garantia for através de fiança).'
    utxt27 = unicode (clausulaDecima, 'UTF-8')
    stxt27 = utxt27.encode ('iso-8859-1') 
    pdf.multi_cell(0,5,stxt27, 0,'J')
    pdf.ln(3)

    decima1 = 'CLÁUSULA DÉCIMA PRIMEIRA:'
    utxt28 = unicode (decima1, 'UTF-8')
    stxt28 = utxt28.encode ('iso-8859-1') 
    pdf.cell(45,5,stxt28, 1,1 , 'L')
    pdf.ln(1)
    
    decimaPrimeira = 'Obriga-se o(a) LOCATÁRIO(A) a efetuar a ligação de energia elétrica em seu nome, providenciando no seu desligamento, por ocasião da devolução do '
    decimaPrimeira += 'imóvel, quando então deverá apresentar as últimas contas de seu consumo. '
    utxt29 = unicode (decimaPrimeira, 'UTF-8')
    stxt29 = utxt29.encode ('iso-8859-1') 
    pdf.multi_cell(0,5,stxt29, 0,'J')
    pdf.ln(3)

    decima2 = 'CLÁUSULA DÉCIMA SEGUNDA:'
    utxt30 = unicode (decima2, 'UTF-8')
    stxt30 = utxt30.encode ('iso-8859-1') 
    pdf.cell(45,5,stxt30, 1,1 , 'L')
    pdf.ln(1)
    
    decimaSegunda = 'A falta de cumprimento de qualquer cláusula ou condição deste instrumento, implicará na sua imediata rescisão, ficando a parte infratora , sujeita'
    decimaSegunda +='ao pagamento de uma multa, equivalente a três meses de aluguel, pelo valor vigente à época da infração, além de perdas e danos.'
    utxt31 = unicode (decimaSegunda, 'UTF-8')
    stxt31 = utxt31.encode ('iso-8859-1') 
    pdf.multi_cell(0,5,stxt31, 0,'J')
    pdf.ln(3)

    decima3 = 'CLÁUSULA DÉCIMA TERCEIRA:'
    utxt32 = unicode (decima3, 'UTF-8')
    stxt32 = utxt32.encode ('iso-8859-1') 
    pdf.cell(45,5,stxt32, 1,1 , 'L')
    pdf.ln(1)
    
    decimaTerceira = 'Sempre que as partes forem obrigadas a se valer de medidas judiciais para a defesa de direitos e obrigações decorrentes deste instrumento,'
    decimaTerceira +='o valor devido a título de honorários, será de 20% (vinte por cento) sobre o valor da causa, elegendo, desde já, o foro da cidade de (cidade)'
    decimaTerceira +='para a solução das questões dele emergentes.'
    utxt33 = unicode (decimaTerceira, 'UTF-8')
    stxt33 = utxt33.encode ('iso-8859-1') 
    pdf.multi_cell(0,5,stxt33, 0,'J')
    pdf.ln(3)

    pdf.cell(0,5,'_________________________________________________  _______ , _______ , __________', 0,1 , 'C')
    pdf.ln(10)
    pdf.cell(0,5,'__________________________________________________',0,1,'C')
    pdf.cell(0,5,'Locador(a)', 0,1, 'C')
    pdf.cell(0,5,'__________________________________________________', 0,1, 'C')
    pdf.cell(0,5,'Locatario(a)',0,1, 'C')
    pdf.cell(0,5,'__________________________________________________', 0,1, 'C')
    pdf.cell(0,5,'Fiador(a)', 0,1, 'C')
    pdf.cell(0,5,'__________________________________________________', 0,1, 'C')
    pdf.cell(0,5,'Fiador(a)', 0,1 , 'C')

    pdf.add_page()
    pdf.set_font('Arial','B',14)
    importante = 'OBSERVAÇÕES IMPORTANTES '
    utxtim = unicode (importante, 'UTF-8')
    stxtim = utxtim.encode ('iso-8859-1')
    pdf.cell(0,10,stxtim,1,1, 'C')
    pdf.ln(3)
    integrantes = 'INTEGRANTES DA MINUTA DE CONTRATO DE LOCAÇÃO RESIDENCIAL '
    utxtin = unicode (integrantes, 'UTF-8')
    stxtin = utxtin.encode ('iso-8859-1')
    pdf.cell(0,10,stxtin,0,1, 'C')
    pdf.ln(10)


    pdf.set_font('Arial', '', 8)
    
    obs1 = 'OBSERVAÇÃO(01)'
    utxt34 = unicode (obs1, 'UTF-8')
    stxt34 = utxt34.encode ('iso-8859-1') 
    pdf.cell(45,5,stxt34, 1,1 , 'L')
    pdf.ln(2)
    
    observacao1 = ' Muito embora o artigo 565, do novo Código Civil não tenha mais estabelecido o prazo mínimo de 30 meses previsto na legislação locatícia,'
    observacao1 += 'ainda não existe manifestação de nossos Tribunais sobre eventual revogação dessa regra. Como pela legislação locatícia, o prazo inferior a 30 meses implicava'
    observacao1 += 'na prorrogação automática do contratoe exigia para a retomada circunstâncias especiais ou o decurso de 5 anos, o aconselhável é ainda se utilizar esse prazo (30 meses).'
    utxt35 = unicode (observacao1, 'UTF-8')
    stxt35 = utxt35.encode ('iso-8859-1') 
    pdf.multi_cell(0,5,stxt35, 0,'J')
    pdf.ln(1)
    
    obs2 = 'OBSERVAÇÃO(02)'
    utxt36 = unicode (obs2, 'UTF-8')
    stxt36 = utxt36.encode ('iso-8859-1') 
    pdf.cell(45,5,stxt36, 1,1 , 'L')
    pdf.ln(2)
    
    observacao2 = ' Normalmente, no primeiro mês de locação ocorre a cobrança do aluguel,seja os dias ocupados decorridos desde o início da locação até o final do mês.'
    observacao2 +='seja, os dias ocupados decorridos desde o início da locação até o final do mês. Somente a partir do segundo mês é que é feita a cobrança do valor locatício integral.'
    utxt37 = unicode (observacao2, 'UTF-8')
    stxt37 = utxt37.encode ('iso-8859-1') 
    pdf.multi_cell(0,5,stxt37, 0,'J')
    pdf.ln(1)
    
    obs3 = 'OBSERVAÇÃO(03)'
    utxt38 = unicode (obs3, 'UTF-8')
    stxt38 = utxt38.encode ('iso-8859-1') 
    pdf.cell(45,5,stxt38, 1,1 , 'L')
    pdf.ln(2)
    
    observacao3 = ' O artigo 406, do novo Código Civil, aparentemente teria revogado de forma expressa o artigo 10, do Decreto 22.626/33, que estabelecia '
    observacao3 += ' vedação de juros superiores a 1% ao mês. Pelo citado artigo, eles poderiam ser convencionados acima desse limite. Como a lei não estabelece o limitemáximo,'
    observacao3 += '  a idéia lógica seria a de que o limite máximo ficaria ao arbítrio das partes. Só que esse entendimento, com toda certeza, será objeto de questionamento pelos Tribunais,'
    observacao3 += ' que no devido tempo, deverão estabelecer os percentuais máximos a serem aplicados.A única certeza, é de que o limite permitido é o das taxas da Fazenda Nacional. Por isso, recomenda-se prudência e coerência. '
    utxt39 = unicode (observacao3, 'UTF-8')
    stxt39 = utxt39.encode ('iso-8859-1') 
    pdf.multi_cell(0,5,stxt39, 0,'J')
    pdf.ln(1)
    
    obs4 = 'OBSERVAÇÃO(04)'
    utxt40 = unicode (obs4, 'UTF-8')
    stxt40 = utxt40.encode ('iso-8859-1') 
    pdf.cell(45,5,stxt40, 1,1 , 'L')
    pdf.ln(2)
    
    observacao4 = 'Nunca entregar para o(a) locatário(a) o carnê do IPTU e nunca permitir que as taxas condominiais sejam remetidas diretamente ao mesmo. Sempre cuidar para'
    observacao4 +=' que esses pagamentos sejam realizados pelo(a) administrador(a), pois é dele a responsabilidade pelo inadimplemento. Todos esses valores são normalmente cobrados '
    observacao4 +='juntamente com o aluguel.Não se descuidar da contratação de seguro-incêndio, pois se algum sinistro ocorrer no imóvel e este não tiver seguro, o(a) administrador(a) será responsável pelo prejuízo.'
    utxt41 = unicode (observacao4, 'UTF-8')
    stxt41 = utxt41.encode ('iso-8859-1') 
    pdf.multi_cell(0,5,stxt41, 0,'J')
    pdf.ln(1)
    
    obs5 = 'OBSERVAÇÃO(05)'
    utxt42 = unicode (obs5, 'UTF-8')
    stxt42 = utxt42.encode ('iso-8859-1') 
    pdf.cell(45,5,stxt42, 1,1 , 'L')
    pdf.ln(2)
    
    observacao5 = 'A fiança não permite interpretação extensiva. Desta forma, por exemplo, reajustes de alugueres acima dos índices pactuados, não terão validade para'
    observacao5 +=' os fiadores, se não anuírem de forma expressa com esses reajustes. Por isso, sempre que houver qualquer alteração não prevista no contrato, tomar'
    observacao5 +=' a providência de exigir a concordância dos fiadores. Nos termos do atual inciso X, do artigo 40, da Lei do Inquilinato alterada, uma vez prorrogado '
    observacao5 +='o contrato por prazo indeterminado, o fiador poderá se desonerar do encargo, por via de notificação ao locador, permanecendo responsável'
    observacao5 +='por todos os efeitos, pelo prazo de 120 dias, cabendo ao locador notificar o locatário para apresentar novo fiador no prazo de 30 dias, sob pena de despejo.'
    utxt43 = unicode (observacao5, 'UTF-8')
    stxt43 = utxt43.encode ('iso-8859-1') 
    pdf.multi_cell(0,5,stxt43, 0,'J')
    pdf.ln(1)

    obs6 = 'OBSERVAÇÃO(06)'
    utxt44 = unicode (obs6, 'UTF-8')
    stxt44 = utxt44.encode ('iso-8859-1') 
    pdf.cell(45,5,stxt44, 1,1 , 'L')
    pdf.ln(2)
    
    observacao6 = 'Cuidar para que a ligação de energia elétrica seja sempre realizada (ou transferida) para o nome do locatário, a fim de que a eventual cobrança e a '
    observacao6 += ' inclusão em cadastro de inadimplentes não seja feita em nome do(a) locador(a).'
    utxt45 = unicode (observacao6, 'UTF-8')
    stxt45 = utxt45.encode ('iso-8859-1') 
    pdf.multi_cell(0,5,stxt45, 0,'J')
    pdf.ln(1)

    obs7 = 'OBSERVAÇÃO(07)'
    utxt46 = unicode (obs7, 'UTF-8')
    stxt46 = utxt46.encode ('iso-8859-1') 
    pdf.cell(45,5,stxt46, 1,1 , 'L')
    pdf.ln(2)
    
    observacao7 = 'A multa indenizatória sempre será proporcional ao prazo restante do contrato.'
    utxt47 = unicode (observacao7, 'UTF-8')
    stxt47 = utxt47.encode ('iso-8859-1') 
    pdf.multi_cell(0,5,stxt47, 0,'J')
    pdf.ln(1)

    obs8 = 'OBSERVAÇÃO FINAL:'
    utxt48 = unicode (obs8, 'UTF-8')
    stxt48 = utxt48.encode ('iso-8859-1') 
    pdf.cell(45,5,stxt48, 1,1 , 'L')
    pdf.ln(2)
    
    observacao8 = 'A presente minuta é apenas uma sugestão, nela informadas as cláusulas básicas de um contrato de locação residencial,'
    observacao8 +=' às quais deverão ser adicionadas outras que vierem a ser necessárias, em face das características particulares de cada negócio.'
    utxt49 = unicode (observacao8, 'UTF-8')
    stxt49 = utxt49.encode ('iso-8859-1') 
    pdf.multi_cell(0,5,stxt49, 0,'J')
    pdf.ln(1)

    pdf.ln(10)
    pdf.cell(0,5,'__________________________________________________',0,1,'C')
    pdf.cell(0,5,'Locador(a)', 0,1, 'C')
    pdf.cell(0,5,'__________________________________________________', 0,1, 'C')
    pdf.cell(0,5,'Locatario(a)',0,1, 'C')
    pdf.cell(0,5,'__________________________________________________', 0,1, 'C')
    pdf.cell(0,5,'Fiador(a)', 0,1, 'C')
    pdf.cell(0,5,'__________________________________________________', 0,1, 'C')
    pdf.cell(0,5,'Fiador(a)', 0,1 , 'C')


    pdf.output('aluguel%s.pdf'%(registro),'F')
示例#41
0
def create_pdf(**kwargs):
    """Build the PDF file from user-supplied information"""

    # Dictionary of variables collected from gui, to be passed to method_graf()
    variabledic = {"methodofservice": kwargs['servicemethod'],
        "documents": kwargs['docserved'].upper(),
        "target": kwargs['personserved'],
        "dateandtime": kwargs['dateserved'] + ", at " + kwargs['timeserved'],
        "location": kwargs['servelocation'],
        "subperson": kwargs['subname'],
        "subrelation": kwargs['subrelation'],
        "parentname": kwargs['parentname'],
        "tempguard": kwargs['guardname'],
        "committed": kwargs['committed'],
        "adminname": kwargs['adminname'],
        "agentname": kwargs['agentname'],
        }

    pdf=FPDF("P", "pt", "Letter")
    pdf.set_margins(36,36)
    pdf.alias_nb_pages()
    pdf.add_page()

    # State, County & Court
    pdf.set_font("Times", "", 12)
    pdf.multi_cell(h = 18, w = 540, align = "L", txt = (
        "IN THE "+kwargs['court'].upper()+" COURT OF\n"+
        kwargs['county'].upper()+" COUNTY, "+kwargs['state'].upper()))
    pdf.ln(30)

    # Plaintiff
    pcursor = pdf.get_y()
    pdf.multi_cell(h=18, w=400, align = "L", txt=kwargs['plaintiff'].upper())
    newpcursor = pdf.get_y()
    pdf.set_xy(400, pcursor)
    pdf.cell(w = 0, align = "R", txt = "PLAINTIFF")
    pdf.set_xy(0, newpcursor)
    pdf.ln(18)

    # Case Number
    pdf.cell(h = 18, w = 20, align = "L", txt = "V.")
    pdf.cell(h = 18, w = 500, align = "C", txt = "CASE NO. "+kwargs['caseno'].upper())
    pdf.ln(30)

    # Defendant
    pcursor = pdf.get_y()
    pdf.multi_cell(h=18, w=400, align = "L", txt=kwargs['defendant'].upper())
    newpcursor = pdf.get_y()
    pdf.set_xy(400, pcursor)
    pdf.cell(h = 18, w = 0, align = "R", txt = "DEFENDANT")
    pdf.set_xy(0, newpcursor)
    pdf.ln(18)

    # Title
    pdf.set_font("Times", "U", 12)
    pdf.cell(h = 24, w = 0, align = "C", txt = "AFFIDAVIT OF SERVICE")
    pdf.ln(36)

    # Commencement
    pdf.set_font("Times", "", 12)
    pdf.multi_cell(h = 30, w = 540, align = "L", txt = (
        "          Comes now " + kwargs['servername'] + ", who, being duly "
        "sworn, deposes and says:"))

    # Paragraph with details of service (multi-line), called from method_graf() function
    pdf.multi_cell(h = 30, w = 540, align = "L", txt = method_graf(**variabledic))

    # Comments
    if len(kwargs['comments']) > 0:
        pdf.multi_cell(h = 30, w = 540, align = "L", txt = "     " + kwargs['comments'])

    # Not a party/No interest/Further affiant sayeth not, etc.
    pdf.multi_cell(h = 30, w = 540, align = "L", txt = (
        "          I am not a party to this action, and I have no interest in it. \n"
        "          Further affiant sayeth not."))
    pdf.ln(40)

    # Signature/Notary section
    pdf.line(270,pdf.get_y(),540,pdf.get_y())
    pdf.set_x(270)
    pdf.cell(h = 24, w = 0, align = "L", txt = kwargs['servername'])
    pdf.ln(24)
    pdf.set_x(270)
    pdf.multi_cell(h = 18, w = 0, align = "L", txt = kwargs['serveraddress'])
    pdf.ln(24)
    pdf.set_x(36)
    pdf.cell(h = 18, w = 270, align = "L", txt = "Subscribed and sworn to before me this date:")
    pdf.line(270,pdf.get_y()+18,540,pdf.get_y()+18)
    pdf.ln(40)
    pdf.line(270,pdf.get_y()+18,540,pdf.get_y()+18)
    pdf.ln(24)
    pdf.set_x(270)
    pdf.cell(h = 18, w = 270, align = "L", txt = "Notary Public")
    pdf.ln(36)
    pdf.set_x(270)
    pdf.cell(h = 18, w = 270, align = "L", txt = "My commission expires:")
    pdf.line(400,pdf.get_y()+18,540,pdf.get_y()+18)

    # write PDF
    pdf.output("app/static/pdfs/your.pdf", "F")
示例#42
0
def novoVenda(
    nomeVend,
    naturalidadeVend,
    estadoCivilVend,
    profissaoVend,
    rgVend,
    cpfVend,
    ruaVend,
    numVend,
    bairroVend,
    cepVend,
    cidadeVend,
    estadoVend,
    nomeComp,
    naturalidadeComp,
    estadoCivilComp,
    profissaoComp,
    rgComp,
    cpfComp,
    ruaComp,
    numComp,
    bairroComp,
    cepComp,
    cidadeComp,
    estado,
    area,
    registro,
    valor,
):
    # Definindo o formato do PDF
    pdf = FPDF("P", "mm", "A4")
    # Definindo as margens
    pdf.set_margins(10, 10, 10)
    # Adicionando página
    pdf.add_page()
    # Adicionando configurações de Fonte

    pdf.set_font("Arial", "B", 16)
    # Inserindo linhas cell by cell.
    contrato = "CONTRATO E COMPROMISSO DE COMPRA E VENDA DE IMÓVEL"
    utxt1 = unicode(contrato, "UTF-8")
    stxt1 = utxt1.encode("iso-8859-1")
    pdf.cell(0, 10, stxt1, 1, 1, "C")
    pdf.ln(10)
    # Dados pessoais das partes interessadas

    pdf.set_font("Arial", "", 8)
    vendedor = (
        "PROMITENTE VENDEDOR: "
        + nomeVend
        + ", nascido em "
        + naturalidadeVend
        + ", "
        + estadoCivilVend
        + ","
        + profissaoVend
        + ",portador do R.G. nº "
        + rgVend
        + " ,"
    )
    vendedor += (
        "  e CPF/MF nº "
        + cpfVend
        + " residente e domiciliado à "
        + ruaVend
        + ", "
        + numVend
        + ", "
        + bairroVend
        + ", "
        + cepVend
        + ", "
        + cidadeVend
        + ", "
        + estadoVend
        + "."
    )
    utxt2 = unicode(vendedor, "UTF-8")
    stxt2 = utxt2.encode("iso-8859-1")
    pdf.multi_cell(0, 5, stxt2, 0, "J")
    pdf.ln(1)

    comprador = (
        "PROMITENTE COMPRADOR: "
        + nomeComp
        + ", "
        + naturalidadeComp
        + ", "
        + estadoCivilComp
        + ", "
        + profissaoComp
        + ", portador do R.G. nº "
        + rgComp
        + ","
    )
    comprador += (
        " e CPF/MF nº "
        + cpfComp
        + " residente e domiciliado à "
        + ruaComp
        + ", "
        + numComp
        + ", "
        + bairroComp
        + ", "
        + cepComp
        + ", "
        + cidadeComp
        + ", "
        + estado
        + "."
    )
    utxt3 = unicode(comprador, "UTF-8")
    stxt3 = utxt3.encode("iso-8859-1")
    pdf.multi_cell(0, 5, stxt3, 0, "J")
    pdf.ln(5)

    pdf.set_font("Arial", "B", 10)
    clausulas = "Têm entre os mesmos, de maneira justa e acordada, o presente contrato particular de compromisso de compra e venda de bem imóvel, ficando desde já aceito, pelas cláusulas abaixo descritas:"
    utxt4 = unicode(clausulas, "UTF-8")
    stxt4 = utxt4.encode("iso-8859-1")
    pdf.multi_cell(0, 5, stxt4, 0, "J")
    pdf.ln(3)

    pdf.set_font("Arial", "", 8)
    pdf.ln(1)
    primeira = "CLÁUSULA PRIMEIRA:"
    utxt5 = unicode(primeira, "UTF-8")
    stxt5 = utxt5.encode("iso-8859-1")
    pdf.cell(33, 5, stxt5, 1, 1, "L")
    pdf.ln(1)

    clausulaPrimeira = (
        "Que a PROMITENTE VENDEDORA é legítima possuidora do imóvel composto por área privativa de "
        + area
        + " metros quadrados, "
    )
    clausulaPrimeira += (
        "inscrito no livro de registro de imóveis sob nº " + registro + ", com as seguintes confrontações:"
    )
    utxt6 = unicode(clausulaPrimeira, "UTF-8")
    stxt6 = utxt6.encode("iso-8859-1")
    pdf.multi_cell(0, 5, stxt6, 0, "J")
    pdf.ln(2)

    segunta = "CLÁUSULA SEGUNDA:"
    utxt7 = unicode(segunta, "UTF-8")
    stxt7 = utxt7.encode("iso-8859-1")
    pdf.cell(33, 5, stxt7, 1, 1, "L")
    pdf.ln(1)

    clausulaSegunda = (
        "O valor da presente transação é feita pelo preço de R$ "
        + valor
        + ", que serão pagos de acordo com o que as partes acharem cabíveis."
    )
    utxt8 = unicode(clausulaSegunda, "UTF-8")
    stxt8 = utxt8.encode("iso-8859-1")
    pdf.multi_cell(0, 5, stxt8, 0, "J")
    pdf.ln(2)

    terceira = "CLÁUSULA TERCEIRA:"
    utxt9 = unicode(terceira, "UTF-8")
    stxt9 = utxt9.encode("iso-8859-1")
    pdf.cell(33, 5, stxt9, 1, 1, "L")
    pdf.ln(1)

    clausulaTerceira = "Que o PROMITENTE VENDEDOR se compromete a entregar o imóvel livre e desembaraçado de todos os débitos até esta data, junto ao Agente Financeiro"
    clausulaTerceira += ", ficando daí a responsabilidade do PROMITENTE COMPRADORE o pagamento mensal da prestação."
    utxt10 = unicode(clausulaTerceira, "UTF-8")
    stxt10 = utxt10.encode("iso-8859-1")
    pdf.multi_cell(0, 5, stxt10, 0, "J")
    pdf.ln(2)

    quarta = "CLÁUSULA QUARTA:"
    utxt11 = unicode(quarta, "UTF-8")
    stxt11 = utxt11.encode("iso-8859-1")
    pdf.cell(33, 5, stxt11, 1, 1, "L")
    pdf.ln(1)

    clausulaQuarta = "Fica acordado entre o PROMITENTE VENDEDOR e PROMITENTE COMPRADOR que o imóvel transacionado permanecerá em nome do PROMITENTE VENDEDOR por "
    clausulaQuarta += "prazo indeterminado, ficando o PROMITENTE VENDEDOR obrigado a apresentar os documentos necessários para transrência a partir do momento em que "
    clausulaQuarta += "o mesmo for notificado pelo PROMITENTE COMPRADOR a qualquer época. "
    utxt12 = unicode(clausulaQuarta, "UTF-8")
    stxt12 = utxt12.encode("iso-8859-1")
    pdf.multi_cell(0, 5, stxt12, 0, "J")
    pdf.ln(2)

    quinta = "CLÁUSULA QUINTA:"
    utxt13 = unicode(quinta, "UTF-8")
    stxt13 = utxt13.encode("iso-8859-1")
    pdf.cell(33, 5, stxt13, 1, 1, "L")
    pdf.ln(1)

    clausulaQuinta = "Todos os compromissos assumidos neste contrato são de caráter irrevogável e irrefratével, obrigado as partes, seus herdeiros e sucessores a qualquer"
    clausulaQuinta += "título fazer sempre boa e valiosa a presente cessão, ficando sujeito às penalidades da lei."
    utxt14 = unicode(clausulaQuinta, "UTF-8")
    stxt14 = utxt14.encode("iso-8859-1")
    pdf.multi_cell(0, 5, stxt14, 0, "J")
    pdf.ln(2)

    sexta = "CLÁUSULA SEXTA:"
    utxt15 = unicode(sexta, "UTF-8")
    stxt15 = utxt15.encode("iso-8859-1")
    pdf.cell(33, 5, stxt15, 1, 1, "L")
    pdf.ln(1)

    clausulaSexta = "Fica ainda acordando, que caso haja necessidade de se beneficiar do seguro referente ao imóvel,os beneficiados será o PROMITENTE COMPRADOR,ou filhos."
    utxt16 = unicode(clausulaSexta, "UTF-8")
    stxt16 = utxt16.encode("iso-8859-1")
    pdf.multi_cell(0, 5, stxt16, 0, "J")
    pdf.ln(2)

    setima = "CLÁUSULA SÉTIMA:"
    utxt17 = unicode(setima, "UTF-8")
    stxt17 = utxt17.encode("iso-8859-1")
    pdf.cell(33, 5, stxt17, 1, 1, "L")
    pdf.ln(1)

    clausulaSetima = "Em caso de falecimento do PROMITENTE VENDEDOR ,fica acordando entre as partes que todo e qualquer benefício oriundo deste fato,transfere-se"
    clausulaSetima += "para o PROMITENTE COMPRADOR."
    utxt18 = unicode(clausulaSetima, "UTF-8")
    stxt18 = utxt18.encode("iso-8859-1")
    pdf.multi_cell(0, 5, stxt18, 0, "J")
    pdf.ln(2)

    oitava = "CLÁUSULA OITAVA:"
    utxt19 = unicode(oitava, "UTF-8")
    stxt19 = utxt19.encode("iso-8859-1")
    pdf.cell(33, 5, stxt19, 1, 1, "L")
    pdf.ln(1)

    clausulaOitava = "Caso haja manifestação pública por parte do Agente Financeiro, quando à transferência do imóvel citado neste instrumento particular de compra"
    clausulaOitava += "venda, sem que haja o aumento das prestações fica acordo entre as partes a sua transferência."
    utxt20 = unicode(clausulaOitava, "UTF-8")
    stxt20 = utxt20.encode("iso-8859-1")
    pdf.multi_cell(0, 5, stxt20, 0, "J")
    pdf.ln(2)

    nona = "CLÁUSULA NONA:"
    utxt21 = unicode(nona, "UTF-8")
    stxt21 = utxt21.encode("iso-8859-1")
    pdf.cell(33, 5, stxt21, 1, 1, "L")
    pdf.ln(1)

    clausulaNona = "O foro deste contrato é da Comarca de, renunciando as partes quaisquer outro por mais privilegiado que seja.E por estarem assim  juntos e"
    clausulaNona += (
        "contra  assinam o presente em 03 (Três) vias de igual teor e forma, na presença das testemunhas abaixo."
    )
    utxt22 = unicode(clausulaNona, "UTF-8")
    stxt22 = utxt22.encode("iso-8859-1")
    pdf.multi_cell(0, 5, stxt22, 0, "J")
    pdf.ln(3)

    pdf.cell(0, 10, "____________________________________________   _____ , _____ , _________", 0, 1, "C")
    pdf.ln(10)

    pdf.cell(0, 5, "PROMITENTE COMPRADOR:", 0, 1, "C")
    pdf.cell(0, 5, "__________________________________________________", 0, 1, "C")
    pdf.cell(0, 5, "PROMITENTE VENDEDOR:", 0, 1, "C")
    pdf.cell(0, 5, "__________________________________________________", 0, 1, "C")
    pdf.cell(0, 5, "TESTEMUNHA:", 0, 1, "C")
    pdf.cell(0, 5, "__________________________________________________", 0, 1, "C")
    pdf.cell(0, 5, "R.G.:", 0, 1, "C")
    pdf.cell(0, 5, "__________________________________________________", 0, 1, "C")
    pdf.cell(0, 5, "TESTEMUNHA:", 0, 1, "C")
    pdf.cell(0, 5, "__________________________________________________", 0, 1, "C")
    pdf.cell(0, 5, "R.G.:", 0, 1, "C")
    pdf.cell(0, 5, "__________________________________________________", 0, 1, "C")

    pdf.output("numero%s.pdf" % (registro), "F")
示例#43
0
    def ImrimirPDF(self, saleId):
	# Obtener los datos de la base de datos (datos de la venta y los elementos)
	datos = db.Salerecord(saleId)
	# guardar los datos de la venta en datos_sale
	datos_sale  = datos[0]
	#Guardar los datos de los elementos de la venta en datos_items 
	datos_items = datos[1]
	# Formatear el numero de la venta (ej: 0000000023)
	facturaNumero = str(("0"*(10-len(str(saleId))))+str(saleId))
	# Obtener los datos de la tienda/empresa desde la base de datos
	Datos = db.SelectConfigNS()
	import sys
	if hasattr(sys, 'frozen'):
		logo = os.path.join('resources', 'logo.png')
	else:
		logo = os.path.join(os.path.split(__file__)[0], 'resources', 'logo.png')
	if hasattr(sys, 'frozen'):
		fuente = os.path.join('resources', 'DejaVuSans.ttf')
	else:
		fuente = os.path.join(os.path.split(__file__)[0], 'resources', 'DejaVuSans.ttf')
	pdf = FPDF()
	pdf.add_page()
	pdf.add_font('DejaVu', '', fuente, uni=True)
	pdf.add_font('DejaVu', 'B', fuente, uni=True)
	pdf.add_font('arial', '', fuente, uni=True)
	pdf.set_font('DejaVu', '', 14)
	pdf.set_font('DejaVu', '', 13.0)
	pdf.set_xy(105.0, 16.0)
	pdf.cell(ln=0, h=22.0, align='L', w=75.0, txt='', border=0)
	pdf.set_line_width(0.0)
	pdf.rect(15.0, 15.0, 170.0, 245.0)
	pdf.set_line_width(0.0)
	pdf.rect(95.0, 15.0, 10.0, 10.0)
	pdf.image(logo, 20.0, 17.0, link='', type='', w=13.0, h=13.0)
	pdf.set_font('DejaVu', 'B', 16.0)
	pdf.set_xy(95.0, 18.0)
	#pdf.cell(ln=0, h=2.0, align='C', w=10.0, txt='Hola 1', border=0)
	pdf.set_font('DejaVu', '', 8.0)
	pdf.set_xy(115.0, 40.0)
	pdf.cell(ln=0, h=4.0, align='L', w=75.0, txt="Tel:                "+str(Datos[3]), border=0)
	pdf.set_xy(115.0, 43.0)
	pdf.cell(ln=0, h=4.0, align='L', w=75.0, txt="Web:               "+str(Datos[4]), border=0)
	pdf.set_xy(115.0, 46.0)
	pdf.cell(ln=0, h=4.0, align='L', w=75.0, txt="E-mail:            "+Datos[7], border=0)
	pdf.set_xy(115.0, 49.0)
	pdf.cell(ln=0, h=4.0, align='L', w=75.0, txt="NIT:                 "+str(Datos[8]), border=0)
	pdf.set_font('DejaVu', 'B', 7.0)
	pdf.set_xy(95.0, 21.5)
	#pdf.cell(ln=0, h=4.5, align='C', w=10.0, txt='Hola 3', border=0)
	pdf.set_line_width(0.0)
	pdf.line(100.0, 25.0, 100.0, 57.0)
	pdf.set_font('arial', 'B', 14.0)
	pdf.set_xy(137.0, 25.5)
	pdf.cell(ln=0, h=9.5, align='L', w=60.0, txt=facturaNumero, border=0)
	pdf.set_xy(110.0, 20.5)
	pdf.cell(ln=0, h=5.5, align='L', w=10.0, txt='Factura N\xba: ', border=0)
	pdf.set_font('DejaVu', 'B', 12.0)
	pdf.set_xy(17.0, 32.5)
	pdf.cell(ln=0, h=5.0, align='L', w=98.0, txt=Datos[1], border=0)
	pdf.set_font('DejaVu', '', 12.0)
	pdf.set_xy(17.0, 36.5)
	pdf.set_font('DejaVu', '', 8.0)
	pdf.cell(ln=0, h=5.0, align='L', w=98.0, txt=Datos[2], border=0)
	pdf.set_xy(17.0, 43.5)
	pdf.set_font('DejaVu', '', 8.0)
	pdf.multi_cell( h=4.0, align='L', w=80.0, txt=Datos[5], border=0, )
	
	
	pdf.set_xy(115.0, 35.0)
	pdf.cell(ln=0, h=7.0, align='L', w=60.0, txt='Fecha:', border=0)
	pdf.set_xy(135.0, 35.0)
	pdf.cell(ln=0, h=7.0, align='L', w=40.0, txt=datos_sale[1], border=0)
	pdf.set_line_width(0.0)
	pdf.line(15.0, 57.0, 185.0, 57.0)
	pdf.set_font('times', '', 10.0)
	pdf.set_xy(17.0, 59.0)
	pdf.cell(ln=0, h=6.0, align='L', w=13.0, txt='Cliente:', border=0)
	pdf.set_xy(35.0, 59.0)
	pdf.cell(ln=0, h=6.0, align='L', w=140.0, txt=datos_sale[3].capitalize(), border=0)
	pdf.set_xy(17.0, 64.0)
	pdf.cell(ln=0, h=6.0, align='L', w=18.0, txt='Nit:', border=0)
	pdf.set_xy(35.0, 64.0)
	pdf.cell(ln=0, h=6.0, align='L', w=125.0, txt=datos_sale[5].upper(), border=0)
	pdf.set_xy(17.0, 69.0)
	pdf.cell(ln=0, h=6.0, align='L', w=18.0, txt='Total:', border=0)
	pdf.set_xy(35.0, 69.0)
	pdf.cell(ln=0, h=6.0, align='L', w=80.0, txt=formatCant(datos_sale[2]), border=0)
	pdf.set_xy(115.0, 69.0)
	#pdf.cell(ln=0, h=6.0, align='L', w=18.0, txt='City:', border=0)
	pdf.set_xy(133.0, 69.0)
	#pdf.cell(ln=0, h=6.0, align='L', w=42.0, txt='Springfield', border=0)
	pdf.set_line_width(0.0)
	pdf.line(15.0, 80.0, 185.0, 80.0)
	pdf.set_line_width(0.0)
	pdf.line(30.0, 80.0, 30.0, 230.0)
	pdf.line(130.0, 80.0, 130.0, 230.0)
	pdf.line(150.0, 80.0, 150.0, 230.0)
	pdf.line(165.0, 80.0, 165.0, 230.0)
	
	
	pdf.set_xy(20.0, 81.0)
	pdf.cell(ln=0, h=5.0, align='L', w=125.0, txt='No.', border=0)
	pdf.set_xy(30.0, 81.0)
	pdf.cell(ln=0, h=5.0, align='L', w=125.0, txt='Producto', border=0)
	pdf.set_xy(135.0, 81.0)
	pdf.cell(ln=0, h=5.0, align='L', w=125.0, txt='Precio', border=0)
	pdf.set_xy(150.0, 81.0)
	pdf.cell(ln=0, h=5.0, align='L', w=125.0, txt='Cantidad', border=0)
	pdf.set_xy(165.0, 81.0)
	pdf.cell(ln=0, h=5.0, align='L', w=20.0, txt='Total', border=0)
	
	lineaN = 89.0
	contador = 0
	for elemento in datos_items:
		contador = contador+1
		pdf.set_xy(20.0, lineaN)
		pdf.cell(ln=0, h=5.0, align='L', w=125.0, txt=str(contador), border=0)
		pdf.set_xy(30.0, lineaN)
		if len(elemento[5]) > 62:
			pdf.multi_cell( h=5.0, align='L', w=100.0, txt=elemento[5], border=0)
		else:
			pdf.cell(ln=0, h=5.0, align='L', w=100.0, txt=elemento[5], border=0)
		pdf.set_xy(130.0, lineaN)
		pdf.cell(ln=0, h=5.0, align='L', w=125.0, txt=str(formatCant(elemento[3]/elemento[4])), border=0)
		pdf.set_xy(154.0, lineaN)
		pdf.cell(ln=0, h=5.0, align='L', w=125.0, txt=str(elemento[4]), border=0)
		pdf.set_xy(165.0, lineaN)
		pdf.cell(ln=0, h=5.0, align='L', w=20.0, txt=str(formatCant(elemento[3])), border=0)
		if len(elemento[5]) > 62:
			lineaN = lineaN+10
		else:
			lineaN = lineaN+5
	
	
	
	
	pdf.set_line_width(0.0)
	pdf.line(15.0, 87.0, 185.0, 87.0)
	pdf.set_line_width(0.0)
	pdf.line(15.0, 230.0, 185.0, 230.0)
	pdf.set_xy(20.0, 233.0)
	#pdf.cell(ln=0, h=5.0, align='L', w=95.0, txt='CAE N\xba', border=0)
	pdf.set_xy(45.0, 233.0)
	#pdf.cell(ln=0, h=5.0, align='L', w=30.0, txt='01234567890', border=0)
	pdf.set_font('DejaVu', '', 12.0)
	pdf.set_xy(105.0, 234.0)
	pdf.cell(ln=0, h=9.0, align='R', w=45.0, txt='Subtotal:', border=0)
	pdf.set_font('DejaVu', 'B', 12.0)
	pdf.set_xy(145.0, 234.0)
	pdf.cell(ln=0, h=9.0, align='R', w=33.0, txt=str(formatCant((datos_sale[2]-datos_sale[6]))), border=0)
	pdf.set_font('DejaVu', '', 10.0)
	pdf.set_xy(20.0, 238.0)
	#pdf.cell(ln=0, h=5.0, align='L', w=95.0, txt='Fecha Vto. CAE:', border=0)
	pdf.set_xy(55.0, 238.0)
	#pdf.cell(ln=0, h=5.0, align='L', w=30.0, txt='19/02/2009', border=0)
	pdf.set_font('DejaVu', '', 12.0)
	pdf.set_xy(125.0, 241.0)
	pdf.cell(ln=0, h=9.0, align='R', w=25.0, txt='IVA:', border=0)
	pdf.set_font('DejaVu', 'B', 12.0)
	pdf.set_xy(145.0, 241.0)
	pdf.cell(ln=0, h=9.0, align='R', w=33.0, txt=str(formatCant(datos_sale[6])), border=0)
	#pdf.interleaved2of5('012345678905', 20.0, 243.5, w=0.75)
	pdf.set_font('DejaVu', 'B', 12.0)
	pdf.set_xy(105.0, 251.0)
	pdf.cell(ln=0, h=9.0, align='R', w=73.0, txt=str(formatCant(datos_sale[2])), border=0)
	pdf.set_font('DejaVu', '', 12.0)
	pdf.set_xy(125.0, 251.0)
	pdf.cell(ln=0, h=9.0, align='R', w=25.0, txt='Total:', border=0)
	pdf.set_line_width(0.0)
	pdf.rect(155.0, 252.0, 25.0, 7.0)
	pdf.set_font('DejaVu', '', 10.0)
	pdf.set_xy(20.0, 253.0)
	#pdf.cell(ln=0, h=7.0, align='L', w=120.0, txt='012345678905', border=0)
	pdf.output('./invoice.pdf', 'F')
	if sys.platform.startswith("linux"):
		os.system("evince ./invoice.pdf")
	else:
		os.system("./invoice.pdf")
	def formatCant( cant):
		import config
		config = config.Configuration()
		c_symbol = config.cCurrency()[0]
		c_dec = config.cCurrency()[1]
		thous_sep = config.ThousandsSep()
		try:
			ins = '%s %.'+str(c_dec)+'f'
			cant = ins % (c_symbol, cant)
		except:
			cant = str(c_dec),cant
		return str(cant)
示例#44
0
def main():
    form = cgi.FieldStorage()
    strLayer = form.getfirst("strLayer")
    strYear = str(form.getfirst("strYear"))
    strMonth = str(form.getfirst("strMonth"))

    # html parser
    #h = HTMLParser.HTMLParser()

    # return output filename
    strName = _returnUniqueFilename()
    # save png and pdf extensions
    # strOutFilenamePNG=strName+'.png';
    strOutFilenamePDF = strName + '.pdf'

    # pdf istance
    pdf = FPDF()
    # add page
    pdf.add_page()
    pdf.add_font(
        'DejaVu',
        '',
        r'/var/lib/opengeo/geoserver/styles/DejaVuSansCondensed.ttf',
        uni=True)
    pdf.set_font('Arial', 'B', 16)
    cont = 30
    # add title
    strTitle = _returnIniValue('PDF_CONFIGURATION', 'PDF_TITLE')
    pdf.cell(200, 10, txt=strTitle, ln=1, align="L")
    pdf.set_font('Arial', '', 16)
    strHttp = _returnHttpAddress()
    # add link
    pdf.cell(200, 10, strHttp, 0, 1, 'L')
    pdf.ln(10)
    cont = cont + 10

    if (strLayer != ""):
        # add layer

        pdf.ln(5)
        pdf.set_x(10)
        cont = cont + 10
        arrayFName = returnVariableFeature(strLayer)
        if (strMonth != "None"):
            strDate = strYear + '-' + strMonth
        else:
            strDate = strYear

        strPrintDate = str(strDate)
        arrayVDataset = _returnDatasetAttributes(
            arrayFName["id"], arrayFName["type"])

        strLink = _returnGetMapLink(
            arrayFName, arrayVDataset, strYear, strMonth)

        pdf.set_font('Arial', '', 12)
        # layer title
        pdf.cell(0, 0, 'Layer: ')
        pdf.ln(5)
        cont = cont + 10
        pdf.set_x(15)
        pdf.set_font('DejaVu', '', 12)

        strText = arrayFName['description'] + ', ' + strPrintDate
        if (arrayVDataset["unit"] != ""):
            strText += ' (' + arrayVDataset["unit"] + ')'
        pdf.cell(0, 0, strText.decode('UTF-8'))
        pdf.ln(100)
        # add image
        pdf.image(strLink, 10, cont, 180, 100, 'PNG')
        cont = cont + 110
        # add legend

        if (arrayFName["legend"] == ""):
            # return http image

            strLegend = _returnLegendString(arrayFName, arrayVDataset, strDate)
            import urllib2
            a = urllib2.urlopen(strLegend).read()
            size = get_image_info(a)
        else:

            # return image info
            strPath = _returnHTMLDir()
            with open(strPath + arrayFName["legend"], 'rb') as f:

                data = f.read()
                size = get_image_info(data)

            strLegend = strPath + arrayFName["legend"]

        # calculate image size
        lngW = size[0]
        lngH = size[1]
        lngWMax = 50
        lngHMax = 30
        if (lngW > lngH):
            if (lngW > lngWMax):
                lngH = (lngWMax * lngH) / lngW
                lngW = lngWMax
        else:
            if (lngH > lngHMax):
                lngW = (lngHMax * lngW) / lngH
                lngH = lngHMax
        # add image

        pdf.image(strLegend, 10, cont, lngW, lngH)
        pdf.ln(lngH + 30)

        # add copyright
        pdf.set_font('Arial', '', 12)
        pdf.cell(0, 0, 'Use limitation: ')
        strTextCopyright = _returnPdfCopyright(arrayFName["id"])
        pdf.ln(5)
        pdf.set_font('DejaVu', '', 10)
        # multi cell (text)
        pdf.multi_cell(180, 5, strTextCopyright.decode('UTF-8'))

    strOutputDirectory = _returnTempDirectory(0)
    strHTTPOutputDirectory = _returnTempDirectory(1)
    pdf.output(strOutputDirectory + strOutFilenamePDF, 'F')
    # print and return the output link
    print strHTTPOutputDirectory + strOutFilenamePDF
    def create_pdf(self):
        """Build the PDF file from user-supplied information"""
        
        # Dictionary of variables collected from gui, to be passed to method_graf()
        self.variabledic = {"methodofservice": self.methodText.get(),
            "documents": self.docsservedText.get().upper(),
            "target": self.targetText.get(),
            "dateandtime": self.monthText.get() + " " + self.dayText.get() + 
                ", " + self.yearText.get() + ", at " + self.hourText.get() + 
                ":" + self.minuteText.get() + " " + self.ampmText.get(),
            "location": self.locationText.get(),
            "subperson": self.subpersonText.get(),
            "subrelation": self.subrelationText.get(), 
            "parentname": self.parentText.get(), 
            "tempguard": self.tempText.get(), 
            "committed": self.committedBool.get(), 
            "adminname": self.adminText.get(), 
            "agentname": self.agentText.get(),
            "sex": self.sexText.get()
            }        
        
        pdf=FPDF("P", "pt", "Letter")
        pdf.set_margins(36,36)
        pdf.alias_nb_pages()
        pdf.add_page()
                
        # State, County & Court        
        pdf.set_font("Times", "", 12)
        pdf.multi_cell(h = 18, w = 540, align = "L", txt = (
            "IN THE "+self.courtText.get().upper()+" COURT OF\n"+
            self.countyText.get().upper()+" COUNTY, "+self.stateText.get().upper()))
        pdf.ln(30)
        
        # Plaintiff
        pcursor = pdf.get_y()
        pdf.multi_cell(h=18, w=400, align = "L", txt=self.plaintiffEntry.get(0.0,'end').upper())
        newpcursor = pdf.get_y()
        pdf.set_xy(400, pcursor)
        pdf.cell(w = 0, align = "R", txt = "PLAINTIFF")
        pdf.set_xy(0, newpcursor)
        pdf.ln(18)
        
        # Case Number
        pdf.cell(h = 18, w = 20, align = "L", txt = "V.")
        pdf.cell(h = 18, w = 500, align = "C", txt = "CASE NO. "+self.caseNoText.get().upper())
        pdf.ln(30)
        
        # Defendant
        pcursor = pdf.get_y()
        pdf.multi_cell(h=18, w=400, align = "L", txt=self.defendantEntry.get(0.0,'end').upper())
        newpcursor = pdf.get_y()
        pdf.set_xy(400, pcursor)
        pdf.cell(h = 18, w = 0, align = "R", txt = "DEFENDANT")
        pdf.set_xy(0, newpcursor)
        pdf.ln(18)

        # Title
        pdf.set_font("Times", "U", 12)
        pdf.cell(h = 24, w = 0, align = "C", txt = "AFFIDAVIT OF SERVICE")
        pdf.ln(36)
        
        # Commencement
        pdf.set_font("Times", "", 12)
        pdf.multi_cell(h = 30, w = 540, align = "L", txt = (
            "     Comes now " + self.serverText.get() + ", who, being duly "
            "sworn, deposes and says:"))

        # Paragraph with details of service (multi-line), called from method_graf() function
        pdf.multi_cell(h = 30, w = 540, align = "L", txt = self.method_graf(**self.variabledic))
        
        # Comments
        if len(self.commentsText.get()) > 0:
            pdf.multi_cell(h = 30, w = 540, align = "L", txt = "     " + self.commentsText.get())
        
        # Not a party/No interest/Further affiant sayeth not, etc.
        pdf.multi_cell(h = 30, w = 540, align = "L", txt = (
            "     I am not a party to this action, and I have no interest in it. \n"
            "     Further affiant sayeth not."))
        pdf.ln(40)
        
        # Signature/Notary section
        pdf.line(270,pdf.get_y(),540,pdf.get_y())
        pdf.set_x(270)
        pdf.cell(h = 24, w = 0, align = "L", txt = self.serverText.get())
        pdf.ln(24)
        pdf.set_x(270)
        pdf.multi_cell(h = 18, w = 0, align = "L", txt = self.servaddrEntry.get(0.0,"end"))
        pdf.ln(24)
        pdf.set_x(36)
        pdf.cell(h = 18, w = 270, align = "L", txt = "Subscribed and sworn to before me this date:")
        pdf.line(270,pdf.get_y()+18,540,pdf.get_y()+18)
        pdf.ln(40)
        pdf.line(270,pdf.get_y()+18,540,pdf.get_y()+18)
        pdf.ln(24)
        pdf.set_x(270)
        pdf.cell(h = 18, w = 270, align = "L", txt = "Notary Public")
        pdf.ln(36)
        pdf.set_x(270)
        pdf.cell(h = 18, w = 270, align = "L", txt = "My commission expires:")
        pdf.line(400,pdf.get_y()+18,540,pdf.get_y()+18)
        
        # write PDF
        pdf.output(self.filenameText.get()+".pdf", "F")
        return None
示例#46
0
def issue_student_admission_letter(Student, body):
    """
    Print letter for Student at time of admission
    Contains details as provided by the Student
    """

    pdf = FPDF('P', 'mm', 'A4')
    pdf.add_page('P')
    pdf.set_font('Times', 'B', 14)

    pdf.multi_cell(0, 5, 'Student Admission Letter')
    pdf.ln()
    pdf.multi_cell(0, 5, ('Name: %s' % Student.name))
    pdf.ln()
    pdf.multi_cell(0, 5, ('Address: %s' % Student.address))
    pdf.ln()
    pdf.multi_cell(0, 5, ('Contact Number: %s' % Student.contact_number))
    pdf.ln()
    pdf.multi_cell(0, 5, ('Hall Allotted: %s' % str(db.get("hall", Student.hall_ID, "name")[0])))
    pdf.ln()
    pdf.multi_cell(0, 5, ('Room Allotted: %s' % Student.room_no))
    pdf.ln()
    pdf.ln()
    pdf.multi_cell(0, 5, ('%s' % body))
    pdf.ln()

    # Write generated output file to PDF
    pdf.output(('admission_letter_%s.pdf' % Student.student_ID), 'F')
示例#47
0
def print_statement(Hall):
    """
    Print Hall Account statements for specified hall_ID
    """

    pdf = FPDF('P', 'mm', 'A4')
    pdf.add_page('P')
    pdf.set_font('Times', 'B', 14)

    pdf.multi_cell(0, 5, ('Hall Account Statement for Hall: %s' % Hall.name))
    pdf.ln()
    pdf.multi_cell(0, 5, ('Mess Account: %s' % Hall.mess_account))
    pdf.ln()
    pdf.multi_cell(0, 5, ('Salary Account: %s' % Hall.salary_account))
    pdf.ln()
    pdf.multi_cell(0, 5, ('Repair Account: %s' % Hall.repair_account))
    pdf.ln()
    pdf.multi_cell(0, 5, ('Rent Account: %s' % Hall.rent_account))
    pdf.ln()
    pdf.multi_cell(0, 5, ('Others Account: %s' % Hall.others_account))
    pdf.ln()

    # Write generated output file to PDF
    pdf.output(('hall_statement_%s.pdf' % Hall.hall_ID), 'F')
示例#48
0
def atualizarVenda(nomeVend, naturalidadeVend,estadoCivilVend,profissaoVend,rgVend,cpfVend,ruaVend,numVend,bairroVend,cepVend,cidadeVend,estadoVend,nomeComp,naturalidadeComp,estadoCivilComp,profissaoComp,rgComp,cpfComp,ruaComp,numComp,bairroComp,cepComp,cidadeComp, estado, area, registro, valor):
    #Definindo o formato do PDF
    pdf=FPDF('P','mm','A4')
    #Definindo as margens
    pdf.set_margins(10, 10, 10)
    #Adicionando página
    pdf.add_page()
    #Adicionando configurações de Fonte

    pdf.set_font('Arial','B',16)
    #Inserindo linhas cell by cell.
    contrato = 'CONTRATO E COMPROMISSO DE COMPRA E VENDA DE IMÓVEL'
    utxt1 = unicode (contrato, 'UTF-8')
    stxt1 = utxt1.encode ('iso-8859-1')
    pdf.cell(0,10,stxt1, 1,1 , 'C')
    pdf.ln(10)
    #Dados pessoais das partes interessadas

    pdf.set_font('Arial','',8)
    vendedor = 'PROMITENTE VENDEDOR: '+nomeVend+', nascido em '+naturalidadeVend+', '+estadoCivilVend+','+profissaoVend+',portador do R.G. nº '+rgVend+' ,'
    vendedor += '  e CPF/MF nº '+cpfVend+' residente e domiciliado à '+ruaVend+', '+numVend+', '+bairroVend+', '+cepVend+', '+cidadeVend+', '+estadoVend+'.'
    utxt2 = unicode (vendedor, 'UTF-8')
    stxt2 = utxt2.encode ('iso-8859-1') 
    pdf.multi_cell(0,5,stxt2, 0,'J')
    
    comprador = 'PROMITENTE COMPRADOR: '+nomeComp+', '+naturalidadeComp+', '+estadoCivilComp+', '+profissaoComp+', portador do R.G. nº '+rgComp+','
    comprador += ' e CPF/MF nº '+cpfComp+' residente e domiciliado à '+ruaComp+', '+numComp+', '+bairroComp+', '+cepComp+', '+cidadeComp+', '+estado+'.'
    utxt3 = unicode (comprador, 'UTF-8')
    stxt3 = utxt3.encode ('iso-8859-1') 
    pdf.multi_cell(0,5,stxt3, 0,'J')
    pdf.ln(5)

    pdf.set_font('Arial','B',10)
    clausulas = 'Têm entre os mesmos, de maneira justa e acordada, o presente contrato particular de compromisso de compra e venda de bem imóvel, ficando desde já aceito, pelas cláusulas abaixo descritas:'
    utxt4 = unicode (clausulas, 'UTF-8')
    stxt4 = utxt4.encode ('iso-8859-1') 
    pdf.multi_cell(0,5,stxt4, 0,'J')
    pdf.ln(3)

    pdf.set_font('Arial','',8)
    pdf.ln(1)
    primeira = 'CLÁUSULA PRIMEIRA:'
    utxt5 = unicode (primeira, 'UTF-8')
    stxt5 = utxt5.encode ('iso-8859-1') 
    pdf.cell(33,5,stxt5, 1,1 , 'L')
    pdf.ln(1)
    
    clausulaPrimeira = 'Que a PROMITENTE VENDEDORA é legítima possuidora do imóvel composto por área privativa de '+area+' metros quadrados, '
    clausulaPrimeira +='inscrito no livro de registro de imóveis sob nº '+registro+', com as seguintes confrontações:'
    utxt6 = unicode (clausulaPrimeira, 'UTF-8')
    stxt6 = utxt6.encode ('iso-8859-1') 
    pdf.multi_cell(0,5,stxt6, 0,'J')
    pdf.ln(2)

    segunta = 'CLÁUSULA SEGUNDA:'
    utxt7 = unicode (segunta, 'UTF-8')
    stxt7 = utxt7.encode ('iso-8859-1') 
    pdf.cell(33,5,stxt7, 1,1 , 'L')
    pdf.ln(1)
    
    clausulaSegunda = 'O valor da presente transação é feita pelo preço de R$ '+valor+', que serão pagos de acordo com o que as partes acharem cabíveis.'
    utxt8 = unicode (clausulaSegunda, 'UTF-8')
    stxt8 = utxt8.encode ('iso-8859-1') 
    pdf.multi_cell(0,5,stxt8, 0,'J')
    pdf.ln(2)
    
    terceira = 'CLÁUSULA TERCEIRA:'
    utxt9 = unicode (terceira, 'UTF-8')
    stxt9 = utxt9.encode ('iso-8859-1') 
    pdf.cell(33,5,stxt9, 1,1 , 'L')
    pdf.ln(1)
    
    clausulaTerceira = 'Que o PROMITENTE VENDEDOR se compromete a entregar o imóvel livre e desembaraçado de todos os débitos até esta data, junto ao Agente Financeiro'
    clausulaTerceira += ', ficando daí a responsabilidade do PROMITENTE COMPRADORE o pagamento mensal da prestação.'
    utxt10 = unicode (clausulaTerceira, 'UTF-8')
    stxt10 = utxt10.encode ('iso-8859-1') 
    pdf.multi_cell(0,5,stxt10, 0,'J')
    pdf.ln(2)

    quarta = 'CLÁUSULA QUARTA:'
    utxt11 = unicode (quarta, 'UTF-8')
    stxt11 = utxt11.encode ('iso-8859-1') 
    pdf.cell(33,5,stxt11, 1,1 , 'L')
    pdf.ln(1)
    
    clausulaQuarta = 'Fica acordado entre o PROMITENTE VENDEDOR e PROMITENTE COMPRADOR que o imóvel transacionado permanecerá em nome do PROMITENTE VENDEDOR por '
    clausulaQuarta += 'prazo indeterminado, ficando o PROMITENTE VENDEDOR obrigado a apresentar os documentos necessários para transrência a partir do momento em que '
    clausulaQuarta += 'o mesmo for notificado pelo PROMITENTE COMPRADOR a qualquer época. '
    utxt12 = unicode (clausulaQuarta, 'UTF-8')
    stxt12 = utxt12.encode ('iso-8859-1') 
    pdf.multi_cell(0,5,stxt12, 0,'J')
    pdf.ln(2)
    
    quinta = 'CLÁUSULA QUINTA:'
    utxt13 = unicode (quinta, 'UTF-8')
    stxt13 = utxt13.encode ('iso-8859-1') 
    pdf.cell(33,5,stxt13, 1,1 , 'L')
    pdf.ln(1)

    clausulaQuinta = 'Todos os compromissos assumidos neste contrato são de caráter irrevogável e irrefratével, obrigado as partes, seus herdeiros e sucessores a qualquer'
    clausulaQuinta += 'título fazer sempre boa e valiosa a presente cessão, ficando sujeito às penalidades da lei.'
    utxt14 = unicode (clausulaQuinta, 'UTF-8')
    stxt14 = utxt14.encode ('iso-8859-1') 
    pdf.multi_cell(0,5,stxt14, 0,'J')
    pdf.ln(2)

    sexta = 'CLÁUSULA SEXTA:'
    utxt15 = unicode (sexta, 'UTF-8')
    stxt15 = utxt15.encode ('iso-8859-1') 
    pdf.cell(33,5,stxt15, 1,1 , 'L')
    pdf.ln(1)
    
    clausulaSexta = 'Fica ainda acordando, que caso haja necessidade de se beneficiar do seguro referente ao imóvel,os beneficiados será o PROMITENTE COMPRADOR,ou filhos.'
    utxt16 = unicode (clausulaSexta, 'UTF-8')
    stxt16 = utxt16.encode ('iso-8859-1') 
    pdf.multi_cell(0,5,stxt16, 0,'J')
    pdf.ln(2)
    
    setima = 'CLÁUSULA SÉTIMA:'
    utxt17 = unicode (setima, 'UTF-8')
    stxt17 = utxt17.encode ('iso-8859-1') 
    pdf.cell(33,5,stxt17, 1,1 , 'L')
    pdf.ln(1)
    
    clausulaSetima =  'Em caso de falecimento do PROMITENTE VENDEDOR ,fica acordando entre as partes que todo e qualquer benefício oriundo deste fato,transfere-se' 
    clausulaSetima += 'para o PROMITENTE COMPRADOR.'
    utxt18 = unicode (clausulaSetima, 'UTF-8')
    stxt18 = utxt18.encode ('iso-8859-1') 
    pdf.multi_cell(0,5,stxt18, 0,'J')
    pdf.ln(2)
    
    oitava = 'CLÁUSULA OITAVA:'
    utxt19 = unicode (oitava, 'UTF-8')
    stxt19 = utxt19.encode ('iso-8859-1') 
    pdf.cell(33,5,stxt19, 1,1 , 'L')
    pdf.ln(1)
    
    clausulaOitava = 'Caso haja manifestação pública por parte do Agente Financeiro, quando à transferência do imóvel citado neste instrumento particular de compra'
    clausulaOitava += 'venda, sem que haja o aumento das prestações fica acordo entre as partes a sua transferência.'
    utxt20 = unicode (clausulaOitava, 'UTF-8')
    stxt20 = utxt20.encode ('iso-8859-1') 
    pdf.multi_cell(0,5,stxt20, 0,'J')
    pdf.ln(2)
    
    nona = 'CLÁUSULA NONA:'
    utxt21 = unicode (nona, 'UTF-8')
    stxt21 = utxt21.encode ('iso-8859-1') 
    pdf.cell(33,5,stxt21, 1,1 , 'L')
    pdf.ln(1)
    
    clausulaNona = 'O foro deste contrato é da Comarca de, renunciando as partes quaisquer outro por mais privilegiado que seja.E por estarem assim  juntos e'
    clausulaNona += 'contra  assinam o presente em 03 (Três) vias de igual teor e forma, na presença das testemunhas abaixo.'
    utxt22 = unicode (clausulaNona, 'UTF-8')
    stxt22 = utxt22.encode ('iso-8859-1') 
    pdf.multi_cell(0,5,stxt22, 0,'J')
    pdf.ln(3)

    pdf.cell(0,10,'____________________________________________   _____ , _____ , _________', 0,1 , 'C')
    pdf.ln(10)

    pdf.cell(0,5,'PROMITENTE COMPRADOR:', 0,1 , 'C')
    pdf.cell(0,5,'__________________________________________________', 0,1 , 'C')
    pdf.cell(0,5,'PROMITENTE VENDEDOR:', 0,1 , 'C')
    pdf.cell(0,5,'__________________________________________________', 0,1 , 'C')
    pdf.cell(0,5,'TESTEMUNHA:', 0,1 , 'C')
    pdf.cell(0,5,'__________________________________________________', 0,1 , 'C')
    pdf.cell(0,5,'R.G.:', 0,1 , 'C')
    pdf.cell(0,5,'__________________________________________________', 0,1 , 'C')
    pdf.cell(0,5,'TESTEMUNHA:', 0,1 , 'C')
    pdf.cell(0,5,'__________________________________________________', 0,1 , 'C')
    pdf.cell(0,5,'R.G.:', 0,1 , 'C')
    pdf.cell(0,5,'__________________________________________________', 0,1 , 'C')

    pdf.output('numero%s.pdf'%(registro),'F')
    def handle(self, *args, **options):
    
        skaters = Skater.objects.exclude(status__name="inactive").order_by("derby_name")

        pdf=FPDF()
        pdf.add_font('DejaVu','','/usr/share/fonts/truetype/ttf-dejavu/DejaVuSansCondensed.ttf',uni=True)
        
        for skater in skaters:
            
            pdf.add_page()
            pdf.set_margins(16, 2)
            pdf.ln(20)

            pdf.set_font('DejaVu','',16)
            pdf.cell(40,40,'Derby Name:')
            pdf.set_font('DejaVu','',48)
            pdf.cell(40,40, skater.derby_name)
            pdf.ln(20)

            pdf.set_font('DejaVu','',16)
            pdf.cell(40,40,'Real Name:')
            pdf.set_font('DejaVu','',24)
            pdf.cell(40,40, skater.first_name + " " + skater.last_name)
            pdf.ln(20)
            
            pdf.set_font('DejaVu','',16)
            pdf.cell(60,40,'Date of Birth:')
            pdf.set_font('DejaVu','',24)
            pdf.cell(0,40, str(skater.dob))
            pdf.ln(10)
            
            pdf.set_font('DejaVu','',16)
            pdf.cell(60,40,'Emergency Contact:')
            pdf.set_font('DejaVu','',24)
            pdf.cell(0,40, skater.emergency_contact)
            pdf.ln(10)
            pdf.cell(60,40,'')
            pdf.set_font('DejaVu','',24)
            pdf.cell(0,40, skater.emergency_phone)
            pdf.ln(10)
            pdf.cell(60,40,'')
            pdf.set_font('DejaVu','',24)
            pdf.cell(0,40, skater.emergency_relationship)
            pdf.ln(15)
            
            pdf.set_font('DejaVu','',16)
            pdf.cell(60,40,'Insurance Provider:')
            pdf.set_font('DejaVu','',24)
            pdf.cell(0,40, skater.insurance_provider)
            pdf.ln(15)
            
            pdf.set_font('DejaVu','',16)
            pdf.cell(60,40,'Hosptial Preference:')
            pdf.set_font('DejaVu','',24)
            pdf.cell(0,40, skater.hospital)
            pdf.ln(15)
            
            pdf.set_font('DejaVu','',12)
            pdf.multi_cell(0,40,'Medical Conditions:')
            pdf.ln(-15)
            pdf.set_font('DejaVu','',24)
            if skater.medical_details == "":
                details = "<none>"
            else:
                details = skater.medical_details
            
            pdf.write(12, details)
            pdf.ln(25)

            wftda = ""
            try:
                wftda = int(skater.wftda_number)
            except:
                pass

            pdf.set_font('Courier','',7)
            pdf.write(4, 'MWD #' + str(skater.id) + " | " + str(skater.email) + " | WFTDA #" + str(wftda) + " | generated on " + strftime("%Y-%m-%d", gmtime()))


        pdf.output('test.pdf','F')
示例#50
0
def createCertificate(
	workshop_name,
	workshop_day,
	workshop_month,
	workshop_year,
	workshop_speaker,
	student_name,
	student_mail,
	chair_IEEE
	):
	
	l_name = unicode( student_name, "utf-8" )
	w_name = unicode( workshop_name, "utf-8" )
	c_name = unicode( chair_IEEE, "utf-8" )
	s_name = unicode( workshop_speaker, "utf-8" )

	# PDF File Properties
	pdf=FPDF('L','mm','A4')
	pdf.set_margins(left=0,top=0,right=0)
	pdf.set_auto_page_break(False,margin=0)
	pdf.add_page()
	# ISEPinIEEE Logo
	pdf.set_font('Arial','',30)
	pdf.cell(297,40,'',0,1,'C')#fill=True
	pdf.image('logos/isepinieee_logo.jpg',190,5, 0,35,'','')
	# Workshop Title
	pdf.set_text_color(0,102,153)
	pdf.cell(293,20,w_name,0,1,'R')
	# Cetificate Bar
	pdf.set_fill_color(0,102,153)
	pdf.set_text_color(255,255,255)
	pdf.set_font('Arial','',48)
	pdf.cell(297,35,'Certificate',0,1,'C',fill=True)
	pdf.cell(297,10,'',0,1,'C')
	# Certificate Text
	pdf.set_font('Arial','',20)
	pdf.set_text_color(0,0,0)
	# This pdf element is used to center ( Note: (297-240)/2 = 28.5)
	pdf.cell(19,20,'',0,0,'C')
	pdf.multi_cell(259,12.5, 'We certifiy that '+l_name+' participated in the talk \"'+w_name+'\", organized by the ISEPinIEEE.',0,1,'C')
	#MultiCell( 200, 40, $reportSubtitle, 1);
	# Certificate Date
	pdf.cell(297,10,'',0,1,'C')
	pdf.cell(19,15,'',0,0,'C')
	pdf.cell(240,10,'Porto, '+workshop_month+' '+str(workshop_day)+', '+str(workshop_year),0,1,'L')

	#Speaker & Chair Signature
	pdf.image(workshop_name+'/signatures/speaker.jpg',167.5,170, 0, 17,'','')
	pdf.image(workshop_name+'/signatures/chair.jpg',240.5,170, 0, 17,'','')

	#Speaker & Chair
	pdf.set_font('Arial','',18)
	pdf.cell(150,20,'',0,0,'C')
	pdf.cell(73.5,20,'Speaker',0,0,'C')
	pdf.cell(73.5,20,'Chair',0,1,'C')
	pdf.cell(150,35,'',0,0,'C')
	pdf.cell(73.5,35,s_name,0,0,'C')
	pdf.cell(73.5,35,c_name,0,1,'C')

	#SpeakerLine & ChairLine
	pdf.line(155, 180, 218, 180)
	pdf.line(228, 180, 292, 180)
	# IEEE and ISEP logos
	pdf.image('logos/ieee_logo.jpg',20,175, 0, 17,'','')
	pdf.image('logos/isep_logo.jpg',85,175, 0, 17,'','')
	# Save PDF File
	certificate_name = hashlib.md5(student_mail)
	pdf.output(workshop_name+'/'+certificate_name.hexdigest()+'.pdf','F')
示例#51
0
    def ImrimirPDF(self, prod_table,SubTotal,TAX,Total,stDate,endDate):
	# Obtener los datos de la tienda/empresa desde la base de datos
	Datos = db.SelectConfigNS()
	if hasattr(sys, 'frozen'):
		logo = os.path.join('resources', 'logo.png')
	else:
		logo = os.path.join(os.path.split(__file__)[0],  'resources', 'logo.png')

	pdf = FPDF()
	pdf.add_page()
	pdf.set_font('times', '', 13.0)
	pdf.set_xy(105.0, 16.0)
	pdf.cell(ln=0, h=22.0, align='L', w=75.0, txt='', border=0)
	pdf.set_line_width(0.0)
	pdf.rect(15.0, 15.0, 170.0, 61.0)
	pdf.set_line_width(0.0)
	#pdf.rect(95.0, 15.0, 10.0, 10.0)
	pdf.image(logo, 20.0, 16.0, link='', type='', w=0, h=17)
	pdf.set_font('times', 'B', 16.0)
	pdf.set_xy(95.0, 18.0)
	#pdf.cell(ln=0, h=2.0, align='C', w=10.0, txt='Hola 1', border=0)
	pdf.set_font('times', '', 8.0)
	pdf.set_xy(115.0, 40.0)
	pdf.cell(ln=0, h=4.0, align='L', w=75.0, txt="Tel:               "+str(Datos[3]), border=0)
	pdf.set_xy(115.0, 43.0)
	pdf.cell(ln=0, h=4.0, align='L', w=75.0, txt="Web:              "+str(Datos[4]), border=0)
	pdf.set_xy(115.0, 46.0)
	pdf.cell(ln=0, h=4.0, align='L', w=75.0, txt="E-mail:           "+Datos[7], border=0)
	pdf.set_xy(115.0, 49.0)
	pdf.cell(ln=0, h=4.0, align='L', w=75.0, txt="NIT:               "+str(Datos[8]), border=0)
	pdf.set_font('times', 'B', 7.0)
	pdf.set_xy(95.0, 21.5)
	#pdf.cell(ln=0, h=4.5, align='C', w=10.0, txt='Hola 3', border=0)
	pdf.set_line_width(0.0)
	pdf.line(100.0, 15.0, 100.0, 57.0)
	pdf.set_font('arial', 'B', 18.0)
	pdf.set_xy(137.0, 30.5)
	pdf.cell(ln=0, h=9.5, align='L', w=60.0, txt='', border=0)
	pdf.set_xy(113.0, 25.5)
	pdf.cell(ln=0, h=5.5, align='C', w=60.0, txt='Reporte de Ventas ', border=0)
	pdf.set_font('times', 'B', 12.0)
	pdf.set_xy(17.0, 32.5)
	pdf.cell(ln=0, h=5.0, align='L', w=98.0, txt=Datos[1], border=0)
	pdf.set_font('times', '', 12.0)
	pdf.set_xy(17.0, 36.5)
	pdf.set_font('times', '', 8.0)
	pdf.cell(ln=0, h=5.0, align='L', w=98.0, txt=Datos[2], border=0)
	pdf.set_xy(17.0, 43.5)
	pdf.set_font('times', '', 8.0)
	pdf.multi_cell( h=4.0, align='L', w=80.0, txt=Datos[5], border=0, )
	pdf.set_xy(115.0, 35.0)
	pdf.cell(ln=0, h=7.0, align='L', w=60.0, txt='Fecha:', border=0)
	pdf.set_xy(130.0, 35.0)
	date = time.localtime()[:5]
	date = (date[2], date[1], date[0], date[3], date[4],)
	date = "%d/%d/%d %d:%02d" % date
	pdf.cell(ln=0, h=7.0, align='L', w=40.0, txt=date, border=0)
	pdf.set_line_width(0.0)
	pdf.line(15.0, 57.0, 185.0, 57.0)
	# Mostrar SubTotal, Iva y total de las ventas
	pdf.set_font('times', '', 10.0)
	pdf.set_xy(17.0, 59.0)
	pdf.cell(ln=0, h=6.0, align='L', w=13.0, txt='Sub-total:  ', border=0)
	pdf.set_xy(35.0, 59.0)
	pdf.cell(ln=0, h=6.0, align='L', w=140.0, txt=SubTotal, border=0)
	pdf.set_xy(17.0, 64.0)
	pdf.cell(ln=0, h=6.0, align='L', w=18.0, txt='IVA:        ', border=0)
	pdf.set_xy(35.0, 64.0)
	pdf.cell(ln=0, h=6.0, align='L', w=125.0, txt=TAX, border=0)
	pdf.set_xy(17.0, 69.0)
	pdf.cell(ln=0, h=6.0, align='L', w=18.0, txt='Total:       ', border=0)
	pdf.set_xy(35.0, 69.0)
	pdf.cell(ln=0, h=6.0, align='L', w=80.0, txt=Total, border=0)
	
	
	
	# Mostrar fecha de inicio y de finalizacion
	pdf.set_xy(115.0, 58.0)
	pdf.cell(ln=0, h=6.0, align='L', w=18.0, txt='Fecha de inicio:', border=0)
	pdf.set_xy(135.0, 62.0)
	pdf.cell(ln=0, h=6.0, align='L', w=42.0, txt=stDate, border=0)
	pdf.set_xy(115.0, 66.0)
	pdf.cell(ln=0, h=6.0, align='L', w=18.0, txt='Fecha de finalizacion:', border=0)
	pdf.set_xy(135.0, 70.0)
	pdf.cell(ln=0, h=6.0, align='L', w=42.0, txt=endDate, border=0)
	
	# Imprimir listado de productos vendidos
	lineaN = 80-7
	for sale in prod_table:
		lineaN = lineaN+7
		PreLineas = 0
		for prod in sale[1]:
			## Precalcular las lineas que se usaran en la tabla
			if len(prod[5]) >67:
				PreLineas = PreLineas+10
			else:
				PreLineas = PreLineas+10
			PreLineas = PreLineas+5
		if (lineaN+PreLineas+5) > 275:
			pdf.add_page()
			lineaN = 10
			#PreLineas = PreLineas- 10
		#Imprimir los datos del cliente
		pdf.set_line_width(0.0)
		pdf.line(15.0, lineaN, 15.0, lineaN+7) # linea vertical de borde iz
		pdf.line(185.0, lineaN, 185.0, lineaN+7) # linea vertical de borde de
		pdf.line(15.0, lineaN, 185.0, lineaN) # linea horizontal
		pdf.set_line_width(0.0)
		pdf.line(80.0, lineaN, 80.0, lineaN+7) # linea verticals
		pdf.line(120.0, lineaN, 120.0, lineaN+7) # linea vertical 
		pdf.line(150.0, lineaN, 150.0, lineaN+7) # linea vertical 
		pdf.set_font('times', '', 8.0)
		pdf.set_xy(15.0, lineaN)
		pdf.cell(ln=0, h=5.0, align='L', w=125.0, txt='Cliente: '+sale[0][3], border=0)
		pdf.set_xy(81.0, lineaN)
		pdf.cell(ln=0, h=5.0, align='L', w=15.0, txt='Nit: '+sale[0][4], border=0)
		pdf.set_xy(121.0, lineaN)
		pdf.cell(ln=0, h=5.0, align='L', w=125.0, txt='Fecha: '+sale[0][1], border=0)
		pdf.set_xy(151.0, lineaN)
		pdf.cell(ln=0, h=5.0, align='L', w=125.0, txt='Total: '+self.TSep(sale[0][2]), border=0)
		lineaN = lineaN+7
		#imprimir las lineas para formar el cuadro
		pdf.line(15.0, lineaN, 15.0, lineaN+7) # linea vertical de borde iz
		pdf.line(185.0, lineaN, 185.0, lineaN+7) # linea vertical de borde de
		pdf.line(15.0, lineaN, 185.0, lineaN) # linea horizontal
		pdf.set_line_width(0.0)
		pdf.line(20.0, lineaN, 20.0, lineaN+7) # linea vertical
		pdf.line(37.0, lineaN, 37.0, lineaN+7) # linea vertical
		pdf.line(130.0, lineaN, 130.0, lineaN+7) # linea vertical
		pdf.line(150.0, lineaN, 150.0, lineaN+7) # linea vertical
		pdf.line(165.0, lineaN, 165.0, lineaN+7) # linea verticalpdf.line(15.0, lineaN, 185.0, lineaN) # linea horizontal

		
		
		#Imprimir los pre-datos de los productos
		pdf.set_font('times', '', 8.0)
		pdf.set_xy(14.0, lineaN)
		pdf.cell(ln=0, h=5.0, align='L', w=125.0, txt=' No.', border=0)
		pdf.set_xy(20.0, lineaN)
		pdf.cell(ln=0, h=5.0, align='C', w=15.0, txt='Codigo', border=0)
		pdf.set_xy(37.0, lineaN)
		pdf.cell(ln=0, h=5.0, align='L', w=125.0, txt='Producto', border=0)
		pdf.set_xy(135.0, lineaN)
		pdf.cell(ln=0, h=5.0, align='L', w=125.0, txt='Precio', border=0)
		pdf.set_xy(150.0, lineaN)
		pdf.cell(ln=0, h=5.0, align='L', w=125.0, txt='Cantidad', border=0)
		pdf.set_xy(165.0, lineaN)
		pdf.cell(ln=0, h=5.0, align='L', w=20.0, txt='Total', border=0)
		pdf.set_line_width(0.0)
		pdf.line(15.0, lineaN+7, 185.0, lineaN+7)
		#Imprimir los productos comprados por el cliente
		contador = 0
		lineaN = lineaN+7
		for prod in sale[1]:
			contador = contador+1
			
			#Imprimir los pre-datos de los productos
			pdf.set_font('times', '', 8.0)
			pdf.set_xy(14.0, lineaN)
			pdf.cell(ln=0, h=5.0, align='L', w=125.0, txt=str(contador), border=0)
			pdf.set_xy(20.0, lineaN)
			pdf.set_font('times', '', 5.0)
			pdf.cell(ln=0, h=5.0, align='C', w=15.0, txt=prod[6], border=0)
			pdf.set_xy(37.0, lineaN)
			pdf.set_font('times', '', 8.0)
			if len(prod[5]) >67:
				pdf.multi_cell( h=5.0, align='L', w=93.0, txt=prod[5]+"  Linea:"+str(lineaN), border=0)
				pdf.line(15.0, lineaN, 15.0, lineaN+10) # linea vertical de borde iz
				pdf.line(185.0, lineaN, 185.0, lineaN+10) # linea vertical de borde de
			else:
				pdf.cell(ln=0, h=5.0, align='L', w=93.0, txt=prod[5]+"  Linea:"+str(lineaN), border=0)
				pdf.line(15.0, lineaN, 15.0, lineaN+5) # linea vertical de borde iz
				pdf.line(185.0, lineaN, 185.0, lineaN+5) # linea vertical de borde de
			pdf.set_xy(135.0, lineaN)
			pdf.cell(ln=0, h=5.0, align='L', w=125.0, txt=self.formatCant(prod[3]), border=0)
			pdf.set_xy(150.0, lineaN)
			pdf.cell(ln=0, h=5.0, align='L', w=125.0, txt=str(prod[4]), border=0)
			pdf.set_xy(165.0, lineaN)
			pdf.cell(ln=0, h=5.0, align='L', w=20.0, txt=self.TSep(prod[3]*prod[4]), border=0)
			pdf.set_line_width(0.0)
			
			if len(prod[5]) >67:
				# Imprimir lineas separadoras de los datos
				pdf.set_line_width(0.0)
				pdf.line(20.0, lineaN, 20.0, lineaN+10) # linea vertical
				pdf.line(37.0, lineaN, 37.0, lineaN+10) # linea vertical
				pdf.line(130.0, lineaN, 130.0, lineaN+10) # linea vertical
				pdf.line(150.0, lineaN, 150.0, lineaN+10) # linea vertical
				pdf.line(165.0, lineaN, 165.0, lineaN+10) # linea vertical
				lineaN = lineaN+10
			
			else:
				# Imprimir lineas separadoras de los datos
				pdf.set_line_width(0.0)
				pdf.line(20.0, lineaN, 20.0, lineaN+5) # linea vertical
				pdf.line(37.0, lineaN, 37.0, lineaN+5) # linea vertical
				pdf.line(130.0, lineaN, 130.0, lineaN+5) # linea vertical
				pdf.line(150.0, lineaN, 150.0, lineaN+5) # linea vertical
				pdf.line(165.0, lineaN, 165.0, lineaN+5) # linea vertical
				lineaN = lineaN+5
		pdf.line(15.0, lineaN, 185.0, lineaN)
		
			
			
			
	
	lineaN = 89.0
	contador = 0
	datos_items = []
	for elemento in datos_items:
		contador = contador+1
		pdf.set_xy(15.0, lineaN)
		pdf.cell(ln=0, h=5.0, align='C', w=5.0, txt=str(contador), border=0)
		pdf.set_xy(20.0, lineaN)
		pdf.set_font('times', '', 5.0)
		pdf.cell(ln=0, h=5.0, align='C', w=10.0, txt=elemento[6], border=0)
		pdf.set_font('times', '', 8.0)
		pdf.set_xy(30.0, lineaN)
		if len(elemento[5]) > 74:
			pdf.multi_cell( h=5.0, align='L', w=100.0, txt=elemento[5], border=0)
		else:
			pdf.cell(ln=0, h=5.0, align='L', w=100.0, txt=elemento[5], border=0)
		pdf.set_xy(130.0, lineaN)
		pdf.cell(ln=0, h=5.0, align='L', w=125.0, txt=str(self.formatCant(elemento[3])), border=0)
		pdf.set_xy(154.0, lineaN)
		pdf.cell(ln=0, h=5.0, align='L', w=125.0, txt=str(elemento[4]), border=0)
		pdf.set_xy(165.0, lineaN)
		pdf.cell(ln=0, h=5.0, align='L', w=20.0, txt=str(self.formatCant(elemento[3]*elemento[4])), border=0)
		if len(elemento[5]) > 74:
			lineaN = lineaN+10
		else:
			lineaN = lineaN+5
	pdf.output('report.pdf', 'F')
	if sys.platform.startswith("linux"):
		os.system("evince ./report.pdf")
	else:
		os.system("report.pdf")
		
示例#52
0
def main():
    # reads input parameters
    form = cgi.FieldStorage()
    #h = HTMLParser.HTMLParser()

    data = form.getfirst("data")

    strParams = form.getfirst("strParams")

    pos = data.find(",")

    data = data[pos + 1:]

    arrayParams = strParams.split('<%%>')
    data = base64.b64decode(data)

    # output directory
    strOutputDirectory = _returnTempDirectory(0)
    # return filename
    strName = _returnUniqueFilename()
    # png and pdf extensions
    strOutFilenamePNG = strName + '.png'
    strOutFilenamePDF = strName + '.pdf'
    # open png file for writing
    f = open(strOutputDirectory + strOutFilenamePNG, 'w')
    f.write(data)
    f.close()
    # parameters

    # print arrayParams[1]
    # strText=arrayParams[1].encode("utf-8")

    # print strText
    # arrayParams[1]=h.unescape(arrayParams[1])
    #arrayParams[1]=arrayParams[1].replace("<br>", ", ");
    #arrayParams[1]=arrayParams[1].replace("Â", "");

    # variables
    arrayVars1 = arrayParams[2].split('#')
    arrayVars2 = arrayParams[3].split('#')

    # pdf istance
    pdf = FPDF()
    # add page
    pdf.add_page()

    #pdf.add_font('Arial', '', r'/var/lib/opengeo/geoserver/styles/ArialSansCondensed.ttf', uni=True)
    #pdf.set_font('Arial', '', 14)

    pdf.set_font('Arial', 'B', 16)
    cont = 0
    # add title
    strTitle = _returnIniValue('PDF_CONFIGURATION', 'PDF_TITLE')
    pdf.cell(200, 10, txt=strTitle, ln=1, align="L")
    pdf.set_font('Arial', '', 16)
    strHttp = _returnHttpAddress()
    # add ce ll for address
    pdf.cell(200, 10, strHttp, 0, 1, 'L')
    pdf.ln(10)
    cont = cont + 10
    # add cell for operation
    pdf.set_font('Arial', '', 12)
    pdf.cell(0, 0, 'Operation: ')
    pdf.ln(5)
    cont = cont + 5
    pdf.set_x(15)
    # add cell for coordinates
    # pdf.set_font('Arial','',12)
    pdf.cell(0, 0, arrayParams[0].decode('UTF-8'))
    pdf.ln(5)
    cont = cont + 5
    # add cell for coordinates
    pdf.set_font('Arial', '', 12)
    pdf.cell(0, 0, 'Coordinates: ')
    pdf.ln(5)
    cont = cont + 5
    pdf.set_x(15)
    # pdf.set_font('Arial','',12)
    pdf.cell(0, 0, arrayParams[1].decode('UTF-8'))

    #pdf.write(8, text)
    pdf.ln(5)
    cont = cont + 5
    pdf.set_font('Arial', '', 12)
    # variables list
    pdf.cell(0, 0, 'Variables Y1: ')
    pdf.ln(5)
    cont = cont + 5
    strAdditionalInfo = ''
    strTextCopyright = ''
    for value in arrayVars1:
        if (value != ""):
            arrayFName = returnVariableFeature(value)

            arrayVDataset = _returnDatasetAttributes(
                arrayFName["id"], arrayFName["type"])
            pdf.set_font('Arial', '', 12)
            strAdd = arrayFName["description"].decode('UTF-8')
            if (arrayVDataset["unit"] != ""):
                strAdd += ' (' + arrayVDataset["unit"].decode('UTF-8') + ')'

            pdf.set_x(15)
            pdf.cell(0, 0, strAdd)
            # for each variable add a description
            pdf.ln(5)
            cont = cont + 5
            # save the copyright for each variable in order to put the text
            # after the graph
            strTextCopyright += '\n\n' + strAdd + '\n' + \
                _returnPdfCopyright(arrayFName["id"])

            strAdditionalInfo += _returnMetadataAdditionalInfo(
                arrayFName["id"])
            strAdditionalInfo += '\n\nMetadata link: \n' + \
                _returnMetadataLink(arrayFName["id"])

    blnPrimaVolta = 1

    for value in arrayVars2:
        if (value != ""):
            if (blnPrimaVolta == 1):
                blnPrimaVolta = 0
                pdf.cell(0, 0, 'Variables Y2: ')
                pdf.ln(5)

            pdf.set_x(15)
            arrayFName = returnVariableFeature(value)
            arrayVDataset = _returnDatasetAttributes(
                arrayFName["id"], arrayFName["type"])
            pdf.set_font('Arial', '', 12)
            strAdd = arrayFName["description"].decode('UTF-8')
            if (arrayVDataset["unit"] != ""):
                strAdd += ' (' + arrayVDataset["unit"].decode('UTF-8') + ')'

            pdf.cell(0, 0, strAdd)
            # for each variable add a description
            pdf.ln(5)
            cont = cont + 5
            # save the copyright for each variable in order to put the text
            # after the graph
            strTextCopyright += '\n\n' + strAdd + '\n' + \
                _returnPdfCopyright(arrayFName["id"])
            strAdditionalInfo += '\n\n' + \
                _returnMetadataAdditionalInfo(arrayFName["id"])
            strAdditionalInfo += '\n\nMetadata link: \n' + \
                _returnMetadataLink(arrayFName["id"])
    # add graph image
    pdf.image(strOutputDirectory + strOutFilenamePNG,
              10, cont + 40, 180, 120, 'PNG')
    # add copyright
    if (strTextCopyright != ""):
        pdf.ln(130)
        pdf.set_font('Arial', '', 12)
        pdf.cell(0, 0, 'Use limitation: ')
        pdf.ln(1)
        pdf.set_font('Arial', '', 10)
        pdf.multi_cell(180, 5, strTextCopyright.decode('UTF-8'))
        strHTTPOutputDirectory = _returnTempDirectory(1)
    pdf.ln(5)
    if (strAdditionalInfo != ""):
        pdf.set_font('Arial', '', 10)
        pdf.multi_cell(180, 5, strAdditionalInfo.decode('UTF-8'))
        strHTTPOutputDirectory = _returnTempDirectory(1)
    pdf.ln(5)

    pdf.output(strOutputDirectory + strOutFilenamePDF, 'F')
    # print and return the output link
    print strHTTPOutputDirectory + strOutFilenamePDF
 def createReportForProjectPDF(self, pid):
     data = self.createReportForProject(pid)
     pdf = FPDF()
     pdf.add_page()
     pdf.set_font('Arial', 'B', 16)
     pdf.cell(40, 10, data['title'])
     pdf.set_font('Arial', size=12)
     pdf.multi_cell(w=0, h=10, txt='')
     pdf.multi_cell(0, 5, 'Users involved in project: ')
     for user in data['users']:
         pdf.multi_cell(0, 5, txt=" - " + user)
     pdf.multi_cell(0, 5, 'Tasks closed: ' + str(data['nrTasksClosed']))
     pdf.multi_cell(0, 5, 'Tasks in progress: ' + str(data['nrTasksInProgress']))
     pdf.multi_cell(0, 5, 'Tasks to do: ' + str(data['nrTasksToDO']))
     pdf.multi_cell(0, 5, 'Most active user is: ' + str(data['mostActive']))
     pdf.multi_cell(0, 5, 'Total time logged: ' + str(data['timeLogged']))
     pdf.multi_cell(0, 5, 'Time remaining for tasks: ' + str(data['timeRemaining']))
     pdf.output('generated_reports/project_' + str(pid) + '_report.pdf', 'F')
示例#54
0
文件: pdf.py 项目: ceasaro/jeslee
def invoice_to_PDF(order, client, filename=None):
    """
    creates and pdf invoice of the order, and returns the pfd as a string buffer.
    @order: the order used to create a invoice
    @client: if specified this data is used for the client address, otherwise the address is taken from the order
    @filename: if specified the pdf is written to disk with the given filename,
               filename can contains a complete path
    """
    pdf = FPDF()
    pdf.add_font('DejaVu', '', fname='{0}/fonts/ttf-dejavu/DejaVuSerif.ttf'.format(settings.STATIC_ROOT), uni=True)
    pdf.add_font('DejaVu', 'B', fname='{0}/fonts/ttf-dejavu/DejaVuSerif-Bold.ttf'.format(settings.STATIC_ROOT), uni=True)
    pdf.add_font('DejaVu', 'I', fname='{0}/fonts/ttf-dejavu/DejaVuSerif-Italic.ttf'.format(settings.STATIC_ROOT), uni=True)
    pdf.add_font('DejaVu', 'BI', fname='{0}/fonts/ttf-dejavu/DejaVuSerif-BoldItalic.ttf'.format(settings.STATIC_ROOT), uni=True)

    def check_for_new_page():
        if pdf.get_y() > PAGE_BOTTOM_Y:
            pdf.add_page()

    def text_fonts():
        pdf.set_font('DejaVu', '', 11.0)

    def add_row(column_data, columns=COLUMNS, border=0):
        """
        add a row to the pdf
        """
        cell_margin_left = 2
        cell_margin_right = 2

        check_for_new_page()
        last_y = START_TABLE_Y if pdf.page_no() == 1 else TOP_PAGE_MARGIN
        row_y = pdf.get_y() if pdf.get_y() > last_y else last_y
        max_y = row_y  # max_y is used to check if multi cell is wrapping text and so uses more rows.

        next_x = LEFT_PAGE_MARGIN
        for i, column in enumerate(columns):
            width = column[0]
            align = column[1]
            pdf.set_xy(next_x+cell_margin_left, row_y)
            pdf.multi_cell(w=width-cell_margin_right,
                           h=TABLE_ROW_HIGH,
                           txt=column_data[i] if len(column_data) > i else '', align=align, border=border)
            max_y = max(max_y, pdf.get_y())  # keep track if multi cell wrapped text
            next_x += width

        pdf.set_y(max_y)

    def add_row_line():
        last_y = START_TABLE_Y if pdf.page_no() == 1 else TOP_PAGE_MARGIN
        line_y = pdf.get_y() if pdf.get_y() > last_y else last_y - 2
        pdf.set_xy(LEFT_PAGE_MARGIN + 1, line_y)
        pdf.line(LEFT_PAGE_MARGIN, line_y+2, RIGHT_PAGE_MARGIN, line_y+2)
        pdf.set_y(line_y+5)

    def draw_vertical_lines_around_columns(columns = COLUMNS, top_y=TOP_PAGE_MARGIN, bottom_y=PAGE_BOTTOM_Y):
        ####
        # draw table vertical lines
        ####
        line_y = pdf.get_y() - 3
        line_x = LEFT_PAGE_MARGIN
        first = True
        for column in columns:
            if first:
                pdf.line(line_x, START_TABLE_Y, line_x, line_y)  # vertical line in front of table
                first = False

            line_x += column[0]
            pdf.line(line_x, START_TABLE_Y, line_x, line_y)  # vertical line after column

    pdf.add_page()
    text_fonts()

    ####
    # Header: logo and company info
    ####
    pdf.image('{0}/gfx/logos/logo_jeslee.jpg'.format(settings.STATIC_ROOT), 20.0, TOP_PAGE_MARGIN, link='', type='', w=79.5, h=33.0)
    pdf.set_xy(125.0, TOP_PAGE_MARGIN)
    # pdf.set_font('arial', 'B', 13.0)
    pdf.set_left_margin(125.0)
    pdf.write(6, '{company}\n{street}\n{zip} {city}\n{email}\n\nBank: {bank_account}\nKvk: {kvk}\nBTW: {btw}'.format(
        company=settings.COMPANY['business_name'],
        street=settings.COMPANY['street'], zip=settings.COMPANY['zip'], city=settings.COMPANY['city'],
        email=settings.COMPANY['email'], bank_account=settings.COMPANY['bank_account'], kvk=settings.COMPANY['kvk_nr'], btw=settings.COMPANY['btw_nr']
    ))

    ####
    # Invoice data
    ####
    pdf.set_xy(LEFT_PAGE_MARGIN, 75)
    pdf.set_left_margin(LEFT_PAGE_MARGIN)
    pdf.set_font('DejaVu', 'B', 14.0)
    pdf.write(6, 'Factuur {number}'.format(number=order.number))
    text_fonts()
    pdf.set_xy(125, 75)
    pdf.write(6, 'Factuurdatum: {date}'.format(date=datetime.now().strftime("%d %B %Y")))
    pdf.set_xy(LEFT_PAGE_MARGIN, 85)
    pdf.write(5, 'Referentie: {reference}'.format(reference=order.invoice_line2 if order.invoice_line2 else 'Uw bestelling bij Jeslee'))
    pdf.set_xy(LEFT_PAGE_MARGIN, 100)
    name = order.invoice_company_name \
        if order.invoice_company_name \
        else "{0} {1}".format(order.invoice_firstname, order.invoice_lastname)
    address = order.invoice_line1
    pdf.write(6, '{name}\n{address}\n{zip} {city}'.format(
        name=name.strip(), address=address.strip(),
        zip=order.invoice_code, city=order.invoice_city
    ))


    ####
    # Article data
    ####
    pdf.set_font('DejaVu', '', 9.0)
    add_row_line()
    add_row(['Artikelcode', 'Omschrijving', '', 'Bedrag\nincl. btw', 'Totaal'])
    add_row_line()
    for item in order.items.all():
        code = ''
        description = ''
        if item.product:
            code = item.product.sku
            description = item.product.description if item.product.description else item.product.name
            str(item.product.tax if item.product.tax else '')
        add_row([code,
                 description,
                 '%.0f x' % item.product_amount,
                 to_currency(item.product_price_gross),
                 to_currency(item.price_gross)])

    add_row_line()

    columns_below_items = [(COLUMN_1_WIDTH + COLUMN_2_WIDTH + COLUMN_3_WIDTH+COLUMN_4_WIDTH , 'R'),
                           (COLUMN_5_WIDTH, 'R')]
    add_row(['Subtotaal', to_currency(order.price-order.tax)], columns=columns_below_items)
    taxes = tax_per_percentage(order)

    for tax_percentage, tax in taxes.iteritems():
        add_row(['Btw {0}%'.format(tax_percentage), to_currency(tax)], columns=columns_below_items)
    add_row_line()
    pdf.set_font('DejaVu', 'B', 10.0)
    add_row(['Totaal', to_currency(order.price)], columns=columns_below_items)
    table_bottom = pdf.get_y() + 2
    pdf.line(LEFT_PAGE_MARGIN, table_bottom, RIGHT_PAGE_MARGIN, table_bottom)  # bottom horizontal line of table

    pdf.set_font('DejaVu', '', 10.0)
    pdf.set_y(pdf.get_y() + 10)
    check_for_new_page()
    pdf.set_x(LEFT_PAGE_MARGIN)
    pdf.multi_cell(w=COLUMN_1_WIDTH + COLUMN_2_WIDTH + COLUMN_3_WIDTH+COLUMN_4_WIDTH+COLUMN_5_WIDTH,
                   h=TABLE_ROW_HIGH,
                   txt=order.message, align='L', border=0)




    pdf.set_font('DejaVu', '', 10.0)
    pdf.set_xy(LEFT_PAGE_MARGIN, PAGE_BOTTOM_Y-14)
    pay_date = datetime.now() + timedelta(PAY_INVOICE_WITHIN_DAYS)
    pdf.write(4, 'We verzoeken u vriendelijk het bovenstaande bedrag van {order_price} voor '
                 '{pay_date} te voldoen op onze bankrekening onder vermelding van het '
                 'factuurnummer {invoice_number}.\nVoor vragen kunt u contact opnemen per e­mail ({email}).'.
              format(order_price=to_currency(order.price),
                     pay_date=pay_date.strftime("%d %B %Y"),
                     invoice_number=order.number,
                     email=settings.COMPANY['email']))

    pdf.set_draw_color(80)
    pdf.set_text_color(80)
    pdf.line(LEFT_PAGE_MARGIN, PAGE_BOTTOM_Y, RIGHT_PAGE_MARGIN, PAGE_BOTTOM_Y)  # bottom horizontal line
    pdf.set_xy(LEFT_PAGE_MARGIN+5, PAGE_BOTTOM_Y+2)
    if filename:
        pdf.output(filename, 'F')
    return pdf.output('invoice.pdf', 'S')
示例#55
0
    im, im_h, im_w = qrc(wif[x])
    img = Image.new( 'RGB', (im_w,im_h), "white")
    img.paste(im,(0,0))
    img.save('qrcode'+str(x)+'.jpg')
    pdf.image('qrcode'+str(x)+'.jpg',169,h_qr,30,29)
    os.remove('qrcode'+str(x)+'.jpg')
    if (x == 3) and (len(priv) > 4):       #wrapped onto the 2nd page..
        pdf.add_page()
        pdf.image('light2.jpg',0,0,210,297)
        pdf.set_font_size(20)
        pdf.cell (0, 10,str(mkeys)+'-of-'+str(nkeys)+': multisignature bitcoin paper wallet %s / page 2' % addr_multi[:6] ,1,1,'C')
        pdf.set_font_size(13)
        h_qr = -10

pdf.set_font('Times',"",10)
pdf.multi_cell(0, 5, 'multisig script: ' + script,1,1)
im, im_h, im_w = qrc(script)
img = Image.new( 'RGB', (im_w,im_h), "white")
img.paste(im,(0,0))
ran=random_key()
img.save('qrcode' + ran + '.jpg')
pdf.image('qrcode' + ran + '.jpg',80,240,50,50)
os.remove('qrcode'+ ran +'.jpg')
os.mkdir( addr_multi[:6] )
pdf.output( addr_multi[:6] + '/' + addr_multi + '-all-keys.pdf','F')

print 'Do you want wallet file in distributable fragments?(enter for yes, all other input = no)'
dist=raw_input()
if not dist:
    print '>>>Producing separate wallets for each private key'
    for x in range(len(priv)):
示例#56
0
    def ImrimirPDF(self, saleId,IMPRIMIRr):
	# Obtener los datos de la base de datos (datos de la venta y los elementos)
	datos = db.Salerecord(saleId)
	# guardar los datos de la venta en datos_sale
	datos_sale  = datos[0]
	#Guardar los datos de los elementos de la venta en datos_items 
	datos_items = datos[1]
	# Formatear el numero de la venta (ej: 0000000023)
	facturaNumero = str(("0"*(10-len(str(saleId))))+str(saleId))
	# Obtener los datos de la tienda/empresa desde la base de datos
	Datos = db.SelectConfigNS()
	pdf = FPDF()
	pdf.add_page()
	MargL = 70
	if IMPRIMIRr:
            MargT = 20
        else:
            MargT = 5
#	pdf.add_font('FangSong',"")
	pdf.set_font('Courier', 'B', 8.5)
	pdf.set_xy(MargL, MargT)
	pdf.cell(ln=0, h=5.0, align='C', w=60.0, txt=Datos[1], border=0)
	pdf.set_font('Courier', '', 8.5)
	MargT = MargT+2.5
	pdf.set_xy(MargL, MargT)
	pdf.cell(ln=0, h=5.0, align='C', w=60.0, txt=Datos[2], border=0)
	MargT = MargT+4
	pdf.set_xy(MargL, MargT)
	pdf.cell(ln=0, h=4.0, align='C', w=60.0, txt="NIT: "+str(Datos[8]), border=0)
	MargT = MargT+3
	pdf.set_xy(MargL, MargT)
	pdf.multi_cell(h=3, align='C', w=60.0, txt=Datos[5], border=0, )
	MargT = MargT+5
	pdf.set_xy(MargL, MargT)
	pdf.cell(ln=0, h=4.0, align='C', w=60.0, txt="E-mail: "+Datos[7], border=0)
	MargT = MargT+3
	pdf.set_xy(MargL, MargT)
	pdf.cell(ln=0, h=4.0, align='C', w=60.0, txt="Tel: "+str(Datos[3]), border=0)
	MargT = MargT+3 #25.5
	pdf.set_xy(MargL, MargT)
	pdf.cell(ln=0, h=4.0, align='C', w=60.0, txt="Web: "+str(Datos[4]), border=0)
	MargT = MargT+1 #26.5
	pdf.set_xy(MargL, MargT)
	pdf.cell(ln=0, h=7.4, align='C', w=60.0, txt='Fecha: '+str(datos_sale[1]), border=0)
	nombre = ""
	for i in datos_sale[3].split(" "): nombre = nombre+i.capitalize()+" "
	MargT = MargT+2 #28.5
	pdf.set_xy(MargL, MargT)
	pdf.cell(ln=0, h=9.5, align='C', w=60.0, txt='Comprobante N\xba: '+str(facturaNumero), border=0)
	MargT = MargT+6 #34.5
	pdf.set_xy(MargL, MargT)
	pdf.set_font('Arial', '', 9.0)
	pdf.cell(ln=0, h=6.0, align='L', w=60.0, txt='Cliente: '+nombre.decode("utf8"), border=0)
	MargT = MargT+2.5 #35.0
	pdf.set_xy(MargL, MargT)
	pdf.set_font('Courier', '', 9.0)
	pdf.cell(ln=0, h=6.0, align='L', w=60.0, txt='Nit: '+str(datos_sale[5].upper()), border=0)

	#Titulos para los productos
	pdf.set_font('Courier', 'B', 9.0)
	MargT = MargT+6.5 #41.5
	pdf.set_xy(MargL, MargT)
	pdf.cell(ln=0, h=5.0, align='L', w=20.0, txt='Codigo', border=0)
	pdf.set_xy(MargL+20, MargT)
	pdf.cell(ln=0, h=5.0, align='L', w=20.0, txt='Producto', border=0)
	pdf.set_xy(MargL+41, MargT)
	pdf.cell(ln=0, h=5.0, align='L', w=13.0, txt='Cant.', border=0)
	pdf.set_xy(MargL+50.5, MargT)
	pdf.cell(ln=0, h=5.0, align='R', w=14.0, txt=' Total', border=0)
	pdf.set_font('Courier', '', 9.0)
	MargT = MargT+4 #45.5
	pdf.line(MargL, MargT, MargL+68, MargT)

	# TOTAL DE LA VENTA
	#pdf.cell(ln=0, h=6.0, align='C', w=18.0, txt='Total:', border=0)
	#pdf.set_xy(MargL, 69.0)
	#pdf.cell(ln=0, h=6.0, align='C', w=80.0, txt=self.formatCant(datos_sale[2]), border=0)

	#Productos
	lineaN = MargT-1 #44.5
	for elemento in datos_items:
		pdf.set_xy(MargL, lineaN)
		if len(elemento[6]) > 10:
                    pdf.cell(ln=0, h=5.0, align='L', w=20.0, txt=elemento[6][0:10], border=0)
                else:
                    pdf.cell(ln=0, h=5.0, align='L', w=20.0, txt=elemento[6], border=0)
		pdf.set_xy(MargL+20, lineaN)
		if len(elemento[5]) > 12:
			pdf.cell(ln=0, h=5.0, align='L', w=20.0, txt=elemento[5][0:12], border=0)
		else:
			pdf.cell(ln=0, h=5.0, align='L', w=20.0, txt=elemento[5], border=0)
		pdf.set_xy(MargL+45, lineaN)
		pdf.cell(ln=0, h=5.0, align='L', w=10.0, txt=str(elemento[4]), border=0)
		pdf.set_xy(MargL+50.5, lineaN)
		pdf.cell(ln=0, h=5.0, align='L', w=5.0, txt="Q ", border=0)
		pdf.set_font('Courier', '', 6.0)
		pdf.cell(ln=0, h=5.0, align='R', w=14.0, txt=str(self.formatCant(elemento[3]*elemento[4])), border=0)
		pdf.set_font('Courier', '', 9.0)
		lineaN = lineaN+3
	pdf.line(MargL, lineaN+1, MargL+68, lineaN+1)

	
        #Subtotal, IVA y Total
	pdf.set_xy(MargL, lineaN)
	pdf.cell(ln=0, h=9.0, align='L', w=60.0, txt='Subtotal: Q ', border=0)
	pdf.set_xy(MargL, lineaN+2.5)
	pdf.cell(ln=0, h=9.0, align='L', w=60.0, txt='IVA:      Q ', border=0)
	pdf.set_xy(MargL, lineaN+5)
	pdf.cell(ln=0, h=9.0, align='L', w=60.0, txt='Total:    Q ', border=0)

	pdf.set_xy(MargL+20.5, lineaN)
	pdf.cell(ln=0, h=9.0, align='R', w=22.0, txt=str(self.TSep(self.formatCant((datos_sale[2]-datos_sale[6])))), border=0)
	pdf.set_xy(MargL+20.5, lineaN+2.5)
	pdf.cell(ln=0, h=9.0, align='R', w=22.0, txt=str(self.TSep(self.formatCant(datos_sale[6]))), border=0)
	pdf.set_xy(MargL+20.5, lineaN+5)
	pdf.cell(ln=0, h=9.0, align='R', w=22.0, txt=str(self.TSep(self.formatCant(datos_sale[2]))), border=0)
	
	pdf.output('invoice.pdf', 'F')
	print
	print
	print
	print
	print "Imprimir?  "+str(IMPRIMIRr)
	print
	print
	print
	if IMPRIMIRr:
            pc = os.name
            filename = "invoice.pdf"
            if pc == 'posix' :
                os.system ('lp -q100 ' + filename)
            elif pc == 'nt' :
                import win32api
                win32api.ShellExecute(0, 'print', filename, None, '.', 0)
            else:
                print "El sistema operativo no es NT ni POSIX"
        else:
            if sys.platform.startswith("linux"):
                    os.system("evince ./invoice.pdf")
            else:
                    #os.system("invoice.pdf")
                    import subprocess
                    p = subprocess.Popen("invoice.pdf", shell=True, bufsize=255, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)