virtual printer to python

I looking for advice, how to make this. I need make virtual printer, and when I will sent any text file(word, excel, pdf) to this printer, I want, that my python script can get this data and parse it to variable. Just windows platform. Any idea?

Answer

Here I have printed this web page from Edge using Windows generic text printer

enter image description here

It was a stock method for extracting text to use the Generic/Text Only virtual printer since the days of pre windows. The results are highly variable.

enter image description here
enter image description here
enter image description here
enter image description here
enter image description here
enter image description here

Having shown you it is possible. I will add that the results are often disappointing and frustrating to work with., for many reasons.

Thus it is better to work with a Programable (API) replacement such as one that may OCR etc.

For example try out one that formats text layout

enter image description here