[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Printing a RFC on non-US PAPERsize



On Mon, Nov 26, 2001 at 11:02:36AM +0100, Lambrecht, Joris wrote:
> 
> I'm getting a stomach ache trying to figure out how best to print an RFC
> without having the impression i'm printing drafts of a draft. The formatting
> goes bananas when i try to print it on any known paper size (A4 Letter ...).
> Does there exist a website, a tool or a procedure to make rfc's printable in
> an adequate way ?

Hi,

I've used a simple script that strips all white space between the end of
the page and the start of the next space and inserts a page break there
instead.  Basically, that should modify the drafts so that they can be
properly printed on any paper size.  Though, I've only tested A4.

I'll attach my boosted script that also downloads the requested
rfc/draft and then reformats it as described above.  But beware, the
logic to determine the location of page break is extremely stupid.
Don't count on getting the rfc's intact :)

Oh, and mpage -2 works nicely for the printing part...


-- 
Tommi Komulainen                                 Tommi.Komulainen@iki.fi
GPG 1024D/68388EE6    6FD6 DD79 EB38 BF6F 3533  09C0 04A8 9871 6838 8EE6
#!/usr/bin/env python

SERVER,RFCDIR,DRAFTDIR = 'ftp.funet.fi','/rfc','/internet-drafts'

import sys
if len(sys.argv) < 2:
    sys.stderr.write("""\
usage: rfc-get [rfc-number | draft-name] ...
""")
    sys.exit(1)

import ftplib,os

ftp = ftplib.FTP(SERVER)
ftp.set_pasv(1)
ftp.login()


import re
end_re =   re.compile(r'^\S+.+\[Page \d+]\s*$')
start_re = re.compile(r'^(Internet|RFC)\s.+$')

for arg in sys.argv[1:]:
    if arg[:3] == 'rfc': arg = arg[3:]
    elif arg[:6] == 'draft-': arg = arg[6:]
    if arg[-4:] == '.txt': arg = arg[:-4]
    try: 
	arg = int(arg)
	filename = 'rfc%d.txt' % arg
	dir = RFCDIR
    except ValueError:
	filename = 'draft-%s.txt' % arg
	dir = DRAFTDIR

    print 'retrieving %s/%s' % (dir,filename)

    ftp.cwd(dir)

    printable = 1
    file = open(filename, 'wt')

    def printer(line):
	global file,printable
	if end_re.match(line):	
	    file.write(line + '\n')
	    file.write('\f\n')
	    printable = 0
	elif start_re.match(line):
	    file.write(line + '\n')
	    printable = 1
	elif printable:
	    file.write(line + '\n')

    try:
	try: ftp.retrlines('RETR ' + filename, printer)
	finally: file.close()
    except ftplib.error_perm, err:
	print err
	os.unlink(filename)


ftp.quit()

Attachment: pgpsQsJoeuanA.pgp
Description: PGP signature


Reply to: