If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Sending a text file to the printer using win32 API

Test1.txtHi all,
I got a project in that,Text file creating by application should get in to print.So i want to send the text file to the printer using win 32 API.I don't have any idea about Printer device driver.Please Give some idea.i created Print Dialog Box using PRINTDLG Structure,After that while click on PrintButton the text file shuold get print.

Re: Sending a text file to the printer using win32 API

Thanks for your great comment.I tryed that sample code with PrimoPDF and i can generate a pdf file also.Next my question is how to pass a file(text )content into the TextOut function.Any help would be greatly appreciated.
Thanks &Regards
Manju

Re: Sending a text file to the printer using win32 API

You don't pass a full text file content into TextOut(). You need to read the text file line and line and pass each line to TextOut() specifying the appropriate x, y coordinates for the position of the individual text line in the device context. x would usually be a fixed constant for each line, and the y value would be incremented for each line by the height of the selected font in the device context.

All advice is offered in good faith only. You are ultimately responsible for effects of your programs and the integrity of the machines they run on.

Re: Sending a text file to the printer using win32 API

Originally Posted by 2kaud

You don't pass a full text file content into TextOut(). You need to read the text file line and line and pass each line to TextOut() specifying the appropriate x, y coordinates for the position of the individual text line in the device context. x would usually be a fixed constant for each line, and the y value would be incremented for each line by the height of the selected font in the device context.

This code is working only for 1 page and Allignment is proper only for PrimoPDF.I have some doubt
1.How to change the Printer DC's Scaling factor,font etc.If i changing tht Scaling factor. will it work with all printer?
2.What modification i have to do on

Re: Sending a text file to the printer using win32 API

Originally Posted by VictorN

It is because you call StartPage/EndPage only once.

If iam calling StartPage/EndPage multiple time multiple page can print.But i don't know howmany lines will be there in 1 page.How to get that number?Is it printer depended or programatically setting one?

Re: Sending a text file to the printer using win32 API

Use GetDeviceCaps() with an index of VERTRES. This will return the height in pixels of the printable area of the page. When the ypos to which you are printing exceeds this area (or exceeds a fixed amount below this value), then start a new page.

* The Perfect Platform for Game Developers: Android
Developing rich, high performance Android games from the ground up is a daunting task. Intel has provided Android developers with a number of tools that can be leveraged by Android game developers.

* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.