Exemplo n.º 1
0
def images_to_pdf(pdfName="newPdf.pdf", fitSize=True):
    '''list files(images) from current dir and save it as pdf'''
    files = [
        file for file in os.listdir()
        if file.endswith(('.png', '.jpg', '.jpeg', '.jp2'))
    ]
    files.sort()

    #make pdf (think about 2 images on 1 page vs 1 img on 1 page)
    pdf = FPDF(orientation="P", unit="mm",
               format="A4")  #orientation -> L/P, A4 -> 210x297
    for key, image in enumerate(files):
        pdf.add_page()
        # pdf.line(5, 287, 205, 287)
        cover = Image.open(image)
        if fitSize:
            '''auto resize and position setting'''
            width, height = cover.size
            if width / height > 210 / 297:
                maxFactor = math.trunc((210 / width) * 10000) / 10000
            elif width / height < 210 / 297:
                maxFactor = math.trunc((297 / height) * 10000) / 10000
            else:
                maxFactor = math.trunc((297 / height) * 10000) / 10000
            # print(maxFactor)
            xMove = math.trunc((210 - width * maxFactor) / 2)
            yMove = math.trunc((297 - height * maxFactor) / 2)
            pdf.image(image, xMove, yMove, width * maxFactor,
                      height * maxFactor)
        else:
            pdf.image(image, 0, 0, 0, 0)
    pdf.set_display_mode(zoom="fullpage", layout="two")
    pdf.set_creator("streanger")
    pdf.output(pdfName, "F")
    return True
Exemplo n.º 2
0
def main():
    """
    Entry-point for the function.
    """
    pdf = FPDF()
    pdf.set_display_mode('fullwidth')
    pdf.set_creator('Cavin Dsouza')
    pdf.set_author('bizarro')
    scrape(pdf)
    pdf.output("bizarro.pdf", "F")
    print("PDF created successfully.")
Exemplo n.º 3
0
def test_setting_all_layout(layout, tmp_path):
    """This test executes some possible inputs to FPDF#set_display_mode."""
    doc = FPDF()
    doc.add_page()
    doc.set_font("helvetica", size=12)
    doc.cell(
        w=72,
        h=0,
        border=1,
        txt="hello world",
        fill=False,
        link="",
        new_x=XPos.LMARGIN,
        new_y=YPos.NEXT,
    )
    doc.set_display_mode(zoom="default", layout=layout)
    assert_pdf_equal(doc, HERE / f"layout-{layout}.pdf", tmp_path)
Exemplo n.º 4
0
def write_to_pdf(pubmed_results, style_method: str, query: str) -> None:
    """Write the PubMed results to PDF


    Parameters
    ----------
    pubmed_results: PubMed results stored in Bio.Entrez.Parser.ListElement

    style_method: the style to be written to a PDF file
    (citation or listview)

    query: a query to be searched against PubMed database

    Return
    -------
    None
    """

    pdf_doc = FPDF()

    pdf_doc.add_page()

    # add font
    pdf_doc.add_font("NotoSans", style="",
                     fname="NotoSans-Regular.ttf",
                     uni=True)

    # setting the font name and size
    pdf_doc.set_font("NotoSans", size=12)

    # configure the header of the PDF document
    pdf_doc.cell(200, 20, txt=f"Search Results for {query.title()}",
                 ln=1, align='C')

    pdf_doc.set_display_mode(zoom='real')

    records = records_iterator(pubmed_results)

    for i, (authors, title, journal, *pub_info) in enumerate(records, 1):

        pub_date, vol_issue, doi, pmid, pmcid = pub_info

        if style_method == 'citation':

            # the following add the information retrieved from the PubMed
            # results
            pdf_doc.multi_cell(180, 7, txt=str(i) + ': ' +
                                           authors + '. ' +
                                           title + ' ' +
                                           journal + '. ' +
                                           pub_date + ';' +
                                           vol_issue + '. ' +
                                           doi + '. ' +
                                           pmid + '; ' +
                                           pmcid + '.')

            # add line break
            pdf_doc.ln(h='2')

        # selecting the other style "the listview"
        else:

            pdf_doc.multi_cell(180, 7, txt=str(i) + ': ' + "Authors: " +
                                           authors)

            pdf_doc.multi_cell(180, 7, txt="Title: " + title)

            pdf_doc.cell(90, 7, txt="Journal Name: " + journal,
                         ln=1,
                         align='L')

            pdf_doc.cell(50, 7, txt="Publication Date: " +
                                    pub_date,
                         ln=2,
                         align='L')

            pdf_doc.cell(50, 7, txt="Volume, Issue, pages: " + vol_issue,
                         ln=2,
                         align='L')

            pdf_doc.cell(50, 7, txt=doi, ln=1, align='L')

            pdf_doc.cell(50, 7, txt=pmid, ln=2, align='L')

            pdf_doc.cell(50, 7, txt=pmcid, ln=2, align='L')

            pdf_doc.ln(h='2')

    # write the information above to MS Word file
    print("\nwriting to a PDF file...")
    pdf_doc.output('output/PubMed_Results.pdf')
    print("\nDone writing.")
Exemplo n.º 5
0
def write_to_pdf(pubmed_results, style_method: str, query: str,
                 is_abstract: bool) -> None:
    """Write the PubMed results to PDF

    Parameters
    ----------
    pubmed_results: PubMed results stored in Bio.Entrez.Parser.ListElement

    style_method: the style to be written to a PDF file
    (citation or listview)

    query: a query to be searched against PubMed database

    is_abstract: include abstract to your search results

    Return
    -------
    None
    """

    pdf_doc = FPDF()

    pdf_doc.add_page()

    # add font
    pdf_doc.add_font("NotoSans",
                     style="",
                     fname="NotoSans-Regular.ttf",
                     uni=True)

    # setting the font name and size
    pdf_doc.set_font("NotoSans", size=12)

    # configure the header of the PDF document
    pdf_doc.cell(200,
                 20,
                 txt=f"Search Results for {query.title()}",
                 ln=1,
                 align='C')

    pdf_doc.set_display_mode(zoom='real')

    records = records_iterator(pubmed_results, is_abstract)

    for i, (authors, title, journal, *pub_info) in enumerate(records, 1):
        try:
            pub_date, vol_issue, doi, pmid, pmcid, abstract = pub_info
        except ValueError:
            pub_date, vol_issue, doi, pmid, pmcid = pub_info

        url = f"http://www.ncbi.nlm.nih.gov/pubmed/" + pmid.split()[-1]

        if style_method == 'citation':
            # the following add the information retrieved from the PubMed
            # results
            pdf_doc.set_text_color(0, 0, 0)
            pdf_doc.multi_cell(180,
                               7,
                               txt=str(i) + ': ' + authors + '. ' + title +
                               ' ' + journal + '. ' + pub_date + ';' +
                               vol_issue + " doi" + doi + ' ' + pmid + '; ' +
                               pmcid + '. ' + url + '.')
            pdf_doc.set_text_color(0, 0, 255)

            # add line break
            pdf_doc.ln(h='2')

        # selecting the other style "the listview"
        else:
            pdf_doc.set_text_color(0, 0, 0)
            pdf_doc.multi_cell(180,
                               7,
                               txt=str(i) + ': ' + "Authors: " + authors)

            pdf_doc.multi_cell(180, 7, txt="Title: " + title)

            pdf_doc.cell(90,
                         7,
                         txt="Journal Name: " + journal,
                         ln=1,
                         align='L')

            pdf_doc.cell(50,
                         7,
                         txt="Publication Date: " + pub_date,
                         ln=2,
                         align='L')

            pdf_doc.cell(50,
                         7,
                         txt="Volume, Issue, pages: " + vol_issue,
                         ln=2,
                         align='L')

            pdf_doc.cell(50, 7, txt="doi" + doi, ln=1, align='L')

            pdf_doc.cell(50, 7, txt=pmid, ln=2, align='L')

            pdf_doc.cell(50, 7, txt=pmcid, ln=2, align='L')

            pdf_doc.cell(50, 7, txt="url: " + url, ln=9, align='L')

            try:
                pdf_doc.multi_cell(190,
                                   7,
                                   txt="Abstract: " + abstract,
                                   align='L')
            except UnboundLocalError:
                pdf_doc.ln(h='2')
                continue

            pdf_doc.ln(h='2')

    # write the information above to PDF file
    print("\nwriting to a PDF file...")
    pdf_doc.output('output/PubMed_Results.pdf')
    print("\nDone writing.")
Exemplo n.º 6
0
Arquivo: mo.py Projeto: alin-c/mo.py
* indicarea părții este opțională doar dacă se caută un număr din Partea I

Exemple de utilizare:
1. 1/414/2017 echivalent cu 414/2017 => Partea I, nr. 414 din 2017
2. 4/2378/2019 => Partea a IV-a, nr. 2378 din 2019
3. 2/17c/2019 => Partea a II-a, nr. 17/C din 2019
*********************************************************************************************
"""
print(__doc__) #comment this line to supress the manifest

import requests, re, sys, os, platform, tempfile
from fpdf import FPDF

#set up the fpdf object
pdf = FPDF('P', 'mm', 'A4')
pdf.set_display_mode('real', 'continuous')

#set the working folder paths
system = platform.system()
if system == 'Windows':
	file_location = tempfile.gettempdir() + "\\"
	pdf_location = os.path.join(
	    os.path.join(os.environ['USERPROFILE']), 'Desktop') + "\\"
elif system == 'Linux' or system == 'Darwin':
	file_location = tempfile.gettempdir() + "/"
	pdf_location = os.path.join(os.path.join(os.path.expanduser('~')),
	                            'Desktop') + "/"
	if not os.path.exists(pdf_location): #useful for Android running in qpython
		pdf_location = '/sdcard/' #assume there is such a folder; I won't bother to really check further for writeable folder...
else:
	print("Sistem de operare necunoscut. Programul nu poate continua.")
Exemplo n.º 7
0
def create_form1(personal_info, skills, languages, sum_text, work_experience,
                 education, awards, font):
    pdf = FPDF()
    pdf.add_page()
    '''HEADER'''
    pdf.set_font("Times", size=25, style="B")
    pdf.set_fill_color(16, 78, 139)
    pdf.set_text_color(255, 255, 255)
    pdf.cell(0, 10, " " + personal_info[0], fill=True, ln=1)
    pdf.set_font("courier", size=15, style="B")

    pdf.set_text_color(255, 255, 255)
    pdf.cell(0, 10, " " + personal_info[1], fill=True, ln=2)
    '''PERSONAL INFO'''
    pdf.set_xy(140, 30)
    pdf.set_font("arial", size=18, style="B")
    pdf.set_text_color(28, 28, 28)
    pdf.set_fill_color(141, 238, 238)
    pdf.cell(0, 15, "Personal Info", fill=True, ln=1)

    pdf.set_draw_color(128, 128, 128)
    pdf.line(140, 42, 190, 42)

    pdf.set_xy(140, pdf.get_y())
    pdf.set_font("arial", size=14, style="B")
    pdf.set_text_color(0, 0, 0)
    pdf.set_fill_color(141, 238, 238)
    pdf.cell(0, 10, "Address", fill=True, ln=1)
    pdf.set_xy(140, pdf.get_y())
    pdf.set_font("arial", size=12)
    pdf.set_text_color(99, 99, 99)
    pdf.cell(0,
             6,
             personal_info[2][0] + "_" + personal_info[2][1],
             fill=True,
             ln=1)
    pdf.set_xy(140, pdf.get_y())
    pdf.cell(0, 6, personal_info[2][2], fill=True, ln=1)
    pdf.set_xy(140, pdf.get_y())
    pdf.cell(0, 6, personal_info[2][3], fill=True, ln=1)

    pdf.set_xy(140, pdf.get_y())
    pdf.set_font("arial", size=14, style="B")
    pdf.set_text_color(0, 0, 0)
    pdf.set_fill_color(141, 238, 238)
    pdf.cell(0, 10, "Phone", fill=True, ln=1)
    pdf.set_xy(140, pdf.get_y())
    pdf.set_font("arial", size=12)
    pdf.set_text_color(99, 99, 99)
    pdf.cell(0, 6, personal_info[3], fill=True, ln=1)

    pdf.set_xy(140, pdf.get_y())
    pdf.set_font("arial", size=14, style="B")
    pdf.set_text_color(0, 0, 0)
    pdf.set_fill_color(141, 238, 238)
    pdf.cell(0, 10, "E_mail", fill=True, ln=1)
    pdf.set_xy(140, pdf.get_y())
    pdf.set_font("arial", size=12)
    pdf.set_text_color(99, 99, 99)
    pdf.cell(0, 6, personal_info[4], fill=True, ln=1)

    pdf.set_xy(140, pdf.get_y())
    pdf.set_font("arial", size=14, style="B")
    pdf.set_text_color(0, 0, 0)
    pdf.set_fill_color(141, 238, 238)
    pdf.cell(0, 10, "Github", fill=True, ln=1)
    for i in range(len(personal_info[5]) - 1):
        link = "http://github/" + personal_info[5][0] + "/" + personal_info[5][
            i + 1]
        pdf.set_xy(140, pdf.get_y())
        pdf.set_font("arial", size=12)
        pdf.set_text_color(99, 99, 99)
        pdf.cell(0, 6, personal_info[5][i + 1], fill=True, ln=1, link=link)
    '''SKILLS'''
    pdf.set_xy(140, pdf.get_y())
    pdf.set_font("arial", size=18, style="B")
    pdf.set_text_color(28, 28, 28)
    pdf.set_fill_color(141, 238, 238)
    pdf.cell(0, 15, "Skills", fill=True, ln=1)

    pdf.set_draw_color(128, 128, 128)
    pdf.line(140, pdf.get_y() - 4, 190, pdf.get_y() - 4)

    for i in range(len(skills[0])):
        pdf.set_fill_color(141, 238, 238)
        pdf.set_xy(140, pdf.get_y())
        pdf.set_font("arial", size=14)
        pdf.set_text_color(99, 99, 99)
        pdf.cell(0, 15, skills[0][i], fill=True, ln=1)
        x = 170
        for j in range(5):
            if j < skills[1][i]:
                pdf.set_fill_color(0, 0, 139)
                pdf.ellipse(x, pdf.get_y() - 5, 4, 4, style="F")
            else:
                pdf.set_fill_color(255, 255, 255)
                pdf.ellipse(x, pdf.get_y() - 5, 4, 4, style="F")
            x = x + 5
    '''LANGUAGES'''
    pdf.set_xy(140, pdf.get_y())
    pdf.set_font("arial", size=18, style="B")
    pdf.set_text_color(28, 28, 28)
    pdf.set_fill_color(141, 238, 238)
    pdf.cell(0, 15, "Languages", fill=True, ln=1)

    pdf.set_draw_color(128, 128, 128)
    pdf.line(140, pdf.get_y() - 3, 190, pdf.get_y() - 3)

    for i in range(len(languages[0])):
        pdf.set_fill_color(141, 238, 238)
        pdf.set_xy(140, pdf.get_y())
        pdf.set_font("arial", size=14)
        pdf.set_text_color(99, 99, 99)
        pdf.cell(0, 15, languages[0][i], fill=True, ln=1)
        x = 170
        for j in range(5):
            if j < languages[1][i]:
                pdf.set_fill_color(0, 0, 139)
                pdf.ellipse(x, pdf.get_y() - 5, 4, 4, style="F")
            else:
                pdf.set_fill_color(255, 255, 255)
                pdf.ellipse(x, pdf.get_y() - 5, 4, 4, style="F")
            x = x + 5

    pdf.set_xy(140, pdf.get_y())
    pdf.set_fill_color(141, 238, 238)
    pdf.cell(0, 15, "", fill=True, ln=1)
    '''SUMMARY TEXT'''
    x = 10
    y = 34
    pdf.set_font(font[0], size=font[1])
    pdf.set_text_color(128, 128, 128)
    for i in range(len(sum_text)):
        if i == 0:
            pass
        else:
            if x + pdf.get_string_width(sum_text[i]) > 115:
                x = 10
                y = y + font[1] / 2
            else:
                x = x + pdf.get_string_width(sum_text[i - 1]) + 2

        pdf.set_xy(x, y)
        pdf.cell(
            pdf.get_string_width(sum_text[i]) + 1, 5, sum_text[i], 0, 1, "C")
    '''WORK EXPERIENCE'''
    pdf.set_xy(10, pdf.get_y())
    pdf.set_font("arial", size=16)
    pdf.set_text_color(0, 0, 0)
    pdf.cell(20, 20, "Work Experience", fill=False, ln=1)

    pdf.set_draw_color(128, 128, 128)
    pdf.line(10, pdf.get_y() - 5, 130, pdf.get_y() - 5)

    for i in range(len(work_experience[1])):
        pdf.set_xy(10, pdf.get_y())
        pdf.set_font(font[0], size=font[1], style="B")
        pdf.set_text_color(0, 0, 0)
        pdf.cell(20, 10, work_experience[0][i], fill=False, ln=1)
        pdf.set_xy(40, pdf.get_y() - 10)
        pdf.cell(20, 10, work_experience[1][i], fill=False, ln=1)
        x = 40
        y = pdf.get_y()
        pdf.set_font(font[0], size=font[1])
        pdf.set_text_color(128, 128, 128)
        for j in range(len(work_experience[2][i])):
            if j == 0:
                pass
            else:
                if x + pdf.get_string_width(work_experience[2][i][j]) > 115:
                    x = 40
                    y = y + font[1] / 2
                else:
                    x = x + pdf.get_string_width(
                        work_experience[2][i][j - 1]) + 2

            pdf.set_xy(x, y)
            pdf.cell(
                pdf.get_string_width(work_experience[2][i][j]) + 1, 5,
                work_experience[2][i][j], 0, 1, "C")
    '''EDUCATION'''
    pdf.set_xy(10, pdf.get_y())
    pdf.set_font("arial", size=16)
    pdf.set_text_color(0, 0, 0)
    pdf.cell(20, 20, "Education", fill=False, ln=1)

    pdf.set_draw_color(128, 128, 128)
    pdf.line(10, pdf.get_y() - 5, 130, pdf.get_y() - 5)

    for i in range(len(education[1])):
        pdf.set_xy(10, pdf.get_y())
        pdf.set_font(font[0], size=font[1], style="B")
        pdf.set_text_color(0, 0, 0)
        pdf.cell(20, 10, education[0][i], fill=False, ln=1)
        pdf.set_xy(40, pdf.get_y() - 10)
        pdf.cell(20, 10, education[1][i], fill=False, ln=1)
        pdf.set_xy(40, pdf.get_y() - 3)
        pdf.cell(20, 10, "GPA  " + education[2][i], fill=False, ln=1)
        x = 40
        y = pdf.get_y()
        pdf.set_font(font[0], size=font[1])
        pdf.set_text_color(128, 128, 128)
        for j in range(len(education[3][i])):
            if j == 0:
                pass
            else:
                if x + pdf.get_string_width(education[3][i][j]) > 115:
                    x = 40
                    y = y + font[1] / 2
                else:
                    x = x + pdf.get_string_width(education[3][i][j - 1]) + 2

            pdf.set_xy(x, y)
            pdf.cell(
                pdf.get_string_width(education[3][i][j]) + 1, 5,
                education[3][i][j], 0, 1, "C")
    '''AWARDS AND HONORS'''
    pdf.set_xy(10, pdf.get_y())
    pdf.set_font("arial", size=16)
    pdf.set_text_color(0, 0, 0)
    pdf.cell(20, 20, "Awards and Honors", fill=False, ln=1)

    pdf.set_draw_color(128, 128, 128)
    pdf.line(10, pdf.get_y() - 5, 130, pdf.get_y() - 5)

    for i in range(len(awards[1])):
        pdf.set_xy(10, pdf.get_y())
        pdf.set_font(font[0], size=font[1], style="B")
        pdf.set_text_color(0, 0, 0)
        pdf.cell(20, 5, awards[0][i], fill=False, ln=1)
        pdf.set_font(font[0], size=font[1])
        pdf.set_text_color(128, 128, 128)
        pdf.set_xy(40, pdf.get_y() - 5)
        pdf.cell(20, 5, awards[1][i], fill=False, ln=1)

    pdf.set_display_mode("fullpage")
    pdf.output(f"{name}_form1.pdf")
Exemplo n.º 8
0
def create_form3(personal_info,skill,languages,work_experience,education,font):
    pdf = FPDF()
    pdf.add_page()
    '''HEADER'''
    pdf.set_xy(10,0)
    pdf.set_font("Times", size=25, style="B")
    pdf.set_text_color(0, 0, 0)
    pdf.set_fill_color(255,128,0)
    pdf.cell(80, 10, fill=True, ln=1)

    pdf.set_xy(29,19)
    pdf.set_font("Times", size=25, style="B")
    pdf.set_text_color(0, 0, 0)
    pdf.set_fill_color(255, 128, 0)
    pdf.cell(42, 42, fill=True, ln=1)

    pdf.set_xy(30,20)
    pdf.image(personal_info[0], w=40, h=40)

    '''NAME AND FIELD'''
    pdf.set_xy(120, 30)
    pdf.set_font("Times", size=25, style="B")
    pdf.set_text_color(0, 0, 0)
    pdf.set_fill_color(255, 255, 255)
    pdf.cell(20, 10, personal_info[1], fill=True, ln=1)
    pdf.set_xy(120, 40)
    pdf.set_text_color(255, 128, 0)
    pdf.set_font("courier", size=15, style="B")
    pdf.cell(0, 10, personal_info[2], fill=True, ln=1, align="L")

    '''ABOUT ME'''
    pdf.set_xy(10,70)
    pdf.set_font("arial", size=15, style="B")
    pdf.set_text_color(0, 0, 0)
    pdf.set_fill_color(255, 255, 255)
    pdf.cell(80, 10, "ABOUT ME", fill=True, ln=1,align="C")

    pdf.set_line_width(1)
    pdf.set_draw_color(132,132,132)
    pdf.line(15, 80,43,80)

    pdf.set_line_width(1)
    pdf.set_draw_color(255, 128, 0)
    pdf.line(43, 80, 57, 80)

    pdf.set_line_width(1)
    pdf.set_draw_color(132, 132, 132)
    pdf.line(57, 80, 85, 80)

    x = 15
    y = pdf.get_y()+5
    pdf.set_font(font[0], size=font[1])
    pdf.set_text_color(128, 128, 128)
    for j in range(len(personal_info[3])):
        if j == 0:
            pass
        else:
            if x + pdf.get_string_width(personal_info[3][j]) > 80:
                x = 15
                y = y + font[1] / 2
            else:
                x = x + pdf.get_string_width(personal_info[3][j - 1]) + 2

        pdf.set_xy(x, y)
        pdf.cell(pdf.get_string_width(personal_info[3][j]) + 1, 5, personal_info[3][j], 0, 1, "C")


    '''CONTACT'''
    pdf.set_xy(10, pdf.get_y()+5)
    pdf.set_font("arial", size=15, style="B")
    pdf.set_text_color(0, 0, 0)
    pdf.set_fill_color(255, 255, 255)
    pdf.cell(80, 10, "CONTACT", fill=True, ln=1, align="C")

    pdf.set_line_width(1)
    pdf.set_draw_color(132, 132, 132)
    pdf.line(15, pdf.get_y(), 43, pdf.get_y())

    pdf.set_line_width(1)
    pdf.set_draw_color(255, 128, 0)
    pdf.line(43, pdf.get_y(), 57, pdf.get_y())

    pdf.set_line_width(1)
    pdf.set_draw_color(132, 132, 132)
    pdf.line(57, pdf.get_y(), 85, pdf.get_y())

    pdf.set_xy(15,pdf.get_y() + 3)
    pdf.set_font("times", size=15)
    pdf.set_text_color(0,0,0)
    pdf.set_fill_color(255, 255, 255)
    pdf.cell(20, 5, "Address", fill=True, ln=1)
    pdf.set_text_color(132,132,132)
    pdf.set_xy(15, pdf.get_y())
    pdf.cell(20, 5, personal_info[4], fill=True, ln=1)

    pdf.set_xy(15, pdf.get_y() + 3)
    pdf.set_font("times", size=15)
    pdf.set_text_color(0, 0, 0)
    pdf.set_fill_color(255, 255, 255)
    pdf.cell(20, 5, "Phone", fill=True, ln=1)
    pdf.set_text_color(132, 132, 132)
    pdf.set_xy(15, pdf.get_y())
    pdf.cell(20, 5, personal_info[5], fill=True, ln=1)

    pdf.set_xy(15, pdf.get_y() + 3)
    pdf.set_font("times", size=15)
    pdf.set_text_color(0, 0, 0)
    pdf.set_fill_color(255, 255, 255)
    pdf.cell(20, 5, "E-Mail", fill=True, ln=1)
    pdf.set_text_color(132, 132, 132)
    pdf.set_xy(15, pdf.get_y())
    pdf.cell(20, 5, personal_info[6], fill=True, ln=1)

    pdf.set_xy(15, pdf.get_y() + 3)
    pdf.set_font("times", size=15)
    pdf.set_text_color(0, 0, 0)
    pdf.set_fill_color(255, 255, 255)
    pdf.cell(20, 5, "WebSite", fill=True, ln=1)
    pdf.set_text_color(132, 132, 132)
    pdf.set_xy(15, pdf.get_y())
    pdf.cell(20, 5, personal_info[7], fill=True, ln=1)

    '''LANGUAGES'''
    pdf.set_xy(10, pdf.get_y() + 5)
    pdf.set_font("arial", size=15, style="B")
    pdf.set_text_color(0, 0, 0)
    pdf.set_fill_color(255, 255, 255)
    pdf.cell(80, 10, "LANGUAGES", fill=True, ln=1, align="C")

    pdf.set_line_width(1)
    pdf.set_draw_color(132, 132, 132)
    pdf.line(15, pdf.get_y(), 43, pdf.get_y())

    pdf.set_line_width(1)
    pdf.set_draw_color(255, 128, 0)
    pdf.line(43, pdf.get_y(), 57, pdf.get_y())

    pdf.set_line_width(1)
    pdf.set_draw_color(132, 132, 132)
    pdf.line(57, pdf.get_y(), 85, pdf.get_y())

    for i in range(len(languages[0])):
        pdf.set_xy(15, pdf.get_y() + 5)
        pdf.set_font("times", size=15)
        pdf.set_text_color(0, 0, 0)
        pdf.set_fill_color(255, 255, 255)
        pdf.cell(20, 5, languages[0][i], fill=True, ln=1)

        pdf.set_line_width(1)
        pdf.set_draw_color(0,0,128)
        pdf.line(15, pdf.get_y() + 2, languages[1][i] * 7 + 15, pdf.get_y() + 2)

        pdf.set_line_width(1)
        pdf.set_draw_color(132, 132, 132)
        pdf.line(languages[1][i] * 7 + 15, pdf.get_y() + 2, 85, pdf.get_y() + 2)

    '''SKILLS'''
    pdf.set_xy(10, pdf.get_y() + 5)
    pdf.set_font("arial", size=15, style="B")
    pdf.set_text_color(0, 0, 0)
    pdf.set_fill_color(255, 255, 255)
    pdf.cell(80, 10, "SKILLS", fill=True, ln=1, align="C")

    pdf.set_line_width(1)
    pdf.set_draw_color(132, 132, 132)
    pdf.line(15, pdf.get_y(), 43, pdf.get_y())

    pdf.set_line_width(1)
    pdf.set_draw_color(255, 128, 0)
    pdf.line(43, pdf.get_y(), 57, pdf.get_y())

    pdf.set_line_width(1)
    pdf.set_draw_color(132, 132, 132)
    pdf.line(57, pdf.get_y(), 85, pdf.get_y())

    for i in range(len(skill[0])):
        pdf.set_xy(15, pdf.get_y() + 5)
        pdf.set_font("times", size=15)
        pdf.set_text_color(0, 0, 0)
        pdf.set_fill_color(255, 255, 255)
        pdf.cell(20, 5,skill[0][i], fill=True, ln=1)

        pdf.set_line_width(1)
        pdf.set_draw_color(0,0,128)
        pdf.line(15, pdf.get_y()+2, skill[1][i]*7 + 15, pdf.get_y()+2)

        pdf.set_line_width(1)
        pdf.set_draw_color(132, 132, 132)
        pdf.line(skill[1][i]*7 + 15, pdf.get_y()+2, 85, pdf.get_y()+2)

    '''WORK EXPERIENCE'''
    pdf.set_xy(100, 70)
    pdf.set_font("arial", size=15, style="B")
    pdf.set_text_color(0, 0, 0)
    pdf.set_fill_color(255, 255, 255)
    pdf.cell(80, 10, "WORK EXPERIENCE", fill=True, ln=1, align="L")

    pdf.set_line_width(1)
    pdf.set_draw_color(255, 128, 0)
    pdf.line(100, 80, 114, 80)

    pdf.set_line_width(1)
    pdf.set_draw_color(132, 132, 132)
    pdf.line(114, 80, 200, 80)

    for i in range(len(work_experience[1])):
        pdf.set_xy(100,pdf.get_y()+3)
        pdf.set_font(font[0], size=font[1]+2,style="B")
        pdf.set_text_color(0, 0, 0)
        pdf.cell(20, 10, work_experience[1][i], fill=False, ln=1)
        pdf.set_xy(155, pdf.get_y() - 7)
        pdf.set_font(font[0], size=font[1])
        pdf.cell(25, 5, work_experience[2][i], fill=True, ln=1)
        pdf.set_xy(100, pdf.get_y() + 3)
        pdf.set_text_color(128, 128, 128)
        pdf.set_font(font[0], size=font[1])
        pdf.cell(20, 6, work_experience[0][i], fill=False, ln=1)
        x = 155
        y = pdf.get_y() - 6
        pdf.set_font(font[0], size=font[1])
        for j in range(len(work_experience[3][i])):
            if j == 0:
                pass
            else:
                if x + pdf.get_string_width(work_experience[3][i][j]) > 200:
                    x = 155
                    y = y + font[1] / 2
                else:
                    x = x + pdf.get_string_width(work_experience[3][i][j - 1]) + 2

            pdf.set_xy(x, y)
            pdf.cell(pdf.get_string_width(work_experience[3][i][j]) + 1, 5, work_experience[3][i][j], 0, 1, "C")

    '''EDUCATION'''
    pdf.set_xy(100, pdf.get_y())
    pdf.set_font("arial", size=15, style="B")
    pdf.set_text_color(0, 0, 0)
    pdf.set_fill_color(255, 255, 255)
    pdf.cell(80, 10, "EDUCATION", fill=True, ln=1, align="L")

    pdf.set_line_width(1)
    pdf.set_draw_color(255, 128, 0)
    pdf.line(100, pdf.get_y(), 114, pdf.get_y())

    pdf.set_line_width(1)
    pdf.set_draw_color(132, 132, 132)
    pdf.line(114, pdf.get_y(), 200, pdf.get_y())

    for i in range(len(education[1])):
        pdf.set_xy(100,pdf.get_y()+3)
        pdf.set_font(font[0], size=font[1]+2,style="B")
        pdf.set_text_color(0, 0, 0)
        pdf.cell(20, 10, education[2][i], fill=False, ln=1)
        pdf.set_xy(155, pdf.get_y() - 7)
        pdf.set_font(font[0], size=font[1])
        pdf.cell(25, 5, education[1][i], fill=True, ln=1,align="L")
        pdf.set_xy(100, pdf.get_y() + 3)
        pdf.set_text_color(128, 128, 128)
        pdf.set_font(font[0], size=font[1])
        pdf.cell(20, 6, education[0][i], fill=False, ln=1)
        x = 155
        y = pdf.get_y() - 6
        pdf.set_font(font[0], size=font[1])
        for j in range(len(education[3][i])):
            if j == 0:
                pass
            else:
                if x + pdf.get_string_width(education[3][i][j]) > 200:
                    x = 155
                    y = y + font[1] / 2
                else:
                    x = x + pdf.get_string_width(education[3][i][j - 1]) + 2

            pdf.set_xy(x, y)
            pdf.cell(pdf.get_string_width(education[3][i][j]) + 1, 5, education[3][i][j], 0, 1, "C")

    pdf.set_display_mode("fullpage")
    pdf.output(f"{personal_info[1]}_form3.pdf")
Exemplo n.º 9
0
def create_form2(personal_info, education, work_experience, languages,
                 software, font):
    pdf = FPDF()
    pdf.add_page()
    pdf.image(personal_info[0], w=40, h=40)
    '''NAME AND FIELD'''
    pdf.set_xy(120, 20)
    pdf.set_font("Times", size=25, style="B")
    pdf.set_text_color(0, 0, 0)
    pdf.set_fill_color(255, 255, 255)
    pdf.cell(20, 10, personal_info[1], fill=True, ln=1)
    pdf.set_xy(120, 30)
    pdf.set_font("courier", size=15, style="B")
    pdf.cell(0, 10, personal_info[2], fill=True, ln=1, align="L")
    '''PERSONAL DETAILS'''
    pdf.set_xy(10, 55)
    pdf.set_font("arial", size=15, style="B")
    pdf.set_text_color(0, 0, 0)
    pdf.set_fill_color(255, 255, 255)
    pdf.cell(20, 10, "PERSONAL DETAILS", fill=True, ln=1)

    pdf.set_line_width(1)
    pdf.set_draw_color(0, 0, 0)
    pdf.line(10, 63, 200, 63)

    pdf.set_xy(20, 68)
    pdf.set_font("times", size=15)
    pdf.set_text_color(91, 91, 91)
    pdf.set_fill_color(255, 255, 255)
    pdf.cell(20, 5, "Birth", fill=True, ln=1)
    pdf.set_xy(50, pdf.get_y() - 5)
    pdf.cell(20, 5, personal_info[3], fill=True, ln=1)

    pdf.set_xy(20, pdf.get_y() + 3)
    pdf.set_font("times", size=15)
    pdf.set_text_color(91, 91, 91)
    pdf.set_fill_color(255, 255, 255)
    pdf.cell(20, 5, "Address", fill=True, ln=1)
    pdf.set_xy(50, pdf.get_y() - 5)
    pdf.cell(20, 5, personal_info[4], fill=True, ln=1)

    pdf.set_xy(20, pdf.get_y() + 3)
    pdf.set_font("times", size=15)
    pdf.set_text_color(91, 91, 91)
    pdf.set_fill_color(255, 255, 255)
    pdf.cell(20, 5, "phone", fill=True, ln=1)
    pdf.set_xy(50, pdf.get_y() - 5)
    pdf.cell(20, 5, personal_info[5], fill=True, ln=1)

    pdf.set_xy(20, pdf.get_y() + 3)
    pdf.set_font("times", size=15)
    pdf.set_text_color(91, 91, 91)
    pdf.set_fill_color(255, 255, 255)
    pdf.cell(20, 5, "E-Mail", fill=True, ln=1)
    pdf.set_xy(50, pdf.get_y() - 5)
    pdf.cell(20, 5, personal_info[6], fill=True, ln=1)
    '''EDUCATION'''
    pdf.set_xy(10, pdf.get_y())
    pdf.set_font("arial", size=15, style="B")
    pdf.set_text_color(0, 0, 0)
    pdf.set_fill_color(255, 255, 255)
    pdf.cell(20, 12, "EDUCATION", fill=True, ln=1)

    pdf.set_line_width(1)
    pdf.set_draw_color(0, 0, 0)
    pdf.line(10, pdf.get_y() - 3, 200, pdf.get_y() - 3)

    for i in range(len(education[1])):
        pdf.set_xy(10, pdf.get_y())
        pdf.set_font(font[0], size=font[1] + 2, style="B")
        pdf.set_text_color(0, 0, 0)
        pdf.cell(20, 10, education[1][i], fill=False, ln=1)
        pdf.set_xy(150, pdf.get_y() - 8)
        pdf.set_font(font[0], size=font[1])
        pdf.set_text_color(255, 255, 255)
        pdf.set_fill_color(0, 0, 0)
        pdf.cell(25, 5, education[0][i], fill=True, ln=1)
        pdf.set_xy(10, pdf.get_y())
        pdf.set_text_color(128, 128, 128)
        pdf.set_font(font[0], size=font[1])
        pdf.set_text_color(0, 0, 0)
        pdf.cell(20, 6, education[2][i], fill=False, ln=1)
        x = 40
        y = pdf.get_y()
        pdf.set_font(font[0], size=font[1])
        for j in range(len(education[3][i])):
            if j == 0:
                pass
            else:
                if x + pdf.get_string_width(education[3][i][j]) > 115:
                    x = 40
                    y = y + font[1] / 2
                else:
                    x = x + pdf.get_string_width(education[3][i][j - 1]) + 2

            pdf.set_xy(x, y)
            pdf.cell(
                pdf.get_string_width(education[3][i][j]) + 1, 5,
                education[3][i][j], 0, 1, "C")
    '''WORK EXPERIENCE'''
    pdf.set_xy(10, pdf.get_y())
    pdf.set_font("arial", size=15, style="B")
    pdf.set_text_color(0, 0, 0)
    pdf.set_fill_color(255, 255, 255)
    pdf.cell(20, 12, "WORK EXPERIENCE", fill=True, ln=1)

    pdf.set_line_width(1)
    pdf.set_draw_color(0, 0, 0)
    pdf.line(10, pdf.get_y() - 3, 200, pdf.get_y() - 3)

    for i in range(len(work_experience[1])):
        pdf.set_xy(10, pdf.get_y())
        pdf.set_font(font[0], size=font[1] + 2, style="B")
        pdf.set_text_color(0, 0, 0)
        pdf.cell(20, 10, work_experience[1][i], fill=False, ln=1)
        pdf.set_xy(150, pdf.get_y() - 8)
        pdf.set_font(font[0], size=font[1])
        pdf.set_text_color(255, 255, 255)
        pdf.set_fill_color(0, 0, 0)
        pdf.cell(25, 5, work_experience[0][i], fill=True, ln=1)
        pdf.set_xy(10, pdf.get_y())
        pdf.set_text_color(128, 128, 128)
        pdf.set_font(font[0], size=font[1])
        pdf.set_text_color(0, 0, 0)
        pdf.cell(20, 6, work_experience[2][i], fill=False, ln=1)
        x = 40
        y = pdf.get_y()
        pdf.set_font(font[0], size=font[1])
        for j in range(len(work_experience[3][i])):
            if j == 0:
                pass
            else:
                if x + pdf.get_string_width(work_experience[3][i][j]) > 115:
                    x = 40
                    y = y + font[1] / 2
                else:
                    x = x + pdf.get_string_width(
                        work_experience[3][i][j - 1]) + 2

            pdf.set_xy(x, y)
            pdf.cell(
                pdf.get_string_width(work_experience[3][i][j]) + 1, 5,
                work_experience[3][i][j], 0, 1, "C")
    '''SKILLS'''
    pdf.set_xy(10, pdf.get_y())
    pdf.set_font("arial", size=15, style="B")
    pdf.set_text_color(0, 0, 0)
    pdf.set_fill_color(255, 255, 255)
    pdf.cell(20, 12, "SKILLS", fill=True, ln=1)

    pdf.set_line_width(1)
    pdf.set_draw_color(0, 0, 0)
    pdf.line(10, pdf.get_y() - 3, 200, pdf.get_y() - 3)

    pdf.set_xy(10, pdf.get_y())
    pdf.set_font(font[0], size=font[1] + 2, style="B")
    pdf.set_text_color(0, 0, 0)
    pdf.cell(20, 10, "Languages", fill=False, ln=1)

    pdf.set_xy(120, pdf.get_y() - 10)
    pdf.set_font(font[0], size=font[1] + 2, style="B")
    pdf.set_text_color(0, 0, 0)
    pdf.cell(20, 10, "Software", fill=False, ln=1)

    y = pdf.get_y()
    for i in range(len(languages[0])):
        pdf.set_xy(10, pdf.get_y())
        pdf.set_text_color(128, 128, 128)
        pdf.set_font(font[0], size=font[1])
        pdf.set_text_color(0, 0, 0)
        pdf.cell(20, 6, languages[0][i], fill=False, ln=1)
        x = 40
        for j in range(5):
            if j < languages[1][i]:
                pdf.set_fill_color(0, 0, 139)
                pdf.ellipse(x, pdf.get_y() - 5, 4, 4, style="F")
            else:
                pdf.set_fill_color(128, 128, 128)
                pdf.ellipse(x, pdf.get_y() - 5, 4, 4, style="F")
            x = x + 5
    pdf.set_y(y)
    for i in range(len(software[0])):
        pdf.set_xy(120, pdf.get_y())
        pdf.set_text_color(128, 128, 128)
        pdf.set_font(font[0], size=font[1])
        pdf.set_text_color(0, 0, 0)
        pdf.cell(20, 6, software[0][i], fill=False, ln=1)
        x = 150
        for j in range(5):
            if j < software[1][i]:
                pdf.set_fill_color(0, 0, 139)
                pdf.ellipse(x, pdf.get_y() - 5, 4, 4, style="F")
            else:
                pdf.set_fill_color(128, 128, 128)
                pdf.ellipse(x, pdf.get_y() - 5, 4, 4, style="F")
            x = x + 5

    pdf.set_display_mode("fullpage")
    pdf.output(f"{name}_form2.pdf")