Send Text output to Printer

조회 수: 11 (최근 30일)
Jesse
Jesse 2011년 9월 13일
Hi all:
I am having difficulty with sending a text output to a print from the MATLAB framework. I tried using the command line "!print" but it won't work in selecting the user computer's default printing option. The print command in MATLAB apparently only supports figures. Additionally, it would be better served if I could access the printing GUI. Primarily this will be running on Windows 7 machines. I would greatly appreciate any assistance.
Cheers,
Jesse

답변 (2개)

Walter Roberson
Walter Roberson 2011년 9월 14일
What happens if you copy the text output to the MS Windows printer device, LPT1: ?
fid = fopen('LPT1:', 'wt');
fprintf(fid, 'Line 1\nLine 2\nLine 3\n');
fclose(fid)
I would, though, caution that these days not many desktop printers seem to accept plain text files and just print them out: if they can accept plain text files at all, they usually expect the text file to contain HPGL or else Postscript. The less expensive desktop printers usually expect binary files in some internal binary language.
So usually, these days, you do not want to send a text file to a printer: usually you want to send the text file to a printer driver that takes care of encoding the text however is needed for that particular model of printer. I am not sure if I ever knew how to send something to the MS Windows printer drivers from a program, though; if I did, I do not recall the method now.
  댓글 수: 1
Jesse
Jesse 2011년 9월 15일
Hi,
Thank you very much for you reply. I was unable to get that method to work, essentially for the very reason you had doubted it. In light of this, I decided to write a C# program to simply generate a print dialog that I could then just run through MATLAB. I appreciate you taking the time to assist me, regardless.
Cheers!

댓글을 달려면 로그인하십시오.


Jan
Jan 2011년 9월 14일
There is a generic text printer driver for Windows, see e.g. http://support.mfm.com/support/std_procedures/xpgenericprinter.html.
Just ask Google for more information: http://www.google.de/search?q=Windows+Text+printer+driver
  댓글 수: 1
Walter Roberson
Walter Roberson 2011년 9월 14일
This appears to be the opposite of what is desired. The poster is trying to send text to a real printer to have it printed, whereas the driver referenced here is for printing to a file instead of a real printer.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Desktop에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by