-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpdf-a-conv.py
More file actions
38 lines (25 loc) · 1.03 KB
/
pdf-a-conv.py
File metadata and controls
38 lines (25 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import os
import ghostscript
print("\n PDF to PDF/A Conversion \n")
# ghostscript package used
# Output: PDF/A - 1b conversion
filepath1 = input(" Enter the File path: ")
Output1 = input(" Enter the Output path: ")
output = Output1 + "\\"
filepath = filepath1 + "\\"
filelist = os.path.isdir(filepath) # specified path is an existing directory or not
# os.listdir = list the file list in the directory
for fname in os.listdir(filepath):
print(fname)
if not fname.endswith(".pdf"):
continue
path = os.path.join(filepath, fname)
print(path)
#print(fname)
#print(path)
ghostScriptExec = ['gs', '-dPDFA', '-dBATCH', '-dNOPAUSE', '-dUseCIEColor', '-sProcessColorModel=DeviceRGB',
'-sDEVICE=pdfwrite', '-dFastWebView', '-dAutoRotatePages=/None', '-sPDFACompatibilityPolicy=1',
'-sOutputFile='+ output + 'PDFA-' + fname, path]
ghostscript.Ghostscript(*ghostScriptExec)
#print(filepath)
print("\n Conversion Completed\n")