I just tried your code with a PDF printer and it worked correctly.
] and StartPage
] both have a return value that specifies success or failure.
You might want to check the returns values to see if they return success. Either code to check the return value or debug the program to see what is returned.
I would also skip the color printing for now by commenting out the line:
SetTextColor( hPrinter, 0x0000FF );
You might also want to increase the print coordinates in case you are printing outside the margins of the page:
TextOut( hPrinter, 1000, 1000, "Hello, World!", 13 );