Esempio n. 1
0
def duplicate_badge_file(pdf_filepath, suffix='-joined'):
    """ Create a PDF file with 2 consecutive copies of `pdf_filepath`.

    Parameters
    ----------
    pdf_filepath: str
        Path to the PDF file path.

    suffix: str
        Suffix for the new file name.

    Returns
    -------
    out_path: str
        Path to the merged file path.
    """
    return merge_pdfs([pdf_filepath]*2, pdf_filepath.replace('.pdf', suffix + '.pdf'))
Esempio n. 2
0
def duplicate_badge_file(pdf_filepath, suffix="-joined"):
    """ Create a PDF file with 2 consecutive copies of `pdf_filepath`.

    Parameters
    ----------
    pdf_filepath: str
        Path to the PDF file path.

    suffix: str
        Suffix for the new file name.

    Returns
    -------
    out_path: str
        Path to the merged file path.
    """
    return merge_pdfs([pdf_filepath] * 2,
                      pdf_filepath.replace(".pdf", suffix + ".pdf"))
def create_badge_faces(pdf_filepath):
    """ duplicate the given pdf, save it in a file with '-joined.pdf' suffix
    and return the new filepath.
    """
    return merge_pdfs([pdf_filepath] * 2, pdf_filepath.replace('.pdf', '-joined.pdf'))
Esempio n. 4
0
def create_badge_faces(pdf_filepath):
    """ duplicate the given pdf, save it in a file with '-joined.pdf' suffix and return the new filepath. """
    return merge_pdfs([pdf_filepath] * 2, pdf_filepath.replace('.pdf', '-joined.pdf'))
Esempio n. 5
0
    # PDF_FILEPATH = prepare_badge_for_print(BADGE_FILEPATH, PDF_FILEPATH)
    # time.sleep(3)
    # os.remove(BADGE_FILEPATH)
    #
    # #check if the generated if the same as the old one
    # if TEST_BADGE:
    #     if not filecmp.cmp (PDF_FILEPATH, ORIG_PDF_FILEPATH, shallow=False):
    #         shutil.copyfile(PDF_FILEPATH, ORIG_PDF_FILEPATH)
    #         os.remove      (PDF_FILEPATH)
    #         PDF_FILEPATH  = ORIG_PDF_FILEPATH
    #     else:
    #         os.remove(PDF_FILEPATH)
    #         continue
    #
    # #create pair-of-badges pdf
    # PDF_PAIR_FILE = create_badge_faces(PDF_FILEPATH)
    # BADGE_FILEPATHS.append(PDF_PAIR_FILE)
    # print(BADGE_FILEPATH)


if BADGE_FILEPATHS:
    BADGES_LIST_FILE = op.join(OUTPUT_DIR, '{}_badges.pdf'.format(BADGE_TYPE.name))
    print('Merging {} badges.'.format(len(BADGE_FILEPATHS)))
    print(BADGES_LIST_FILE)
    merge_pdfs(BADGE_FILEPATHS, BADGES_LIST_FILE)
else:
    print('No badges to make.')


# In[ ]: