-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathprintqueuetest.cpp
52 lines (44 loc) · 1.07 KB
/
printqueuetest.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include <stdio.h>
#include <string.h>
#include "stp_support/printerqueues.h"
static char *getfilename(void *userdata)
{
return(strdup("/tmp/testprintcapture"));
}
int main(int argc,char **argv)
{
struct pqinfo *pq;
if((pq=pqinfo_create()))
{
char *message="This is a quick test of printing...\n";
int pcount=pq->GetPrinterCount(pq);
int i;
printf("%d printer queues available\n",pcount);
for(i=0;i<pcount;++i)
{
const char *pn=pq->GetPrinterName(pq,i);
const char *driver;
printf("Printer: %s\n",pn);
pq->SetPrinterQueue(pq,pn);
driver=pq->GetDriver(pq);
if(driver)
printf("(using driver: %s)\n",driver);
else
printf("(driver unknown)\n");
}
#ifdef WIN32
pq->SetPrinterQueue(pq,"Epson Stylus Photo R300");
pq->SetGetFilenameCallback(pq,getfilename,NULL);
#else
pq->SetPrinterQueue(pq,PRINTERQUEUE_CUSTOMCOMMAND);
pq->SetCustomCommand(pq,"cat >test.prn");
#endif
pq->InitialiseJob(pq);
pq->InitialisePage(pq);
pq->WriteData(pq,message,strlen(message));
pq->EndPage(pq);
pq->EndJob(pq);
pq->Dispose(pq);
}
return(0);
}