Where is pdfwriter.py located?

Hello I am starting to learn scripting and I was following the instructions in this link (Converting a txt to pdf with python’s pdfrw). Link here: https://www.cyberciti.biz/faq/unix-howto-read-line-by-line-from-file/ Below is the sample code provided in the link:

#!/bin/bash
# Usage: Create pdf files from input (wrapper script)

# Author: Vivek Gite <Www.cyberciti.biz> under GPL v2.x+
#---------------------------------------------------------

#Input file
_db="/tmp/wordpress/faq.txt"

#Output location
o="/var/www/prviate/pdf/faq"

_writer="~/bin/py/pdfwriter.py"

# If file exists 
if [[ -f "$_db" ]]
then
    # read it
    while IFS='|' read -r pdfid pdfurl pdftitle
    do
        local pdf="$o/$pdfid.pdf"
        echo "Creating $pdf file ..."
    #Genrate pdf file
        $_writer --quiet --footer-spacing 2 
        --footer-left "nixCraft is GIT UL++++ W+++ C++++ M+ e+++ d-" 
        --footer-right "Page [page] of [toPage]" --footer-line 
        --footer-font-size 7 --print-media-type "$pdfurl" "$pdf"
    done <"$_db"
fi

As you will notice, he has the _writer path set to be ~/bin/py/pdfwriter.py, which I have tried to set up by doing sudo apt-get python-pdfrw, after I run this command the output tells me python-pdfrw is up to date and it has been installed. So now I am trying to find pdfwriter.py and I can’t. I checked /usr/bin/ and /usr/lib/python3.5 as well as /usr/lib/python2.7. I have also run locate pdfrw and I can’t find it. I will appreciate your help! Thanks!

Answer

In general you can obtain a list of a package’s installed files on Debian-based systems using dpkg -L e.g.

dpkg -L python-pdfrw

or search for a specific file using dpkg -S

dpkg -S pdfwriter.py

whose output (if successful) should include the full path to the file.

In this case you will likely find the location to be /usr/lib/python2.7/dist-packages/pdfrw/pdfwriter.py

Leave a Reply

Your email address will not be published. Required fields are marked *