I'm assuming you got the code sample, but I'll repost it anyway.
Code:
#include <windows.h>
int main(void)
{
HDC hdc = NULL;
DOCINFO di = { 0 };
TEXTMETRIC tm = { 0 };
ULONG y = 10;
/* Get a device context for the printer. We should use PrintDlg to retrive an HDC
* or at least GetDefaultPrinter to get the printer name to use. */
hdc = CreateDC(TEXT("WINSPOOL"), TEXT("HP DeskJet 712C"), NULL, NULL);
/* Start the document. */
di.cbSize = sizeof(DOCINFO);
di.lpszDocName = TEXT("Print Test");
di.fwType = 0;
StartDoc(hdc, &di);
StartPage(hdc); /* Start a page. */
/* Set the alignment mode so we can output text and it will automatically be horizontally positioned. */
SetTextAlign(hdc, GetTextAlign(hdc) | TA_UPDATECP);
/* Get the height of text. */
GetTextMetrics(hdc, &tm);
/* Set start position. */
MoveToEx(hdc, 10, y, NULL);
/* We can now use the GDI functions to output content. */
TextOut(hdc, 0, 0, TEXT("Hello World"), lstrlen(TEXT("Hello World")));
/* Move to new line. */
MoveToEx(hdc, 10, y += tm.tmHeight + tm.tmExternalLeading, NULL);
TextOut(hdc, 0, 0, TEXT("Bye World. "), lstrlen(TEXT("Bye World ")));
TextOut(hdc, 0, 0, TEXT("Maybe not!"), lstrlen(TEXT("Maybe not!")));
/* Move to new line. */
MoveToEx(hdc, 10, y += tm.tmHeight + tm.tmExternalLeading, NULL);
TextOut(hdc, 0, 0, TEXT("OK Now!"), lstrlen(TEXT("OK Now!")));
EndPage(hdc); /* End page. */
EndDoc(hdc); /* End document. */
DeleteDC(hdc); /* Cleanup hdc. */
return 0;
}