Sponsored Content
Full Discussion: [python] merge pdf files.
Top Forums Programming [python] merge pdf files. Post 303039514 by SaltCityScripts on Tuesday 8th of October 2019 04:47:23 PM
Old 10-08-2019
[python] merge pdf files.

First off I am very new to python but not to scripting I have done a lot of bash scripting.

I need to create a python script for work that will combine multiple pdf files into one pdf file and archive both the combined file and the original pdf files.

So we receive zip files from a client (the file name will either begin with a number #########.zip or MU3-#######-#.zip) and I need to unzip the zip file and use the file name as the name of the combined file.

example
MU3-6493489-1.zip

when I unzip this file I have the following pdf files.:
MU3-6493489-1_006493489-001_ARINV.pdf
MU3-6493489-1_3461.pdf
MU3-6493489-1_7501.pdf
MU3-6493489-1_CI_2.pdf
MU3-6493489-1_CI_3.pdf
MU3-6493489-1_CI_4.pdf
MU3-6493489-1_CI_5.pdf
MU3-6493489-1_CI.pdf

I need to combine all of these pdf file into a new file called MU3-6493489-1_combined.pdf

I did find a script online that has the basic stuff but it will not work for my needs.

Code:
#pdf_merger.py

import glob
from PyPDF2 import PdfFileMerger

def merger(output_path, imput_paths):
    pdf_merger = PdfFileMerger()
    file_handles = []

    for path in input_paths:
        pdf_merger.append(path)

    with open(ouput_path, 'wb') as fileobj:
        pdf_merger.write(fileobj)

if _name_ == '_main_':
    paths = glob.glob('MU3_*.pdf')
    paths.sort()
    merger('pdf_merger2.pdf', paths)


This is not my coding and I am not attached to it in anyway. I know I will have to make a lot of changes to get that to work.

If anyone has any thoughts on how to do this I would be forever thankful and so would my work.

--- Post updated at 08:47 PM ---

on a side note: this can be in either perl or python. I just thought python would be better to learn.

I was not able to edit my original post.
 

2 More Discussions You Might Find Interesting

1. Programming

Scipy Python/ get pdf

Hi all I'm just starting usign scipy with python, really powerfull. It comes with some many functions but I'm not able to solve my problem. I have an array x and i need to find a probability density function (pdf) from data. does anyone know how to do that? (i've done it evaluating first... (1 Reply)
Discussion started by: Dedalus
1 Replies

2. Shell Programming and Scripting

Merge PDF

Hi I am trying to find a software to merge several pdfs into one pdf on our solaris machine. After merging the document, I have to direct it to a printer. Does anyone have a recommendation? I try to contact a couple of vendor but no replies. Thanks. (5 Replies)
Discussion started by: lillyt2006
5 Replies
UPDATE-PYTHON-MODULES(8)				      System Manager's Manual					  UPDATE-PYTHON-MODULES(8)

NAME
update-python-modules - byte-compile python modules SYNOPSIS
update-python-modules [options] [package.public [...]] DESCRIPTION
The update-python-modules command is part of the python-support bundle. update-python-modules is responsible for the byte-compilation of python modules. When used in byte-compilation mode, it will byte-compile modules references in the files given on the command line. When used in installation mode, it will byte-compile them once for each installed python version, and will make them available for all of them. At each invocation, with or without arguments, update-python-modules will check for installed python versions, and will build or remove modules according to new or removed versions since the last time it was run. ARGUMENTS
Arguments must be files or directories located in the /usr/share/python-support directory. Depending on their extension, they are treated differently. package.public A file listing public modules to install for each version. These modules must lie in /usr/share/pyshared or /usr/lib/pyshared. package.private A file listing private modules to byte-compile for one Python version. package/ A legacy directory hierarchy of public modules. The C extensions and portions that change with the Python version are to be found in /usr/lib/python-support/pythonX.Y/package/. package.dirs A legacy file listing directories where to find private modules. OPTIONS
-h, --help Show summary of options. -v, --verbose Detail all actions while they are performed. -b, --bytecompile Only accept to work on private modules. When given this option, update-python-modules will fail if passed references to public mod- ules. -i, --install Only accept to work on public modules. When given this option, update-python-modules will fail if passed references to public mod- ules. -c, --clean Clean modules instead of installing them. -a, --rebuild-all Rebuild all private modules. This is necessary when the default python version was changed, for example. -f, --force-rebuild-all Clean all modules (public and private), and rebuild them. FILES
/usr/lib/pymodules/pythonX.Y/ These directories contain the byte-compiled modules for version pythonX.Y. SEE ALSO
/usr/share/doc/python-support/README.gz AUTHOR
Josselin Mouette <joss@debian.org>. 18 Feb 2009 UPDATE-PYTHON-MODULES(8)
All times are GMT -4. The time now is 09:39 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy