File: pdfboxValidate.py

package info (click to toggle)
endesive 2.19.2%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,128 kB
  • sloc: python: 18,368; xml: 800; sh: 195; javascript: 118; makefile: 23
file content (22 lines) | stat: -rwxr-xr-x 692 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/usr/bin/env vpython3
import sys
import pdfbox
from jnius import autoclass

pdfname = 'pdf.pdf'
if len(sys.argv) > 1:
    pdfname = sys.argv[1]
signature = autoclass('org.apache.pdfbox.examples.examples.ShowSignature')
signature.showSignature('', pdfname)
parser.parse()
#org.apache.pdfbox.preflight.PreflightDocument
document = parser.getPreflightDocument()
document.validate()
result = document.getResult()
document.close()
if result.isValid():
    print("The file:{} is a valid PDF/A-1b file".format(pdfname))
else:
    print("The file: {} is not valid, error(s) :".format(pdfname))
    for error in result.getErrorsList():
        print(error.getErrorCode(), " : ", error.getDetails())