print>>sys.stderr,"Conversion of PS or PDF to PDF/X is not possible because the minimal gs version for the executable %s is not met: it should be %s but %s has been found"%(CFG_PATH_GS,CFG_GS_MINIMAL_VERSION_FOR_PDFX,output)
returnFalse
exceptException,err:
print>>sys.stderr,"Conversion of PS or PDF to PDF/X is not possible because it's not possible to retrieve the gs version using the executable %s: %s"%(CFG_PATH_GS,err)
returnFalse
ifnotCFG_PATH_PDFINFO:
ifverbose:
print>>sys.stderr,"Conversion of PS or PDF to PDF/X is not possible because the pdfinfo executable is not available"
returnFalse
ifnotos.path.exists(CFG_ICC_PATH):
ifverbose:
print>>sys.stderr,"Conversion of PS or PDF to PDF/X is not possible because %s does not exists. Have you run make install-pdfa-helper-files?"%CFG_ICC_PATH
returnFalse
returnTrue
defcan_pdfa(verbose=False):
"""Return True if it's possible to generate PDF/As."""
ifnotCFG_PATH_PDFTOPS:
ifverbose:
print>>sys.stderr,"Conversion of PS or PDF to PDF/A is not possible because the pdftops executable is not available"
returnFalse
ifnotCFG_PATH_GS:
ifverbose:
print>>sys.stderr,"Conversion of PS or PDF to PDF/A is not possible because the gs executable is not available"
print>>sys.stderr,"Conversion of PS or PDF to PDF/A is not possible because the minimal gs version for the executable %s is not met: it should be %s but %s has been found"%(CFG_PATH_GS,CFG_GS_MINIMAL_VERSION_FOR_PDFA,output)
returnFalse
exceptException,err:
print>>sys.stderr,"Conversion of PS or PDF to PDF/A is not possible because it's not possible to retrieve the gs version using the executable %s: %s"%(CFG_PATH_GS,err)
returnFalse
ifnotCFG_PATH_PDFINFO:
ifverbose:
print>>sys.stderr,"Conversion of PS or PDF to PDF/A is not possible because the pdfinfo executable is not available"
returnFalse
ifnotos.path.exists(CFG_ICC_PATH):
ifverbose:
print>>sys.stderr,"Conversion of PS or PDF to PDF/A is not possible because %s does not exists. Have you run make install-pdfa-helper-files?"%CFG_ICC_PATH
returnFalse
returnTrue
defcan_perform_ocr(verbose=False):
"""Return True if it's possible to perform OCR."""
ifnotCFG_CAN_DO_OCR:
ifverbose:
print>>sys.stderr,"OCR is not supported because either the pyPdf of ReportLab Python libraries are missing"
returnFalse
ifnotCFG_PATH_OCROSCRIPT:
ifverbose:
print>>sys.stderr,"OCR is not supported because the ocroscript executable is not available"
returnFalse
ifnotCFG_PATH_PDFTOPPM:
ifverbose:
print>>sys.stderr,"OCR is not supported because the pdftoppm executable is not available"
get_file_converter_logger().debug("Extracted title is %s"%title)
ifos.path.exists(CFG_ICC_PATH):
shutil.copy(CFG_ICC_PATH,working_dir)
else:
raiseInvenioWebSubmitFileConverterError('ERROR: ISOCoatedsb.icc file missing. Have you run "make install-pdfa-helper-files" as part of your Invenio deployment?')
get_file_converter_logger().debug("Extracted title is %s"%title)
ifos.path.exists(CFG_ICC_PATH):
shutil.copy(CFG_ICC_PATH,working_dir)
else:
raiseInvenioWebSubmitFileConverterError('ERROR: ISOCoatedsb.icc file missing. Have you run "make install-pdfa-helper-files" as part of your Invenio deployment?')
@param ln is a two letter language code to give the OCR tool a hint.
@param return_working_dir if set to True, will return output_file path and the working_dir path, instead of deleting the working_dir. This is useful in case you need the intermediate images to build again a PDF.
"""
def_perform_rotate(working_dir,imagefile,angle):
"""Rotate imagefile of the corresponding angle. Creates a new file
with rotated.ppm."""
get_file_converter_logger().debug('Performing rotate on %s by %s degrees'%(imagefile,angle))
parser.add_option("-o","--output",dest="output_name",help="the desired output FILE (if not specified a new file will be generated with the desired output format)")
parser.add_option("--without-pdfa",action="store_false",dest="pdf_a",default=True,help="don't force creation of PDF/A PDFs")
parser.add_option("--without-pdfopt",action="store_false",dest="pdfopt",default=True,help="don't force optimization of PDFs files")
parser.add_option("--without-ocr",action="store_false",dest="ocr",default=True,help="don't force OCR")
parser.add_option("--can-convert",dest="can_convert",help="display all the possible format that is possible to generate from the given format",metavar="FORMAT")
parser.add_option("--is-ocr-needed",dest="check_ocr_is_needed",help="check if OCR is needed for the FILE specified",metavar="FILE")
parser.add_option("-t","--title",dest="title",help="specify the title (used when creating PDFs)",metavar="TITLE")
parser.add_option("-l","--language",dest="ln",help="specify the language (used when performing OCR, e.g. en, it, fr...)",metavar="LN",default='en')