Esempio n. 1
0
def create_abfrage_pdf(abfrage, kriterium1, kriterium2, tierhaltungen):
    fpdf = FPDF()
    fpdf.t_margin = 20
    fpdf.r_margin = 16
    fpdf.b_margin = 26
    fpdf.l_margin = 10
    fpdf.orientation = 'P'
    fpdf.format = 'A4'
    fpdf.set_font('Arial', '', 11)
    fpdf.add_page()

    spacing = 1.2
    width = 184  #210 - (16 + 10) = 184
    height = fpdf.font_size

    fpdf.set_font('Arial', '', 14)
    topic_height = fpdf.font_size
    if (kriterium2 and len(kriterium2) > 0):
        abfrage = "Abfrage " + abfrage + ", " + kriterium1 + " - " + kriterium2
    else:
        abfrage = "Abfrage " + abfrage + ", " + kriterium1
    fpdf.cell(width, topic_height * spacing, txt=abfrage, border=0)
    fpdf.ln(10)

    fpdf.set_font('Arial', '', 11)
    write_abfrage_table(fpdf, tierhaltungen, width, height, spacing)

    byte_string = fpdf.output(dest="S").encode('latin-1')
    return byte_string
Esempio n. 2
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
Esempio n. 3
0
def natives_to_pdf(confidential, prefix, vol_num, prod_num):
    prod_fol, vol_fol, n_path, i_path, t_path, m_path = start(
        prefix, vol_num, prod_num)
    dirs = [f for f in listdir(n_path) if isfile(join(n_path, f))]
    for filer in dirs:
        pre, ext = os.path.splitext(filer)
        if ext != ".msg":
            pdf = FPDF()
            pdf.l_margin = 10
            pdf.t_margin = 2
            pdf.add_page()
            pdf.set_auto_page_break(True, margin=0.25)
            pdf.set_font('arial', 'B', 13.0)
            if confidential:
                pdf.cell(
                    ln=0,
                    h=5.0,
                    align='C',
                    w=0,
                    txt=
                    "CONFIDENTIAL                                                                                 "
                    + pre,
                    border=0)
            else:
                pdf.cell(
                    ln=0,
                    h=5.0,
                    align='C',
                    w=0,
                    txt=
                    "                                                                                             "
                    + pre,
                    border=0)
            pdf.set_font('arial', 'B', 20.0)
            pdf.cell(ln=1, h=10.0, align='C', w=0, txt="", border=0)
            pdf.cell(ln=1, h=10.0, align='C', w=0, txt="", border=0)
            pdf.cell(ln=1, h=10.0, align='C', w=0, txt="", border=0)
            pdf.cell(ln=1, h=10.0, align='C', w=0, txt="", border=0)
            pdf.cell(ln=1,
                     h=10.0,
                     align='C',
                     w=0,
                     txt="FILE PRODUCED NATIVELY",
                     border=0)
            pdf.output(f"{t_path}\\{pre}.pdf", 'F')
            pdf_to_image(pre, t_path, i_path)
Esempio n. 4
0
def image_to_pdf(filer, index, confidential, prefix, vol_num, prod_num):
    prod_fol, vol_fol, n_path, i_path, t_path, m_path = start(
        prefix, vol_num, prod_num)
    _, ext = os.path.splitext(filer)
    if ext == ".png":
        n_ext = ".jpg"
    else:
        n_ext = ext
    mn_index = format(index, '08d')
    dest = f"{prefix}{mn_index}"
    pdf = FPDF()
    pdf.l_margin = 30
    pdf.add_page()
    pdf.set_auto_page_break(True, margin=0.25)
    pdf.set_font('arial', 'B', 10.0)
    if confidential:
        pdf.cell(
            ln=0,
            h=5.0,
            align='C',
            w=0,
            txt=
            f"CONFIDENTIAL                                                                                        {dest}",
            border=0)
    else:
        pdf.cell(
            ln=0,
            h=5.0,
            align='C',
            w=0,
            txt=
            f"                                                                                                    {dest}",
            border=0)
    pdf.set_font('arial', 'B', 20.0)
    pdf.cell(ln=1, h=10.0, align='C', w=0, txt="", border=0)
    pdf.cell(ln=1, h=10.0, align='C', w=0, txt="", border=0)
    pdf.cell(ln=1, h=10.0, align='C', w=0, txt="", border=0)
    pdf.cell(ln=1, h=10.0, align='C', w=0, txt="", border=0)
    name = f"{t_path}\\{dest}{n_ext}"
    typer = n_ext[1:]
    pdf.image(name, x=45, y=None, w=120, type=typer, link='')
    pdf.output(f"{t_path}\\{dest}.pdf", 'F')
    pdf_to_image(dest, t_path, i_path)
Esempio n. 5
0
def create_etiketten_pdf(personen):
    fpdf = FPDF()
    fpdf.t_margin = 20
    fpdf.r_margin = 16
    fpdf.b_margin = 26
    fpdf.l_margin = 10
    fpdf.orientation = 'P'
    fpdf.format = 'A4'
    fpdf.set_font('Arial', '', 11)
    fpdf.add_page()

    spacing = 1.0
    width = 184  #210 - (16 + 10) = 184
    height = fpdf.font_size

    write_etiketten_table(fpdf, personen, width, height, spacing)

    byte_string = fpdf.output(dest="S").encode('latin-1')
    return byte_string
Esempio n. 6
0
def pdf_generator(state, fastfoodtype):
    pdf = FPDF(format='letter', unit='in')
    pdf.l_margin = pdf.l_margin * 4.0
    pdf.r_margin = pdf.r_margin * 4.0
    pdf.t_margin = pdf.t_margin * 4.0
    pdf.b_margin = pdf.b_margin * 4.0
    pdf.add_page()

    effective_page_width = pdf.w - 2 * pdf.l_margin

    epw = pdf.w - pdf.l_margin - pdf.r_margin
    eph = pdf.h - pdf.t_margin - pdf.b_margin

    pdf.set_font("helvetica", size=15)
    pdf.multi_cell(
        effective_page_width, 0.25,
        'Relationship between the number of fast food companies and average household income'
    )
    pdf.ln(0.30)

    my_text = report_generator(state, fastfoodtype)

    pdf.set_font('helvetica', 'B', 10.0)
    pdf.cell(1.0, 0.15, '{} analysis:'.format(state))
    pdf.ln(0.30)

    pdf.set_font('helvetica', '', 10.0)
    pdf.multi_cell(effective_page_width, 0.15, my_text)
    pdf.ln(0.30)

    plot_generator(state, fastfoodtype)
    pdf.image("output.png", w=pdf.w / 2.0, h=pdf.h / 4.0)
    pdf.ln(0.10)

    pdf.set_font("helvetica", 'I', size=8)
    pdf.multi_cell(
        effective_page_width, 0.15,
        "Figure 1: Relationship between the number of fast food companies and average household income in {}. Source: own elaboration from United States Census Bureau and Datafiniti"
        .format(state))
    pdf.ln(0.25)

    pdf.output('report.pdf', 'F')
Esempio n. 7
0
 def buildContract(self, data, *args, **kw):
     try:
         pdf = FPDF(format='letter', unit='in')
         pdf.l_margin = pdf.l_margin * 2.8
         pdf.r_margin = pdf.r_margin * 2.8
         pdf.t_margin = pdf.t_margin * 1.5
         pdf.b_margin = pdf.b_margin * 1.5
         pdf.add_page()
         # eph = pdf.h - pdf.t_margin - pdf.b_margin
         pdf.set_font('Times', '', 14)
         th = 0.20
         pdf.ln(2 * th)
         epw = pdf.w - pdf.l_margin - pdf.r_margin
         pdf.multi_cell(epw, th, PDF.text(self, data))
         pdf.output('api/business/contrato_arrendamiento.pdf', 'F')
         #Email.sendEmail(self, data)
         return True
     except Exception as error:
         print(error)
         return False
Esempio n. 8
0
def images_to_pdf(confidential, prefix, vol_num, prod_num):
    prod_fol, vol_fol, n_path, i_path, t_path, m_path = start(
        prefix, vol_num, prod_num)
    i_dirs = [f for f in listdir(i_path) if isfile(join(i_path, f))]
    for filer in i_dirs:
        pre, _ = os.path.splitext(filer)
        pdf = FPDF()
        pdf.l_margin = 30
        pdf.add_page()
        pdf.set_auto_page_break(True, margin=0.25)
        pdf.set_font('arial', 'B', 10.0)
        if confidential:
            pdf.cell(
                ln=0,
                h=5.0,
                align='C',
                w=0,
                txt=
                "CONFIDENTIAL                                                                                        "
                + pre,
                border=0)
        else:
            pdf.cell(
                ln=0,
                h=5.0,
                align='C',
                w=0,
                txt=
                "                                                                                                    "
                + pre,
                border=0)
        pdf.set_font('arial', 'B', 20.0)
        pdf.cell(ln=1, h=10.0, align='C', w=0, txt="", border=0)
        pdf.cell(ln=1, h=10.0, align='C', w=0, txt="", border=0)
        pdf.cell(ln=1, h=10.0, align='C', w=0, txt="", border=0)
        pdf.cell(ln=1, h=10.0, align='C', w=0, txt="", border=0)
        name = f"{t_path}\\{filer}"
        pdf.image(name, x=45, y=None, w=120, type='', link='')
        pdf.output(f"{t_path}{pre}.pdf", 'F')
        pdf_to_image(pre, t_path, i_path)
Esempio n. 9
0
def html_to_pdf(orig_path, index, confidential, prefix, vol_num, prod_num):
    prod_fol, vol_fol, n_path, i_path, t_path, m_path = start(
        prefix, vol_num, prod_num)
    _, ext = os.path.splitext(orig_path)
    in_index = format(index, '08d')
    n_path = f"{prefix}{in_index}"
    text = open(t_path + "\\" + n_path + ext).read()
    pdf = FPDF()
    pdf.l_margin = 30
    pdf.add_page()
    pdf.set_auto_page_break(True, margin=0.25)
    pdf.set_font('arial', 'B', 10.0)
    if confidential:
        pdf.cell(
            ln=1,
            h=10.0,
            align='C',
            w=0,
            txt=
            "CONFIDENTIAL                                                                                        "
            + n_path,
            border=0)
    else:
        pdf.cell(
            ln=1,
            h=10.0,
            align='C',
            w=0,
            txt=
            "                                                                                                    "
            + n_path,
            border=0)
    pdf.set_font('arial', '', 13.0)
    pdf.cell(ln=1, h=10.0, align='C', w=0, txt="", border=0)
    pdf.cell(ln=1, h=10.0, align='C', w=0, txt="", border=0)
    pdf.cell(ln=1, h=10.0, align='C', w=0, txt="", border=0)
    pdf.cell(ln=1, h=10.0, align='C', w=0, txt="", border=0)
    pdf.multi_cell(0, 5, text.encode('latin-1', 'replace').decode('latin-1'))
    pdf.output(f"{t_path}\\{n_path}.pdf", 'F')
    pdf_to_image(n_path, t_path, i_path)
Esempio n. 10
0
def fpj(id_employees):
    con = sqlite3.connect("database.db")
    con.row_factory = sqlite3.Row
    cur = con.cursor()
    cur.execute("select * from Employees where id_employees = ?",
                (id_employees, ))
    rows = cur.fetchall()
    con.close()

    pdf = FPDF(orientation='P', unit='mm', format='A4')
    pdf.l_margin = pdf.l_margin * 2.0
    pdf.r_margin = pdf.r_margin * 2.0
    pdf.t_margin = pdf.t_margin * 1.0
    pdf.b_margin = pdf.b_margin * 1.0

    pdf.add_page()
    pdf.set_font("Arial", style='B', size=12)
    pdf.multi_cell(
        170,
        5,
        txt=
        "LAPORAN PERTANGGUNGJAWABAN PESERTA PROGRAM PEMBERIAN BANTUAN PEMERINTAH DIGITAL TALENT SCHOLARSHIP TAHUN 2021",
        align="C")
    pdf.ln()
    pdf.set_font("Arial", style='I', size=10)
    pdf.multi_cell(
        170,
        5,
        txt=
        "Formulir ini untuk diisi (diketik atau tulis tangan dengan jelas) kemudian diunggah/upload di akun digitalent.kominfo.go.id oleh masing-masing peserta di akhir pelaksanaan pelatihan",
        border=1,
        align="J")
    pdf.ln()
    pdf.set_font("Arial", style='B', size=10)
    pdf.cell(170, 5, txt="I. Identitas Diri", ln=1)
    pdf.set_font("Arial", size=10)

    for row in rows:
        pdf.cell(50, 5, txt="NIK/NIP                                    :")
        pdf.cell(100, 5, txt=row["nik_nip"], ln=1)
        pdf.cell(50, 5, txt="Nama Lengkap                         :")
        pdf.cell(100, 5, txt=row["nama"], ln=1)
        pdf.cell(50, 5, txt="Alamat                                      :")
        pdf.multi_cell(120, 5, txt=row["alamat"])
        pdf.cell(50, 5, txt="No HP Aktif                              :")
        pdf.cell(100, 5, txt=row["hp"], ln=1)
        pdf.cell(50, 5, txt="No HP Wali/Atasan                  :")
        pdf.cell(100, 5, txt=row["hp_wali_atasan"], ln=1)
        pdf.cell(50, 5, txt="Email Aktif                                :")
        pdf.cell(100, 5, txt=row["email"], ln=1)

    pdf.ln()
    pdf.set_font("Arial", style='B', size=10)
    pdf.cell(170, 5, txt="II. Program Akademi", ln=1)

    for row in rows:
        pdf.set_font("Arial", size=10)
        pdf.cell(50, 5, txt="Akademi                                   :")
        pdf.cell(100, 5, txt=row["program_akademi"], ln=1)
        pdf.cell(50, 5, txt="Mitra Pelatihan                         :")
        pdf.cell(100, 5, txt=row["mitra_pelatihan"], ln=1)
        pdf.cell(50, 5, txt="Tema Pelatihan                        :")
        pdf.cell(100, 5, txt=row["tema_pelatihan"], ln=1)
        pdf.cell(50, 5, txt="Bulan Pelaksanaan                  :")
        pdf.cell(100, 5, txt=row["bulan_pelaksanaan"], ln=1)

    pdf.ln()
    pdf.set_font("Arial", style='B', size=10)
    pdf.cell(170, 5, txt="III. Pelaksanaan Kegiatan", ln=1)
    pdf.set_font("Arial", size=10)
    pdf.cell(170, 5, txt="Dengan ini menyatakan telah menerima hak:", ln=1)
    pdf.set_font("Arial", style='B', size=10)
    pdf.cell(10, 5, txt="No", border=1, ln=0, align="C")
    pdf.cell(120, 5, txt="Uraian", border=1, ln=0, align="C")
    pdf.cell(40, 5, txt="Beri Tanda Check List", border=1, ln=1, align="C")

    pdf.set_font("Arial", size=10)
    top = pdf.y
    pdf.multi_cell(10, 15, txt="1.", border=1, align="C")
    pdf.y = top
    pdf.x = pdf.x + 10
    pdf.multi_cell(
        120,
        5,
        txt=
        "Self-paced Learning : Peserta pelatihan belajar secara mandiri melalui laptop/komputer, jadwal pelaksanaan Self-paced Learning diatur secara mandiri oleh peserta dalam batas durasi pelatihan Professional Academy",
        border=1)
    pdf.y = top
    pdf.x = pdf.x + 130
    pdf.set_font("ZapfDingbats", size=10)
    pdf.multi_cell(40, 15, txt="4", border=1, align="C")

    pdf.set_font("Arial", size=10)
    top = pdf.y
    pdf.multi_cell(10, 20, txt="2.", border=1, align="C")
    pdf.y = top
    pdf.x = pdf.x + 10
    pdf.multi_cell(
        120,
        5,
        txt=
        "Live Session : Sesi tatap muka secara daring/online antara instruktur dan peserta pelatihan, peserta pelatihan mendapatkan kesempatan bertanya dan berinteraksi dengan instruktur pada tema pelatihan tertentu di Program Professional Academy",
        border=1)
    pdf.y = top
    pdf.x = pdf.x + 130
    pdf.set_font("ZapfDingbats", size=10)
    pdf.multi_cell(40, 20, txt="4", border=1, align="C")

    pdf.set_font("Arial", size=10)
    top = pdf.y
    pdf.multi_cell(10, 10, txt="3.", border=1, align="C")
    pdf.y = top
    pdf.x = pdf.x + 10
    pdf.multi_cell(
        120,
        5,
        txt=
        "Hands-on Lab: Peserta akan mengerjakan suatu project secara mandiri pada Virtual Lab",
        border=1)
    pdf.y = top
    pdf.x = pdf.x + 130
    pdf.set_font("ZapfDingbats", size=10)
    pdf.multi_cell(40, 10, txt="4", border=1, align="C")

    pdf.set_font("Arial", size=10)
    top = pdf.y
    pdf.multi_cell(10, 15, txt="4.", border=1, align="C")
    pdf.y = top
    pdf.x = pdf.x + 10
    pdf.multi_cell(
        120,
        5,
        txt=
        "Certificate of Completion : diberikan kepada peserta yang menyelesaikan seluruh sesi pelatihan, mengisi survey dan mengunggah/upload Laporan Pertanggungjawaban (form ini) di digitalent.kominfo.go.id",
        border=1)
    pdf.y = top
    pdf.x = pdf.x + 130
    pdf.set_font("ZapfDingbats", size=10)
    pdf.multi_cell(40, 15, txt="4", border=1, align="C")

    pdf.ln()
    pdf.set_font("Arial", style='B', size=10)
    pdf.cell(170,
             5,
             txt="IV. Saran/Rekomendasi Pelaksanaan Kegiatan (diketik)",
             ln=1)
    pdf.set_font("Arial", size=10)

    for row in rows:
        pdf.multi_cell(170, 5, txt=row["saran"])

    pdf.ln()
    pdf.ln()

    for row in rows:
        pdf.cell(145, 5, txt=row["kota_sekarang"] + ", ", align="R")
        pdf.cell(25, 5, txt=date.today().strftime("%d %B %Y"), align="R", ln=1)

    pdf.ln()
    pdf.ln()
    pdf.ln()

    for row in rows:
        pdf.cell(170, 5, txt=row["nama"], align="R", ln=1)

    return Response(pdf.output(dest='S').encode('latin-1'),
                    mimetype='application/pdf',
                    headers={
                        'Content-Disposition':
                        'attachment;filename=Form PertanggungJawaban ' +
                        row["nama"] + '.pdf'
                    })
Esempio n. 11
0
def fk(id_employees):
    con = sqlite3.connect("database.db")
    con.row_factory = sqlite3.Row
    cur = con.cursor()
    cur.execute("select * from Employees where id_employees = ?",
                (id_employees, ))
    rows = cur.fetchall()
    con.close()

    pdf = FPDF(orientation='P', unit='mm', format='A4')
    pdf.l_margin = pdf.l_margin * 2.0
    pdf.r_margin = pdf.r_margin * 2.0
    pdf.t_margin = pdf.t_margin * 1.0
    pdf.b_margin = pdf.b_margin * 1.0

    pdf.add_page()
    pdf.set_font("Arial", style='B', size=12)
    pdf.multi_cell(
        170,
        5,
        txt=
        "FORM KOMITMEN PARTISIPASI PROGRAM PEMBERIAN BANTUAN PEMERINTAH DIGITAL TALENT SCHOLARSHIP TAHUN 2021",
        align="C")
    pdf.ln()
    pdf.set_font("Arial", style='I', size=10)
    pdf.multi_cell(
        170,
        5,
        txt=
        "Formulir ini untuk diisi (diketik atau tulis tangan dengan jelas) kemudian diunggah/upload di akun digitalent.kominfo.go.id oleh masing-masing peserta di awal pelaksanaan pelatihan",
        border=1,
        align="J")
    pdf.ln()
    pdf.set_font("Arial", size=10)
    pdf.cell(170, 5, txt="Saya yang bertandatangan di bawah ini:", ln=1)

    for row in rows:
        pdf.cell(50, 5, txt="Nama Lengkap (Sesuai KTP)  :")
        pdf.cell(100, 5, txt=row["nama"], ln=1)
        pdf.cell(50, 5, txt="Tempat/Tanggal Lahir              :")
        pdf.cell(100, 5, txt=row["tempat_tanggal_lahir"], ln=1)
        pdf.cell(50, 5, txt="NIK/NIP                                    :")
        pdf.cell(100, 5, txt=row["nik_nip"], ln=1)
        pdf.cell(50, 5, txt="Email Aktif                                :")
        pdf.cell(100, 5, txt=row["email"], ln=1)
        pdf.cell(50, 5, txt="No HP Aktif                              :")
        pdf.cell(100, 5, txt=row["hp"], ln=1)
        pdf.cell(50, 5, txt="No HP Wali/Atasan                  :")
        pdf.cell(100, 5, txt=row["hp_wali_atasan"], ln=1)
        pdf.cell(50, 5, txt="Pekerjaan                                 :")
        pdf.cell(100, 5, txt=row["pekerjaan"], ln=1)
        pdf.cell(50, 5, txt="Alamat Domisili                        :")
        pdf.multi_cell(120, 5, txt=row["alamat"])
        pdf.cell(50, 5, txt="Program Akademi                    :")
        pdf.cell(100, 5, txt=row["program_akademi"], ln=1)
        pdf.cell(50, 5, txt="Tema Pelatihan                        :")
        pdf.cell(100, 5, txt=row["tema_pelatihan"], ln=1)
        pdf.cell(50, 5, txt="Mitra Pelatihan                         :")
        pdf.cell(100, 5, txt=row["mitra_pelatihan"], ln=1)

    pdf.ln()
    pdf.cell(170, 5, txt="Menyatakan : ", ln=1)
    pdf.cell(
        170,
        5,
        txt=
        "1. Bersedia mengikuti seluruh tahapan pelatihan sejak awal hingga selesai;",
        ln=1)
    pdf.cell(
        170,
        5,
        txt=
        "2. Bersedia menjadi calon Penerima Bantuan Pemerintah Digital Talent Scholarship Tahun 2021;",
        ln=1)
    pdf.cell(
        170,
        5,
        txt=
        "3. Bersedia memenuhi persyaratan administratif serta Syarat dan Ketentuan yang berlaku;",
        ln=1)
    pdf.cell(
        170,
        5,
        txt=
        "4. Bersedia memenuhi Kewajiban dan Tata Tertib sebagai peserta pelatihan;",
        ln=1)
    pdf.multi_cell(
        170,
        5,
        txt=
        "5. Bersedia menerima dan tidak akan mengganggu-gugat segala keputusan Panitia Digital Talent Scholarship Tahun 2021;"
    )
    pdf.multi_cell(
        170,
        5,
        txt=
        "6. Bersedia memberikan informasi pribadi yang tercantum dalam form pendaftaran kepada Panitia Digital Talent Scholarship 2021 untuk kepentingan pelaksanaan pelatihan dan pasca pelatihan;"
    )
    pdf.cell(
        170,
        5,
        txt=
        "7. Menaati segala ketentuan dan tata tertib yang diterapkan di lingkungan mitra penyelenggara; ",
        ln=1)
    pdf.multi_cell(
        170,
        5,
        txt=
        "8. Mengerti dan setuju bahwa konten pelatihan digunakan hanya untuk kebutuhan Digital Talent Scholarship Kementerian Komunikasi dan Informatika. Segala konten pelatihan termasuk tidak terbatas pada soal tes substansi, soal kuis, soal mid exam, soal final exam, materi pelatihan, video, gambar dan kode ini mengandung Kekayaan Intelektual, peserta tunduk kepada undang-undang hak cipta, merek dagang atau hak kekayaan intelektual lainnya. Peserta dilarang untuk mereproduksi, memodifikasi, menyebarluaskan, atau mengeksploitasi konten ini dengan cara atau bentuk apapun tanpa persetujuan tertulis dari Panitia Digital Talent Scholarship Kementerian Komunikasi dan Informatika Republik Indonesia. Peserta yang terbukti melakukan pelanggaran ini akan dicabut Hak sebagai penerima beasiswa dan akan menerima konsekuensi sesuai aturan yang berlaku;"
    )
    pdf.multi_cell(
        170,
        5,
        txt=
        "9. Tidak terlibat dalam penyalahgunaan narkotika, obat-obatan terlarang, kriminal, dan paham radikal dan terorisme."
    )
    pdf.ln()

    pdf.multi_cell(
        170,
        5,
        txt=
        "Demikian Form Komitmen Partisipasi ini dibuat dengan sebenarnya secara sadar dan tanpa paksaan. Apabila dikemudian hari pernyataan ini terbukti tidak benar, maka saya bersedia untuk dicabut haknya sebagai peserta pelatihan dan menerima sanksi sesuai ketentuan Kementerian Komunikasi dan Informatika."
    )
    pdf.ln()

    for row in rows:
        pdf.cell(145, 5, txt=row["kota_sekarang"] + ", ", align="R")
        pdf.cell(25, 5, txt=date.today().strftime("%d %B %Y"), align="R", ln=1)

    pdf.ln()
    pdf.ln()
    pdf.ln()

    for row in rows:
        pdf.cell(170, 5, txt=row["nama"], align="R", ln=1)

    return Response(pdf.output(dest='S').encode('latin-1'),
                    mimetype='application/pdf',
                    headers={
                        'Content-Disposition':
                        'attachment;filename=Form Komitmen ' + row["nama"] +
                        '.pdf'
                    })
Esempio n. 12
0
def create_pdf(row):
    # Create instance of FPDF class
    pdf = FPDF(format='Letter', unit='in')

    # Set margin sizes
    pdf.l_margin = 1
    pdf.r_margin = 1
    pdf.t_margin = .25
    pdf.b_margin = .25

    # Create first page
    pdf.add_page()

    # Effective page width and height (for centering purposes)
    epw = pdf.w - 2 * pdf.l_margin
    #eph = pdf.h = 2*pdf.t_margin

    # Font declaration
    pdf.set_font('Helvetica', '', 14)

    # Text height
    th = pdf.font_size

    # Initial line break needed for unknown reasons.
    pdf.ln(2 * th)

    # Images
    # Use absolute positioning. Specify image dimension or it will revert to 72dpi.
    pdf.image('zuckbox.png', x=.39, y=.535, h=9.93, type='PNG')
    pdf.image('zucklogo.png', x=1, y=1, h=1.133, type='PNG')

    # Zuck Files URL
    pdf.set_xy(4.86, 1.43)  # Absolute positioning
    pdf.cell(
        0, th,
        'www.zuckerbergfiles.org')  # Content cell (width, height, content)
    pdf.ln(1.2)  # Line break

    # Title
    pdf.set_font('Helvetica', 'B', 20)
    pdf.multi_cell(epw, th * 1.5, row['title'], align='C')
    pdf.ln(.10)

    # ID
    pdf.set_font('Helvetica', '', 12)
    pdf.cell(epw, th, row['record_id'], align='C')
    pdf.ln(.72)

    # Date
    pdf.set_xy(1.25, 3.6)
    pdf.set_font('Helvetica', 'B')
    pdf.cell(1.1, th, 'Date: ', align='R')
    pdf.set_font('Helvetica', style='')
    pdf.multi_cell(4.93, th, row['date'], align='L')
    pdf.ln(.25)

    # Description
    pdf.set_x(1.25)  # Absolute positioning
    pdf.set_font('Helvetica', 'B')  # Bold font for label
    pdf.cell(1.1, th, 'Description: ', align='R')  # Metadata field label
    pdf.set_font('Helvetica', style='')  # Unbold font for contents
    pdf.multi_cell(4.93, th, row['description'],
                   align='L')  # Metadata value contents
    pdf.ln(.25)

    # Participants
    pdf.set_x(1.25)
    pdf.set_font('Helvetica', 'B')
    pdf.cell(1.1, th, 'Participants: ', align='R')
    pdf.set_font('Helvetica', style='')
    pdf.multi_cell(4.93, th, row['participants'], align='L')
    pdf.ln(.25)

    # Source
    pdf.set_x(1.25)  # Reset L-R position
    pdf.set_font('Helvetica', 'B')
    pdf.cell(1.1, th, 'Source: ', align='R')
    pdf.set_font('Helvetica', style='')
    pdf.multi_cell(4.93, th, row['source'], align='L')
    pdf.ln(.25)

    # Type
    pdf.set_x(1.25)
    pdf.set_font('Helvetica', 'B')
    pdf.cell(1.1, th, 'Type: ', align='R')
    pdf.set_font('Helvetica', style='')
    pdf.multi_cell(4.93, th, row['record_type'], align='L')
    pdf.ln(.25)

    # URL
    pdf.set_x(1.25)
    pdf.set_font('Helvetica', 'B')
    pdf.cell(1.1, th, 'URL: ', align='R')
    pdf.set_font('Helvetica', style='')
    pdf.multi_cell(4.93, th, row['url'], align='L')

    # Write file
    pdf.output(row['record_id'] + '_cover' + '.pdf', 'F')
Esempio n. 13
0
def buildContract():

    pdf = FPDF(format='letter', unit='in')
    pdf.l_margin = pdf.l_margin*2.8
    pdf.r_margin = pdf.r_margin*2.8
    pdf.t_margin = pdf.t_margin*1.5
    pdf.b_margin = pdf.b_margin*1.5
    pdf.add_page()

    epw = pdf.w - pdf.l_margin - pdf.r_margin
    # eph = pdf.h - pdf.t_margin - pdf.b_margin

    pdf.set_font('Times', '', 14)
    th = 0.20

    pdf.ln(2*th)

    textoContrato = """"""

    with open(os.path.join(os.path.dirname(os.path.dirname(__file__)),
              'api/contrato.txt')) as file_in:
        # lines = []
        for line in file_in:
            textoContrato = textoContrato + line

    now = datetime.now()
    months = ("Enero", "Febrero", "Marzo", "Abri", "Mayo",
              "Junio", "Julio", "Agosto", "Septiembre",
              "Octubre", "Noviembre", "Diciembre")

    # NOMBRE_ARRENDADOR_REMPLAZO
    NRR = \
        textoContrato.replace('${NOMBRE_ARRENDADOR}',
                              'Santiago Pérez Ontiveros'.upper())
    # NOMBRE_ARRENDATARIO_REMPLAZO
    NAR = \
        NRR.replace('${NOMBRE_ARRENDATARIO}',
                    'Roberto Israel Perez Ochoa'.upper())
    # NUMERO_ESCRITURA_REMPLAZO
    NER = \
        NAR.replace('${NUMERO_ESCRITURA}',
                    '')
    # TIPO_INMUEBLE_REMPLAZO
    TIR = \
        NER.replace('${TIPO_INMUEBLE}',
                    'LOCAL')
    # DIRECCION_INMUEBLE_REMPLAZO
    DIR = \
        TIR.replace('${DIRECCION_INMUEBLE}',
                    'AV. Tepic Vallarta #32')
    # SERVICIO_A_OFRECER_REMPLAZO
    SAOR = \
        DIR.replace('${SERVICIO_A_OFRECER}',
                    'RENTA LOCAL')
    # FECHA_INICIO_REMPLAZO
    FIR = \
        SAOR.replace('${FECHA_INICIO}',
                     'el día {} de {} del {}'
                     .format(now.day, months[now.month - 1], now.year))
    # FECHA_FINAL_REMPLAZO
    FFR = \
        FIR.replace('${FECHA_FINAL}',
                    'el día {} de {} del {}'
                    .format(now.day, months[now.month - 1], now.year + 1))
    # PRECIO_INMUEBLE_REMPLAZO
    PIR = \
        FFR.replace('${PRECIO_INMUEBLE}',
                    '6,000')
    # PRECIO_DEPOSITO_REMPLAZO
    PDR = \
        PIR.replace('${PRECIO_DEPOSITO}',
                    '6,500')
    # PLAZO_GRACIA_REMPLAZO
    PGR = \
        PDR.replace('${PLAZO_GRACIA}',
                    '2')
    # PORCENTAJE_AUMENTO_REMPLAZO
    PAR = \
        PGR.replace('${PORCENTAJE_AUMENTO}',
                    '10%')
    # DIRRECCION_ARRENDADOR_REMPLAZO
    DAR = \
        PAR.replace('${DIRRECCION_ARRENDADOR}',
                    'Federalismo sur 341 cp: 44100')

    pdf.multi_cell(epw, th, DAR)
    pdf.output('contrato_arrendamiento.pdf', 'F')
Esempio n. 14
0
#creating color dictionary for keywords
clr_dict = {}
for keyword in keywords['hw']:
    clr_dict[keyword] = [
        randint(100, 255),
        randint(100, 255),
        randint(100, 255)
    ]

#####################hw test_data################################

distances = []

print('Initializing distances...')
pdf = FPDF()
pdf.l_margin = pdf.l_margin * 0.1
pdf.add_page()
pdf.set_xy(0, 0)
pdf.set_font('Times', 'B', 8.0)
num = 0
for comment in hw_comments:
    num += 1
    comments = list(filter(None, comment.lower().split('.')))
    no_of_comments = len(comments)
    heading = "Comment " + str(num)
    pg_no = pdf.page_no()
    # checking for page no. in advance based on future formatting(line break) that will be done
    # to ensure all sentences of comment are in the same page for each heading.

    if (pdf.ln(2 * (no_of_comments + 2))):
        if (pdf.page_no() != pg_no):