# Desktop pdf converter

Our desktop pdf converter is useful for clients who have a folder on the computer which contains a number of pdfs that they would like to convert. For example in credit process where teams store pdfs in a shared folder. The desktop converter is a command-line tool which looks through a folder, finds all the statements contained therein, and then converts them in place[1] to a .csv.

NOTE: the desktop pdf converter is currently called spike-pdf-cli.

The tool must be installed on your machine, along with it's dependencies (Node.js), and occasionally updated (if we release fixes or new features).

# Usage

NOTE: @spike/pdf-cli is installed as an executable script called spike-pdf-cli (see package.json:bin (opens new window))

spike-pdf-cli <command>

Commands:
  spike-pdf-cli configure  Configure the tool with your keys
  spike-pdf-cli folder     Recurse through a folder and process all .pdfs found
  spike-pdf-cli single     Process a single .pdf
  spike-pdf-cli combine    combine .json output from previously processed pdfs into a single .csv

Options:
  --version  Show version number                                                           [boolean]
  --help     Show help                                                                     [boolean]
1
2
3
4
5
6
7
8
9
10
11

# Demo

asciicast (opens new window)

# How to video

This video shows the desktop converter in action. NOTE: link below opens in YouTube - make sure that you have YouTube > Setting > Quality = 1080p (or at least 720p) in order to see the text in the video.

How to use the desktop pdf converter (opens new window)

# Installation

  • Install Node.js

  • Install[2] spike-pdf-cli

    • Run a terminal e.g. on windows: Start > run > cmd.exe

    • Then

      npm i -g @spike/pdf-cli # creates global bin = spike-pdf-cli
      
      1
  • Configure spike-pdf-cli

    • If you haven't already, create an account on Spike (opens new window)

    • Now obtain your token from settings (opens new window)

    • Run the configuration process:

      # run the tool in configure mode
      spike-pdf-cli configure
      # example output
      First run detected, creating config file...
      Enter you token: # paste your token here
      wrote config file: C:\Users\ilan\.spike\config.json
      
      1
      2
      3
      4
      5
      6
      • this will write your keys to the .spike\config.json file in your home directory
  • Setup a .bat file to run spike-pdf-cli

    • this saves you from having to run DOS each time and type in the command

    • you can just double click on the .bat file to run spike-pdf-cli

    • create a file called run-spike.bat with the following contents and put it on your desktop:

      # change `C:\pdfs` to your folder
      spike-pdf-cli folder --folder C:\pdfs --quiet
      
      1
      2
    • You can see the full list of commandline options below

# Update

When we release a new version of spike-pdf-cli you will need to run a terminal (e.g. cmd.exe on Windows) and enter the following:

npm update -g @spike/pdf-cli@latest
npm install -g @spike/pdf-cli@latest
1
2

You can get the version number of your tool like so:

spike-pdf-cli -v
1

Compare this to the latest released version available here:

# How it works

  1. You point spike-pdf-cli at a folder and it will find all the pdfs within the folder (including sub directories) and then uploads each one to the Spike API for processing.
  2. The Spike API extracts transactions and other data (like account holder information) from the statement and returns it to the spike-pdf-cli.
  3. The spike-pdf-cli creates a .csv next to the .pdf, containing all the financial transactions from the .pdf.
  4. It writes a summary of all the files processed to date to folder.csv - in the folder which you indicated above.

# Use a filter

Note - we use minimatch (opens new window) for filtering. The pattern is applied to the full file path e.g. to filter the following to ABSA only

Pdfs found:
 /pdfs/ABSA/1.pdf
 /pdfs/ABSA/2.pdf
 /pdfs/NED/3.pdf
1
2
3
4

Use the pattern:

  • **/ABSA/*"

e.g.

--------------------------------
Which pdfs do you want to process:
--------------------------------

1. all
2. new files only
3. new + prev errors
4. filename matching a pattern
5. none = quit
Enter option: 4
--------------------------------
Enter pattern: **/ABSA/*
1
2
3
4
5
6
7
8
9
10
11
12

# Commandline arguments

Run the following to get a list of the current arguments:

spike-pdf-cli --help
1

  1. i.e. it writes a .csv file next to the original .pdf file using the same filename. ↩︎

  2. you can also run spike-pdf-cli directly without installation using npx @spike/pdf-cli ↩︎

Updated: 7/21/2021, 9:29:43 AM