Practical Business Python

Taking care of business, one python script at a time

Mon 29 January 2018

Building a PDF Splitter Application

Posted by Chris Moffitt in articles   

I recently had the need to take a couple pages out of a PDF and save it to a new PDF. This is a fairly simple task but every time I do it, it takes some time to figure out the right command line parameters to make it work. In addition, my co-workers wanted similar functionality and since they are not comfortable on the command line, I wanted to build a small graphical front end for this task.

One solution is to use Gooey which is a really good option that I cover in my prior article. However, I wanted to try out another library and decided to give appJar a try. This article will walk through an example of using appJar to create a GUI that allows a user to select a PDF, strip out one or more pages and save it to a new file. This approach is simple, useful and shows how to integrate a GUI into other python applications you create.

Read more...


Mon 16 February 2015

Creating PDF Reports with Pandas, Jinja and WeasyPrint

Posted by Chris Moffitt in articles   

Pandas is excellent at manipulating large amounts of data and summarizing it in multiple text and visual representations. Without much effort, pandas supports output to CSV, Excel, HTML, json and more. Where things get more difficult is if you want to combine multiple pieces of data into one document. For example, if you want to put two DataFrames on one Excel sheet, you need to use the Excel libraries to manually construct your output. It is certainly possible but not simple. This article will describe one method to combine multiple pieces of information into an HTML template and convert it to a standalone PDF document using Jinja templates and WeasyPrint.

Read more...