All online search relates printing a df in console. Does python have the capability to print a df directly (without saving it as a file in windows) ?
To clarify - It should not be saved as a pdf/excel/any other file. Can we print (to paper) the dataframe directly?
As far as my exploration, I think we cannot print anything (string / graph / etc) directly from Python. We might always have to do it via a file (doc/excel/pdf). Please correct me if wrong.
You can use win32print
module.
Please read the following documents first:
Applications that print create a printer device context (DC). When an application creates a printer DC, the spooler performs necessary tasks such as determining the location of the required printer driver and then loading that driver. The print spooler also determines the data type used to record the print job.
The print spooler supports the following data types:
- Enhanced metafile (EMF).
- ASCII text.
- Raw data, which includes printer data types such as PostScript, PCL, and custom data types.
Custom data types can be added to the spooler by installing additional printer drivers and print processors. A print job is a document stored internally and encoded by using one of the supported data types, and a print job may contain one or more pages of output.
The spooler deletes these files when the job has successfully printed.
It is indeed possible to print jobs directly without saving them as files, because the spooler will delete these files directly after printing.