On 27/08/2026 16:16, Rob Cliffe via Python-list wrote:
Thanks Pierre and MRAB.
I tried that; here is a hex dump of my concatenated file:


16:09:12 R:\DSPR>dump ShortDocument3.txt
File ShortDocument3.txt Size 60 (hex 3C) bytes
00000000:  54 68 69 73 20 69 73 20 74 68 65 20 66 69 72 73  |This is the firs| 00000010:  74 20 64 6F 63 75 6D 65 6E 74 2E 0D 0A 0C 54 68  |t document...♀Th| 00000020:  69 73 20 69 73 20 74 68 65 20 73 65 63 6F 6E 64  |is is the second| 00000030:  20 64 6F 63 75 6D 65 6E 74 2E 0D 0A              | document...    |


but no dice; it printed the whole thing on one sheet, with the form feed printed as a
thick-headed up-arrow character at the start of the second line.
It's looking as if it will only switch sides when the first side is full.

[snip]
Apparently you need to print in "RAW" mode, otherwise the printer driver will just discard the Form Feeds.

I asked Copilot, and it came up with this example code (not tested because I'm on Linux now). Good luck!


import win32print
import win32api

printer_name = win32print.GetDefaultPrinter()
hPrinter = win32print.OpenPrinter(printer_name)

doc_info = {
    "pDocName": "Raw FF Test",
    "pOutputFile": None,
    "pDatatype": "RAW"
}

win32print.StartDocPrinter(hPrinter, 1, doc_info)
win32print.StartPagePrinter(hPrinter)

with open("myfile.txt", "rb") as f:
    data = f.read()
    win32print.WritePrinter(hPrinter, data)

win32print.EndPagePrinter(hPrinter)
win32print.EndDocPrinter(hPrinter)
win32print.ClosePrinter(hPrinter)

--
https://mail.python.org/mailman3//lists/python-list.python.org

Reply via email to