By Manny Fernandez

May 22, 2025

Extracting Registration Codes from PDF

Extracting Registration Codes from PDF

Have you ever ordered a bunch of Fortinet gear or services and forgot to add FortiDeploy to you order and now you are sitting with sometimes hundreds of PDF files containing the registration numbers you need to add to support.fortinet.com.  How much easier would it be to dump the contents of all the PDF Contract Registration Code Into a CSV file so you can add the codes faster and identify location, device name, serial number, date, etc.

As you can see in the graphic, It says Contract Registration Code however if you look at it using pdfplumber,  it displays ContactRegistrationCode without the spaces.  The idea is to have a folder containing all the PDFs.  Then we run the script and it will create an output csv file named contract_codes.csv (obviously you can modify the script to change it).  It will show the file name and the registration code.  In my example I ran it from my desktop in a folder named lic2 (For reference, I tried to run Optical Character Recognition (OCR) against the file and it did not work.

python3 get.py /Users/fernandezm/Desktop/lic2

[coding-blocks block="get-registration"]

 

Herdr: Run and Orchestrate AI Coding Agents From One Terminal

Herdr: Run and Orchestrate AI Coding Agents From One Terminal

Set up herdr for AI coding agents: install it, add the Claude Code and Codex integrations, isolate agents in worktrees, and let one agent...

Read More
tmux Tips and Tricks: Sessions, Panes, Use Cases and Rare Tidbits

tmux Tips and Tricks: Sessions, Panes, Use Cases and Rare Tidbits

Learn tmux tips and tricks: named sessions, a starter tmux.conf, logging, synchronize-panes, real use cases and rare tidbits.

Read More
iTerm2 AI Watches: Stop Babysitting Your Terminal and Get Alerts on Your iPhone

iTerm2 AI Watches: Stop Babysitting Your Terminal and Get Alerts on Your iPhone

Set up iTerm2 AI Watches so a linked AI chat tells you when a long job finishes or fails, then push the alert to...

Read More