I comment that with the PyPDF2 library, I want to read 1 file (.pdf) that 
is in a folder, take the information from that file and send it to a scrpt, 
which is processed (I already have the scropt functions done, I put them 
here) and then I want to save the results in another pdf and that this be 
saved in the same folder, but with the name results. Suggestions on how I 
can do this. Escrip that will process the information in the pdf.
import pdfAWAM
import sys, os
import optparse
import time
import config
import requests
import io

USAGE="""%s [options] pdffile - Check PDF documents for accessibility"""

def checkAcc(pdffile_or_url, passwd='', verbose=True, report=False, 
developer=False, loglevel='info'):

config.pdfwamloglevel = loglevel

if pdffile_or_url.startswith('http://') or pdffile_or_url.startswith('
https://'):
data = requests.get(pdffile_or_url).content
stream = io.BytesIO(data)
else:
stream = open(pdffile_or_url, 'rb')
json_response = pdfAWAM.extractAWAMIndicators(stream, passwd, verbose, 
report, developer, json_value=True, console=True)

print("JSON Response",json_response)

def setupOptions():
if len(sys.argv)==1:
sys.argv.append('-h')
o = optparse.OptionParser(usage=USAGE % sys.argv[0] )
o.add_option('-p','--password',
dest='password',help='Optional password for encrypted PDF',default='')
o.add_option('-q','--quiet',
dest='quiet',help="Be quiet, won't print debug/informational messages",
action="store_true",
default=False)
o.add_option('-d','--developer',
dest='developer',help="Print a dictionary of information for the developer 
(please note that this turns off reporting and debug messages 
automatically)",action="store_true",
default=False) 
o.add_option('-r','--report',
dest='report',help="Print a report of test results at the end",action=
"store_true",
default=False)
o.add_option('-l','--loglevel',
dest='loglevel',help="Set logging level (default: info)",
default='info')
o.add_option('-j', '--json',
dest='json', help="Print JSON of result",action="store_true",
default=False)

options, args = o.parse_args()
return (args[0], options.__dict__)

def main():
pdffile, options = setupOptions()

password = options.get('password','')
quiet = options.get('quiet')
report = options.get('report')
developer = options.get('developer')
loglevel = options.get('loglevel','info')
json_flag = options.get('json')

if developer:
print('Developer option turned on, reporting and messages will be disabled.'
)

verbose = (not quiet)
checkAcc(pdffile, password, verbose, report, developer, loglevel)

if __name__ == "__main__":
main()

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/3c640390-fc35-45dc-880d-8f02b980a1e0n%40googlegroups.com.

Reply via email to