Gura
Gura

Reputation: 330

Zebra-printer TTP 2030 does not work

I'm trying to print "Hello World" in a Zebra Printer TTP 2030.

std::ofstream of;

of.open("Zebra TTP 2030");
if (of.is_open())
{
  debug(std::string("open : ok"));

  of << ticket.generateCode(); // return std::string
                               // ^XA^FO50,50^ADN,10,10^FDHello World^FS^XZ
  of.flush();
  of.close();
}
else 
  debug(std::string("open : ko"));

In the console, "open : ok" is trace.

I'm on a Microsoft XP Pro (VM). I'm working on Visual Studio 2010. The printer is setup on the VM.

Does someone know why a ticket is not created?

Upvotes: 1

Views: 651

Answers (2)

Captain Giraffe
Captain Giraffe

Reputation: 14705

The way to print stuff from the command line is with print. Print, TechNet

So you can achieve what you are asking by invoking print from your application. E.g.

#include<fstream>
#include<string>
#include<cstdlib>

void print_to_file(string filename){
    std::ofstream printer(filename);
    printer<<"Hello";
}

//create file with contents to print
int main(){
    std::string filename("print_this.tmp");
    print_to_file(filename);
    std::string command("print \\d:\\\\ServerName\\PrinterName ");
    std::system(command + filename);
}

As noted by the TechNet article, you have a few options for the printer name.

Upvotes: 1

molbdnilo
molbdnilo

Reputation: 66431

You've created a text file called "Zebra TTP 2030" and your text is in there.

C++ has no standard way of sending output to a printer - you'll have to consult the Microsoft help to see how it's done.

Upvotes: 2

Related Questions