python - How to identify if a page of PDF contains text using PyPDF2? -


the original task crop pdf several seperated parts. have adjusted params complete task,but sometimes, croping method lead 'blank page' looks like,it has text(using extracttext method). want know how filter 'blank page' mentioned above.

below part of croping method:

original = 'input.pdf' target = 'output.pdf' pdf = pdffilereader(open(original, 'rb')) page in pdf.pages:     in range(4):         new_page = copy.copy(page)         if == 0:             # top left             new_page.mediabox.upperright = (285.5, 780)             new_page.mediabox.lowerleft = (20, 570)         elif == 1:             # bottom left             new_page.mediabox.upperright = (285.5, 400)             new_page.mediabox.lowerleft = (20, 190)         elif == 2:             # top right             new_page.mediabox.upperright = (572, 780)             new_page.mediabox.lowerleft = (306.5, 570)         elif == 3:             # bottom right             new_page.mediabox.upperright = (572, 400)             new_page.mediabox.lowerleft = (306.5, 190)         out.addpage(new_page)   open(target, 'wb') f:     out.write(f) 

here croped pdf: https://drive.google.com/open?id=0bxl6yv_hdnnymet0of9ru1baywm


Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -