Searchable, syntax highlighted 3270 terminal screen as pdf

To print your terminal screen into a pdf file, execute the following steps:

1. Requirements

2. Print the terminal content into a html file

  • In the 3270 terminal emulator navigate to the screen you want to print
  • Open the “Enter Action” Dialog
    • in x3270: from the menu select: File -> Execute an Action
    • in x3270: from the menu select: File -> c3270> Prompt
  • Enter the following action, where filename is the name of the output file:
    printText(html, filename.html)

3. Convert the html to a pdf  file

First convert the filename.html file to pdf using wkhtmltopdf:

wkhtmltopdf filename.html filename.pdf

Then crop the pdf:

pdfcrop filename.pdf filename.pdf

Those two steps produce the following result: filename

4. Change the color

To invert the colors in the filename.pdf file run the following command:

./pdfinvert.rb filename.pdf filenameInverted.pdf

You can also specify a colorfile, which contains a colormap to replace the colors in the pdf by another specified color in the map:

./pdfinvert.rb -c colorfile filename.pdf filenameColored.pdf

My colorfile:

00 #000000 #ffffff
00 #ffffff #1d1f21
00 #00bfff #3971ed
00 #ff0000 #cc342b
00 #ffc0cb #a36ac7
00 #00ff00 #198844
00 #40e0d0 #39c6ed
00 #ffff00 #fba922

To learn more about the colorfile, read the documentation of pdfinvert.rb.

After changing the colors, crop the pdf one last time:

pdfcrop filenameColored.pdf filenameColored.pdf

The result looks like this: filenameColored

 

Update: replaced colorfile.

Leave a Reply

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