Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to print FF (form feed) character?

Tags:

python

I do some old report conversion and need to add "new page" FF character. What's the syntax to print FF character from Python?

like image 397
olekb Avatar asked Jul 06 '17 17:07

olekb


People also ask

What is form feed on a printer?

Sometimes abbreviated as FF, form feed is a button or command on the printer that allows the advancement of a printer page. This feature was frequently used on dot matrix printers since nearly all of them used continuous feed paper rather than single sheets.

What is Auto FF on printer?

Auto FF. Off*/On. Allows you to print the remaining data without pressing Go.


1 Answers

Like this *Wikipedia article says Form Feed (FF) has decimal value 12 in ASCII. Which is 0x0c in hex:

Form feed is a page-breaking ASCII control character. It forces the printer to eject the current page and to continue printing at the top of another. Often, it will also cause a carriage return. The form feed character code is defined as 12 (0xC in hexadecimal) (..) In the C programming language (and other languages derived from C), the form feed character is represented as '\f'.

So you can:

print('\x0c',end='')

Or you can use - like @martineau says - use '\f':

print('\f',end='')

The end='' is used to prevent Python from printing an additional new line after the form feed character.

Note that it depends on the console (or the device that receives the stream) how the Form Feed is handled. Some consoles might ignore it. Others print a few blank lines, and a printer might for instance decide to start a new page.

like image 51
Willem Van Onsem Avatar answered Sep 19 '22 11:09

Willem Van Onsem