Board index » cppbuilder » Re: Printing - Escape Sequence
Hans Galema
![]() CBuilder Developer |
Hans Galema
![]() CBuilder Developer |
Re: Printing - Escape Sequence2005-02-16 09:20:19 PM cppbuilder77 Thomas J. wrote: QuoteI tried to send escape sequences to the printer, Quotebut obviously it is not done by a new call to TextOut with the right X,Y parameter. Hans. |
Thomas J.
![]() CBuilder Developer |
2005-02-16 09:35:36 PM
Re:Re: Printing - Escape Sequence
The intention is the following:
I want to print labels on a label printer. And the aim should be to print a Label A and a Label B. After each second Label the cutter should cut. I assumes taht each label is a page. So I called NewPage(). But the printer will create a new job for each call of NewPage and for each new job the cutter willl work. So Label A and Label B are not together anymore. (I want to print 300 labels). The label printer company told me to send the esacep sequence F which is 0x00c a form feed. And thats what I try to do for hours and hours. I found out that another way it is possible to send escape sequnces. But this is workig without Canvas and acomponent which I'm using fpr printing Barcode needs a Canvas. So with the first snippet it is possible to send escape sequence but I cannot use because of the barcode. The second snippet force no form feed ---------------------------------------------------------------------------- ------------------ 1. OpenPrinter(printername, &PrnHandle, NULL); if (PrnHandle != NULL) { DOC_INFO_1 DocInfo; DocInfo.pDocName = "SessionName"; DocInfo.pOutputFile = NULL; DocInfo.pDatatype = "RAW"; if (StartDocPrinter(PrnHandle,1,(LPSTR)&DocInfo) <= 0) Application->MessageBox("StartDocPrinter", "Error", MB_OK); else if (StartPagePrinter(PrnHandle) <= 0) Application->MessageBox("StartPagePrinter", "Error", MB_OK); else if (!WritePrinter(PrnHandle,Help,strlen(Help),&size)) Application->MessageBox("WritePrinter", "Error", MB_OK); if (!EndPagePrinter(PrnHandle)) Application->MessageBox("EndpagePrinter", "Error", MB_OK); else if(!EndDocPrinter(PrnHandle)) Application->MessageBox("EndDoc", "Error", MB_OK); printer->EndDoc(); ClosePrinter(PrnHandle); } else { Application->MessageBox("Cannot find printer", "Error", MB_OK); } ---------------------------------------------------------------------------- ------------------ 2. char Help[1024]; sprintf(Help, "\x00c"); TPrinter* printer = Printer(); printer->BeginDoc(); printer->Canvas->TextOut(300, 300, "First page"); Escape(printer->Canvas->Handle, PASSTHROUGH, sizeof(Help), Help, NULL); printer->Canvas->TextOut(400, 400, "Next page"); printer->EndDoc(); Thanks fr your help "Hans Galema" < XXXX@XXXXX.COM >schrieb im Newsbeitrag QuoteThomas J. wrote: |
Hans Galema
![]() CBuilder Developer |
2005-02-16 10:23:57 PM
Re:Re: Printing - Escape Sequence
Thomas J. wrote:
QuoteI want to print labels on a label printer. QuoteAnd the aim should be to print a QuoteI QuoteBut the printer Quoteand for each new job the for that. A formfeed for TPrinter() is NewPage(). QuoteI found out that another way it is possible to send escape sequnces. QuoteOpenPrinter(printername, &PrnHandle, NULL); QuoteTPrinter* printer = Printer(); {smallsort} |
Hans Galema
![]() CBuilder Developer |
2005-02-16 10:26:31 PM
Re:Re: Printing - Escape Sequence
Hans Galema wrote:
QuoteForget about escape sequences. Use TextOut(X,Y, ...) to make new lines Hans. |
Thomas J.
![]() CBuilder Developer |
2005-02-16 10:43:55 PM
Re:Re: Printing - Escape Sequence
The paperformat is 9cm to 7,5cm. The labels are "endless". On one role are
1000 labels. The size of the paper (label) is set correct and I if I debug I get the correct dimension of the labe in pixel. One customer wants to have 2 lables together the next customers needs 4 label together. So each label represnets a page. Unfortunately NewPage force the printer to create a new job. This I can see on the display of the printer. But of course only one job you can see in "windows printer job window". I'm sure that is a bug in the driver of the printern and I will again the company why the hell NewPage force a new job ->cutter will cut. QuoteA formfeed for TPrinter() is NewPage(). QuoteForget about escape sequences. Use TextOut(X,Y, ...) to make new lines One solution is to destroy the cutter and cut by self - but 300 labels - forget it. The next solution will be that the stupid cutter cut EACH label and someone has to tabe up each pair. QuoteHere you mixed the raw printer with TPrinter(). That seems a QuoteThomas J. wrote: |
Hans Galema
![]() CBuilder Developer |
2005-02-16 11:01:11 PM
Re:Re: Printing - Escape Sequence
Thomas J. wrote:
QuoteThe paperformat is 9cm to 7,5cm. The labels are "endless". On one role are concernig the type of paper used. Now I still don't know how that paper looks like. I'm used to paper that is endless with labels glued on them. Then the labels have dimensions like X cm x Y cm. QuoteUnfortunately NewPage force the printer to create a new job. This I can see labels and then do a NewPage(). Or are there others drawbacks from 'a new job' which you did not mention? Please trim quotes when replying. Hans. |
Thomas J.
![]() CBuilder Developer |
2005-02-16 11:04:47 PM
Re:Re: Printing - Escape Sequence
I tested this. In the first case the windows printer job queue shows a
document with two pages, but in the second case only one page is shown in the queue. The result is the same. Two pages were printed. These means that Form Feed ist not the same as NewPage at least not for the Windows printer queue and maybe also not for the label printer. TPrinter* printer = Printer(); printer->BeginDoc(); printer->Canvas->TextOut(300, 300, "First page"); printer->NewPage(); printer->Canvas->TextOut(400, 400, "Second page"); printer->EndDoc(); and with escape sequence if (PrnHandle != NULL) { DOC_INFO_1 DocInfo; DocInfo.pDocName = "SessionName"; DocInfo.pOutputFile = NULL; DocInfo.pDatatype = "RAW"; if (StartDocPrinter(PrnHandle,1,(LPSTR)&DocInfo) <= 0) Application->MessageBox("StartDocPrinter", "Error", MB_OK); else if (StartPagePrinter(PrnHandle) <= 0) Application->MessageBox("StartPagePrinter", "Error", MB_OK); else { char page1[100]; sprintf(page1, "First page\n"); if (!WritePrinter(PrnHandle,page1,strlen(page1),&size)) { Application->MessageBox("WritePrinter", "Error", MB_OK); } else { WritePrinter(PrnHandle,Help,strlen(Help),&size); sprintf(page1, "Second page\n"); WritePrinter(PrnHandle,page1,strlen(page1),&size); } } if (!EndPagePrinter(PrnHandle)) Application->MessageBox("EndpagePrinter", "Error", MB_OK); else if(!EndDocPrinter(PrnHandle)) Application->MessageBox("EndDoc", "Error", MB_OK); ClosePrinter(PrnHandle); } else { Application->MessageBox("Drucker nicht gefunden", "Error", MB_OK); } "Thomas J." < XXXX@XXXXX.COM >schrieb im Newsbeitrag QuoteThe paperformat is 9cm to 7,5cm. The labels are "endless". On one role are |
Thomas J.
![]() CBuilder Developer |
2005-02-16 11:07:25 PM
Re:Re: Printing - Escape Sequence
Yes this kind of labels I use too. Endless paper ad labels glued on this
endless paper., sorry. "Hans Galema" < XXXX@XXXXX.COM >schrieb im Newsbeitrag QuoteThomas J. wrote: |
Hans Galema
![]() CBuilder Developer |
2005-02-16 11:15:41 PM
Re:Re: Printing - Escape Sequence
Thomas J. wrote:
QuoteThe result is the same. Two pages were printed. QuoteThese means that Form Feed ist not the same as NewPage at least not for the is written here. Just some specific sentences.). Hans. |
Thomas J.
![]() CBuilder Developer |
2005-02-16 11:51:09 PM
Re:Re: Printing - Escape SequenceQuoteWhat do you consider /two pages/ using endless paper ? the same. That means that I have to send a escape sequence to the printer. (I will test in the evening) FYI I'm testing now not with a label printer. (This one is located home) But the problem is not linked to a label printer. Because I'm also not able to send text, form feed sequence and again text to a printer using TPrinter. And that's my problem. QuoteBut what is your problem then when the result is the same ? cut what is wrong. The last test was only to find out if NewPage and sending a Escape Sequnce (Form Feed) is the same. So my only solution can be to find a way to send a Escape Sequence which is working in the context of TPrinter. |
Hans Galema
![]() CBuilder Developer |
2005-02-17 12:01:11 AM
Re:Re: Printing - Escape Sequence
Thomas J. wrote:
Quote>What do you consider /two pages/ using endless paper ? how many cm's the paper is forwarded with every NewPage(). You should configure -under windows- the printerdriver in such a way that for every NewPage() the paper is forwarded 2 or 4 labels. Which ever you want. Realise that using /endless paper/ you have to define yourself what should be taken as /a page/. Hans. |
Bob Gonder
![]() CBuilder Developer |
2005-02-17 02:45:19 AM
Re:Re: Printing - Escape Sequence
Thomas, please take a look at this again.
It is probably the way you need to do it. Hans might not have made himself clear to you. QuoteHans Galema wrote: PrintSomeLabels( int LabelsPerPage) { int LabelNumber = 0; do{ PrintLabel( LabelNumber ); }while( ++LabelNumber < LabelsPerPage ); NewPage(); /* cut the paper */ } PrintLabel( int LabelNumber ) { TextOut( X , (LabelNumber*LabelHeight)+Y , ... ); } An alternate method: int LabelNumber = 0; GetData(); while( !DataEof ) { PrintLabel( LabelNumber ); if( ++LabelNumber>= LabelsPerPage ) { NewPage(); LabelNumber = 0; }; GetData(); }; |
Thomas J.
![]() CBuilder Developer |
2005-02-17 07:47:55 PM
Re:Re: Printing - Escape Sequence
Thanks a lot but my english is not well enough.
You both are right, but my answer regarding the kind of label was "wrong". I checked it in the evening the wording of the printer and the the label are not endless in this context. This means between each label is gap see "image" below or use the link. And the cutter has to cut exact between the gap. And the customers are using different labels with different size of gap and therfor eI cannot your solution. But anyway - thanks for your help!! www.avery-zweckform.com/de1/main.jsp | | | ______________ | | | Label1.1 | | | |______________| | | ______________ | | | Label 1.2 | | | |______________| | | ______________ | | | Label 2.1 | | | |______________| | | ______________ | | | Label 2.2 | | | |______________| | |
Hans Galema
![]() CBuilder Developer |
2005-02-17 08:59:48 PM
Re:Re: Printing - Escape Sequence
Thomas J. wrote:
QuoteYou both are right, but my answer regarding the kind of label was "wrong". I paper. The customer just takes the labels from the paper. QuoteAnd with TextOut. Now when you do a NewPage() and thereby force the printer to cut, then the customer has to have adjusted the printerdriver to the /length of paper/. It is the responsability of the customer to define the pagelength. Hans. |
Hans Galema
![]() CBuilder Developer |
2005-02-17 09:20:06 PM
Re:Re: Printing - Escape Sequence
Hans Galema wrote:
QuoteThomas J. wrote: printer->BeginDoc(); printer->Canvas->TextOut(300, 300, "First page"); printer->NewPage(); printer->Canvas->TextOut(300, 300, "Second page"); printer->NewPage(); printer->Canvas->TextOut(300, 300, "Third page"); printer->EndDoc(); Now adjust the printerdriver -under windows itself- in such a way that the page has such a length that there will be cut after 1,2,3 or how many you like, labels. Or just do a BeginDoc()/EndDoc() for every cut. Once you have this ready then you can add the code for printing the labels themself. Hans. |