By Manny Fernandez

May 22, 2025

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"]

 

Recent posts

  • I have run macOS in macOS with Parallels but... Full Story

  • Don't be confused with my other FortiNAC posts where... Full Story

  • This is the third session in a multi-part article... Full Story

  • Today I was configuring key-based authentication on a FortiGate... Full Story

  • Netcat, often called the "Swiss Army knife" of networking,... Full Story

  • At its core, IEEE 802.1X is a network layer... Full Story

  • In case you did not see the previous FortiNAC... Full Story

  • This is our 5th session where we are going... Full Story

  • Now that we have Wireshark installed and somewhat configured,... Full Story

  • The Philosophy of Packet Analysis Troubleshooting isn't about looking... Full Story