Skip to content
Snippets Groups Projects

Hotfix

Merged Christian Rohlfing requested to merge rohlfing-master-patch-43730 into master
1 file
+ 10
9
Compare changes
  • Side-by-side
  • Inline
+ 10
9
@@ -142,13 +142,15 @@ def watermark_pdf(infolder, tmpdir, outfolder, dpi, pdf_file):
#Watermarking PDF page images
img_folder = os.listdir(tmpdir)
img_files = [_ for _ in img_folder if _[-4:] == ".jpg" and (_.split('.',1)[0]).split('_',1)[0] == matnum]
#TODO: call watermark_template as in merge request described
#TODO: temporary single pdf pages should be stored in tmpdir
#Create template
template = create_watermark_template(dpi,tmpdir,matnum,img_files[0])
for img_file in img_files:
watermark_img(dpi,tmpdir,outfolder,matnum, img_file)
watermark_img(dpi,tmpdir,outfolder,template, img_file)
#Combining watermarked PDF pages into one PDF
filenames = [_ for _ in os.listdir(outfolder) if _[-4:] == ".pdf" and (_.split('.',1)[0]).split('_',1)[0] == matnum]
filenames.sort()
if len(filenames) > 0:
combine_all_pdfs(outfolder+'/',filenames)
@@ -205,12 +207,11 @@ if __name__ == '__main__':
starttime = time.time()
#Call watermarking pipeline in parallel
if cores > 1:
watermark_pdf_p = Pool(cores)
watermark_pdf_fun = partial(watermark_pdf,infolder,tmpdir,outfolder,dpi)
watermark_pdf_p.map(watermark_pdf_fun, pdf_files)
watermark_pdf_p.close()
watermark_pdf_p.join()
watermark_pdf_p = Pool(cores)
watermark_pdf_fun = partial(watermark_pdf,infolder,tmpdir,outfolder,dpi)
watermark_pdf_p.map(watermark_pdf_fun, pdf_files)
watermark_pdf_p.close()
watermark_pdf_p.join()
endtime = time.time()
print('All PDFs are watermarked and can be found in'+ outfolder +' folder')
Loading