TextPad - Strange Printing Behavior

I’ve been tasked with resolving an issue that involves printing ( my favorite /s ).

A console application used in Windows 10 and Windows 11 is not printing certain files when it should.

Printing is handled by TextPad using the -p command line parameter and passed a filename.

To reproduce the issue, I found the file that is not printing which is named PRNOUT.P12. I attempted to call TextPad from the command line with the -p parameter and pass the PRNOUT.P12 file to see what, if anything, happens. The print dialog comes up, queues, and goes away. This is printing to the default printer, a Brother MFC-L1727DW laser over wifi connection ( grumble ). Nothing prints.

If I change the default printer to Microsoft Print to PDF printer, it will prompt to save the file when attempting to print the file from the command line via TextPad.

If I change the default printer back to the Brother printer, it looks like it prints, but it doesn’t do anything on the machine.

Short of a TCPdump to see if anything was actually being sent to the printer, I decided to run a few other tests.

I made a copy of PRNOUT.P12 and named it PRNOUT.P12.copy and passed the new file to TextPad to print. It printed to the Brother printer just fine.

I created a test file (echo test > TEST.P12) and sent it to TextPad command line printer; it printed just fine to the Brother.

I know a P12 file in Windows contains a cryptographic certificate for PKCS#12 - so maybe Windows is filtering this somehow, or maybe the printer is doing something with this file when it is sent to the queue. I think it’s important to mention that the printer is added as a TCP/IP printer.

I decided to update the firmware on the printer, update Windows and reboot everything.

Tested everything again; failure to print the PRNOUT.P12 file. It fails to print any file ending in .P12 to the Brother printer.

Another important note. If I open the PRNOUT.P12 file, or any P12 created test file directly in TextPad and then print from the File menu, it prints just fine.

Another note. If I use notepad /p PRNOUT.P12 it prints just fine as well. I can’t use this method because the console application specifically calls textpad.exe -p <filename>.

I’m at a loss here and have tested both TextPad 7.x and TextPad 8.x to no avail.

I’m pointing my finger at TextPad. But why did this problem just start? I’ve also disabled any security suite on the system as a test measure.

Tests Performed: Printing to Brother MFC-L2717DW

FAIL: textpad.exe -p PRNOUT.P12

SUCCESS: textpad.exe -p PRNOUT.P12.copy

FAIL: textpad.exe -p test.P12

SUCCESS: notepad.exe /p PRNOUT.P12

Tests Performed: Printing to Microsoft Print to PDF

Success: textpad.exe -p PRNOUT.P12

Tests Performed: Opening File and Printing

Success: textpad.exe File > Open > PRNOUT.P12; File > Print

Workaround

Since I’ve found that a batch file handles some of this, I’ve modified the batch file to change the name of the file to then pass it to the printer and it is working. The binary is a Watcom C/C++ that I’ve been trying to get through to make a more permanent change but haven’t had much luck as of this writing.

Here’s what the batch file looks like.

tpad.bat

Original:

c:\progra~2\textpa~1\textpad.exe %1 %2

Modified:

@echo off
setlocal

set _filename=%~n2
set _extension=%~x2

IF /I "%_extension%" == ".P12" (
type %2 > %_filename%.P12.tmp
c:\progra~2\textpa~1\textpad.exe -p %_filename%.P12.tmp
) ELSE (
c:\progra~2\textpa~1\textpad.exe %1 %2
)