Re: Help wanted - Duplex printing
"Peter J. Holzer" <[email protected]>
| Newsgroups | gmane.comp.python.general |
|---|---|
| Message-ID | <p7bxddhodaafeuwglks7osj3e6hv4276qekl2qsnwj2jwoyxa6@b3qxli67taqa> |
On 2026-08-27 16:16:07 +0100, Rob Cliffe via Python-list wrote:
> I tried that; here is a hex dump of my concatenated file:
[...]
> 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.
You could just pad each files with newlines, like this:
#!/usr/bin/python3
import sys
lines_per_page = 72 # 12" fan-fold paper ;-)
for fn in sys.argv[1:]:
line_no = 0
with open(fn) as fh:
for line in fh:
print(line, end="")
line_no += 1
while line_no % lines_per_page != 0:
print()
line_no += 1
Of course this only works if the lines are short enough not to be
wrapped. Otherwise you'd have to implement line-wrapping, too.
I tend to agree with Mats: In this day and age converting to PDF and
printing that is probably best.
hjp
--
_ | Peter J. Holzer | Story must make more sense than reality.
|_|_) | |
| | | [email protected] | -- Charles Stross, "Creative writing
__/ | http://www.hjp.at/ | challenge!"
signature.asc
(application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEETtJbRjyPwVTYGJ5k8g5IURL+KF0FAmqSjccACgkQ8g5IURL+ KF2CLQ/+POqFcWivI3DhgllX22+HNMBlI8f1SEsrHah7WnqVuei1O7bMR3RhfE8O Yrni8Vi6CvKf/FoEvxfzTAJeSHsrChM7CtbpUy09OWgGi7sMUhuxQ3h2cR5CrLUX DGvXv9WIOWsUmt/Zz652f5JLgglo/DBWeiAgrUpeCn+jnWoDHSFt6AJTLOKZem7S Td+pul+xMD34+glKXCx6oNzwsKu2TFYtMYoSHT49xdGwvHIIUTo1deMpPa3r4j5X p8G61ciS3U9b9gOwbkDv1Fjtl7+Rhq6LcgaRKnMhOP4yaNitkCDDnfp5Vby3lv6e YPV3gLQTmk9KCopV51lSCT/BAlmvZY0HW3txOgypW1+KFTyo9HoXApUOQf844nxZ p2MxciwPl66odtfzu/pk4LfG2Q6Dsdof8GlgQ7+quxzmi3zPFBvnz/dvVXxZxF0F 87UUycMPOJebJH+MAWQPJ/TaCTvpW2BN1iyw0am/8NV1ACBlo614hGVgoRPrFbDc bmBMJnXUKjTQCShg921rbjA4tf93LmlEwRI4HQxt4WmGdHEgYPowZjK2Zqn8eTjr 56Ao9+4j8grbCxzkuyFv/y8PL4xxcQpBauK1AMpMLCmA6ZtKMypGEzDKIxZyOjsk hrybMxSNhnHjUj7ZlaQZTNAF9cTgrvwM7tcqk9zNmosC4DRoxZw= =+5gJ -----END PGP SIGNATURE-----