I coded it in Delphi 2007 because for some or other reason I couldn't get the functionality I wanted with TPrinter, I think one of the things was to send the name of the document to the printer so the customer could cancel the specific page that was printing.
Anyway, I think it can be adjusted to suite whatever basic need, and yes, it does not talk directly to the port but does in a sense bypass the dreaded canvas and fonts! Rename the object / class as needed! On Fri, Oct 5, 2012 at 4:24 PM, Stephen Posey <stephenlpo...@earthlink.net>wrote: > Since TRawPrinter is declared as "object" rather than "class", I'm > guessing the code is a hold over from Turbo Pascal for Windows/Borland > Pascal 7 and OWL, which didn't have the TPrinter object. > > Interesting code nonetheless: A real "bare-bones" wrapper for the Windows > Printer API; though it doesn't do "raw" printing in the sense of bypassing > the Printer API to talk directly to the port. > > Thanks for posting. > > Stephen Posey > stephenlpo...@earthlink.net > > -----Original Message----- > >From: Andre van Zuydam <an...@spiceware.co.za> > >Sent: Oct 4, 2012 12:53 PM > >To: Delphi-Talk Discussion List <delphi-talk@elists.org> > >Subject: Re: Printing Labels > > > >Hi K2RFP > > > >Just occured to me I had a similar problem, my client had pages of > vouchers > >that needed to be printed, minimum of 5 per line, each page has 20 > >vouchers, much like labels. > >You probably won't get away from the end doc feed, but changing the page > >size to be one row of labels will help you. > > > >In other words, keep the width of you label page but make the page height > >the height of the 1 row of labels, this will spool line by line. > > > >I also created a basic printer object to help me with what I wanted to > do, > >not sure why I did not use TPrinter, perhaps I didn't want to use Canvas > or > >wanted to use the default printer fonts > > > >TRawPrinter = object > > N : DWORD; > > DocInfo : TDocInfo1; > > function RWOpenPrinter (APrinter : String; ADocName: String = > 'print') > >: THandle; > > procedure RWStartPage (AHandle: THandle); > > procedure RWWriteLine (AHandle : THandle; ALine: String = #13#10); > > procedure RWClosePage (AHandle: THandle); > > procedure RWEndDoc (AHandle: THandle); > > procedure RWClosePrinter (AHandle: THandle); > > end; > > > >{ TRawPrinter } > > > >procedure TRawPrinter.RWClosePage(AHandle: THandle); > >begin > > EndPagePrinter(AHandle); > >end; > > > >procedure TRawPrinter.RWClosePrinter(AHandle: THandle); > >begin > > EndDocPrinter(AHandle); > > ClosePrinter(AHandle); > >end; > > > >procedure TRawPrinter.RWEndDoc(AHandle: THandle); > >begin > > EndDocPrinter(AHandle); > >end; > > > >function TRawPrinter.RWOpenPrinter(APrinter, ADocName: String): CARDINAL; > >var > > Handle : THandle; > >begin > > if not OpenPrinter(PChar(APrinter), Handle, nil) then > > begin > > Handle := 0; > > end; > > if (Handle <> 0) then > > begin > > DocInfo.pDocName := PChar(ADocName); > > DocInfo.pOutputFile := nil; > > DocInfo.pDataType := 'RAW'; > > end; > > StartDocPrinter(Handle, 1, @DocInfo); > > Result := Handle; > >end; > > > >procedure TRawPrinter.RWStartPage(AHandle: THandle); > >begin > > StartPagePrinter(AHandle); > >end; > > > >procedure TRawPrinter.RWWriteLine(AHandle: THandle; ALine: String); > >begin > > ALine := Aline+#13#10; > > WritePrinter(AHandle, PChar(ALine), Length(ALine), N); > >end; > > > >Anyway I hope this may provide you with a solution. > > > >On Wed, Oct 3, 2012 at 4:32 PM, K2RFP <rn...@verizon.net> wrote: > > > >> Steve: > >> Writing a procedure to handle a batch of labels is > >> not a problem but that is not what I want. As a ham > >> radio operator I have, from time to time, to send > >> a postcard to someone in my log book. So it is an > >> individual label and the procedure is not called for > >> every time I run the logbook program. So it doesn't > >> make sense for the printer to do a form feed to a > >> new page after printing one or two labels. > >> > >> I did some google searching and found out that > >> EndDoc always results in a form feed and a way > >> around it is to do a raw printing to the printer > >> port. I haven't tried that. Another way I'll try > >> is to set the physical size of the printer's page > >> to the height of the label. You would think there > >> would be an EndDoc2 procedure that does what EndDoc > >> does but stops the printer in its tracks so I would > >> not have to jump through hoops to do what I want. > >> > >> > >> > >> On 10/3/2012 9:55 AM, Stephen Posey wrote: > >> > >>> I'm not sure I understand the question here. > >>> > >>> Normally you don't call Printer.EndDoc until you're done printing. If > you > >>> have multiple labels to print, then you'll want to handle them as a > "batch" > >>> and compose them all onto your label page(s) before calling > Printer.EndDoc. > >>> > >>> If the number of labels you have to print is more than will fit on a > page > >>> of labels, then you'll call Printer.NewPage between page batches. > >>> > >>> If that doesn't clarify the situation then I'll need you to describe > your > >>> setup and exactly what you're trying accomplish in more detail. > >>> > >>> Stephen Posey > >>> stephenlpo...@earthlink.net > >>> > >>> -----Original Message----- > >>> > >>>> From: -K2RFP- <rn...@verizon.net> > >>>> Sent: Oct 2, 2012 1:25 PM > >>>> To: Delphi-Talk Discussion List <delphi-talk@elists.org> > >>>> Subject: Printing Labels > >>>> > >>>> I want to print individual 1-inch labels on fan-fold > >>>> tractor feed paper. The label prints okay but the > >>>> EndDoc statement causes thepaper to move to the next > >>>> page. How do I get it tomove to the next label? > >>>> > >>>> The printer does not have any setting for labels. > >>>> > >>>> > >>>> > >>>> ______________________________**____________________ > >>>> Delphi-Talk mailing list -> Delphi-Talk@elists.org > >>>> http://lists.elists.org/cgi-**bin/mailman/listinfo/delphi-**talk< > http://lists.elists.org/cgi-bin/mailman/listinfo/delphi-talk> > >>>> > >>> ______________________________**____________________ > >>> Delphi-Talk mailing list -> Delphi-Talk@elists.org > >>> http://lists.elists.org/cgi-**bin/mailman/listinfo/delphi-**talk< > http://lists.elists.org/cgi-bin/mailman/listinfo/delphi-talk> > >>> > >>> > >> ______________________________**____________________ > >> Delphi-Talk mailing list -> Delphi-Talk@elists.org > >> http://lists.elists.org/cgi-**bin/mailman/listinfo/delphi-**talk< > http://lists.elists.org/cgi-bin/mailman/listinfo/delphi-talk> > >> > > > > > > > >-- > ><http://spiceware.co.za> > >__________________________________________________ > >Delphi-Talk mailing list -> Delphi-Talk@elists.org > >http://lists.elists.org/cgi-bin/mailman/listinfo/delphi-talk > > __________________________________________________ > Delphi-Talk mailing list -> Delphi-Talk@elists.org > http://lists.elists.org/cgi-bin/mailman/listinfo/delphi-talk > -- <http://spiceware.co.za> __________________________________________________ Delphi-Talk mailing list -> Delphi-Talk@elists.org http://lists.elists.org/cgi-bin/mailman/listinfo/delphi-talk