• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 294
  • Last Modified:

Using a MATRIX-printer!

(Im not sure that I spell it right...)

How do I print a single line on a MATRIX-printer?
0
hutelihut
Asked:
hutelihut
  • 6
  • 3
  • 2
  • +1
1 Solution
 
VSFCommented:
Hope this helps!
VSF
www.victory.hpg.com.br
www.enge.cjb.net

procedure TForm1.Button1Click(Sender: TObject);
var
F : TextFile; i : integer;
begin
AssignFile(F,?LPT1');
Rewrite(F);
i := 0;
Writeln(F,'Print Test - Line 0');
Writeln(F,'Print Test - Line 1');
Writeln(F,#27#15+'Print Test - Line 2');
Writeln(F,#27#18+'Print Test - Line 3');
Writeln(F,#12); // Eject Page
CloseFile(F);
end;
0
 
VSFCommented:
Sorry for the "?"
Please consider this corrected code:

procedure TForm1.Button1Click(Sender: TObject);
var
F : TextFile; i : integer;
begin
AssignFile(F,'LPT1');
Rewrite(F);
i := 0;
Writeln(F,'Print Test - Line 0');
Writeln(F,'Print Test - Line 1');
Writeln(F,#27#15+'Print Test - Line 2');   //Compressed
Writeln(F,#27#18+'Print Test - Line 3');   //Expanded
Writeln(F,#12);                           // Eject Page
CloseFile(F);
end;
0
 
hutelihutAuthor Commented:
aaa...we got a problem!

This does'nt work on a matrix-printer.

The matrix-printer has no pageheight, because the paper is one long tail of papers.

Closefile just think that its a A4-paper-format, and then prints a lot of empty lines, so it fits with one page (or something like that).

But I don't really know very much about Matrix-printers (actually I don't know anything at all), so the problem could also be because of the settings or so on...
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
YodaMageCommented:
Writeln(F,#12); // Eject Page

If you don't want to eject the page, then don't.

Most dotmatrix printers also have dip swtches that control certain operations like ejection, font size, emulation...look in the manual.
0
 
VSFCommented:
If you want to set paper size the use the canvas like this:
This should cover all your problems!
VSF
www.victory.hpg.com.br

procedure TForm1.Button1Click(Sender: TObject);
var
Device : array[0..255] of char;
Driver : array[0..255] of char;
Port   : array[0..255] of char;
hDMode : THandle;
PDMode : PDEVMODE;
VMULTA,VVALOR:REAL;
begin
  DataModule1.TabBoletos.First;
  while not DataModule1.TabBoletos.Eof do
  Begin
    Printer.GetPrinter(Device, Driver, Port, hDMode);
    If hDMode <> 0 then
       begin
       pDMode := GlobalLock( hDMode );
       If pDMode <> nil then
          begin
          pDMode^.dmPaperSize   := DMPAPER_USER;
          pDMode^.dmPaperWidth  := 1600;   // Paper width
          pDMode^.dmPaperLength := 1020;  // Paper Length
          pDMode^.dmFields := pDMode^.dmFields or DM_PAPERSIZE;
          GlobalUnlock( hDMode );
          end;
       end;
       Printer.BeginDoc;
       Printer.Canvas.Pen.Width := 5;
       Printer.Canvas.Font.Name := 'Arial';
       Printer.Canvas.Font.Size := 10;
       Printer.Canvas.TextOut(005,010,'Some text here');
       Printer.Canvas.TextOut(030,050,'Some other text');
       Printer.EndDoc;
   End;
end;

0
 
VSFCommented:
That was my answer and not yoda's!
Why should he have the points?!?!


Thats not fair at all hutelihut!

I ask you to reconsider your decision!
0
 
MoondancerCommented:
hutelihut, I am happy that our excellent team has helped you.  It is important to take note of who responded to you with the correct information first and award accordingly.  Most experts choose to comment versus propose answers to provide optimum assistance to people asking questions, some choose to bypass that and propose answers, all the more reason to carefully note who said what first.

VSF, please comment here to flow award points to you for this error.

Thank you.

http://www.experts-exchange.com/jsp/qShow.jsp?qid=20159030

Moondancer
Community Support Moderator @ Experts Exchange
0
 
VSFCommented:
Ok, thanks for the great job you guys do at EE.

VSF
0
 
hutelihutAuthor Commented:
So sorry - of course VSF should have the points...

How do I give VSF the points?
0
 
MoondancerCommented:
I will correct/handle this for you.

Moondancer
Community Support Moderator @ Experts Exchange
0
 
MoondancerCommented:
VSF:  Please comment in the link below to correct this.

Thank you,
Moondancer
Community Support Moderator @ Experts Exchange

http://www.experts-exchange.com/jsp/qManageQuestion.jsp?qid=20161116
0
 
VSFCommented:
Thanks for your attention!
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 6
  • 3
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now