Welcome, guest | Sign In | My Account | Store | Cart

This recipe shows how you can generate a Windows process list or task list (basically, a list of running processes, with some information about each of them), to a PDF file, using the Windows TASKLIST command along with the xtopdf toolkit. The list is sorted in ascending order of memory usage of the processes, before writing it to PDF.

It differs somewhat from other xtopdf recipes, in that no additional code needs to be written, over and above what is already in the xtopdf package. We just have to use the needed commands there, in a series of commands or a pipeline.

However, one can still write additional code, by modifying the program used (StdinToPDF.py), if needed, to customize the PDF output.

Batch, 16 lines
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
1: Run TASKLIST and redirect its output to a text file.

$ tasklist > tasklist.out

2: Sort the file into another file.

$ sort /+65 tasklist.out > tasklist.srt

(Sort the output of TASKLIST by the character position of the Mem Usage field.)

3: Go edit tasklist to put the header lines back at the top :)
[ They get dislodged by the sort. ]

4: Pipe the sorted task list to StdinToPDF, to generate the PDF output.

$ type tasklist.srt | python StdinToPDF.py tasklist.pdf

More details, and sample output, are available here:

http://jugad2.blogspot.in/2015/12/generate-windows-task-list-to-pdf-with.html

If you want to customize the output, e.g. such as adding a header or footer, you can edit the file StdinToPDF.py which is part of the xtopdf package.

xtopdf is at https://bitbucket.org/vasudevram/xtopdf

This guide shows how to set up and use xtopdf:

http://jugad2.blogspot.in/2012/07/guide-to-installing-and-using-xtopdf.html