Greenbar…quick fix?

Well it started that way. My Python greenbar program stopped working because I updated my system and a PDF module I used PyPDF2, had become deprecated. I hate when that happens. They went back to pypdf, however a simple name change wouldn’t make it work.

To recap perhaps due to my lack of understanding of reportlab, the main module that does most of the work…creates the greenbar listing. There were 2 problems with the output listing…

  • A beginning blank page
  • The right margin was too wide

Well PyPDF2 (now deprecated) let me fix both problems.

I saw where there were other versions of pyPDF2…pyPDF3, pyPDF4. What a mess it seemed to me. Trying to fix a previously working program, pyPDF2 recommended pypdf. But I quickly got discouraged. Stack overflow showed an example of pyPdf…not the same as pypdf. I just wanted a quick and easy way to fix this problem. The worse problem IMHO was the beginning blank page, pdfrw did that pretty easily. You just write out only the pages you want.

Then I found pdfCropMargins, pretty self describing. A command line program (with a lot of options) that can also be called by Python. Once you figured the many may options it was pretty easy…and one line. In my case…crop([“-p4”, “50”, “70”, “100”, “60”, output_file]). the 50, 70, 100, 60 are percentages of the margins (L, B, R, T) to keep. As you can see I also cropped the bottom and top, for a more uniform look.

To do all this I needed to get Python Virtual environments working again too. And of course the Ubuntu way isn’t the normal pip way.

So once again my greenbar quick fix…not so quick, is working.