Solved

Using a MATRIX-printer!

Posted on 2001-07-27
12
278 Views
Last Modified: 2012-05-04
(Im not sure that I spell it right...)

How do I print a single line on a MATRIX-printer?
0
Comment
Question by:hutelihut
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 3
  • 2
  • +1
12 Comments
 
LVL 3

Expert Comment

by:VSF
ID: 6326392
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
 
LVL 3

Expert Comment

by:VSF
ID: 6326417
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
 

Author Comment

by:hutelihut
ID: 6326574
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 4

Accepted Solution

by:
YodaMage earned 0 total points
ID: 6326720
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
 
LVL 3

Expert Comment

by:VSF
ID: 6331404
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
 
LVL 3

Expert Comment

by:VSF
ID: 6331412
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
 
LVL 1

Expert Comment

by:Moondancer
ID: 6331909
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
 
LVL 3

Expert Comment

by:VSF
ID: 6333830
Ok, thanks for the great job you guys do at EE.

VSF
0
 

Author Comment

by:hutelihut
ID: 6333845
So sorry - of course VSF should have the points...

How do I give VSF the points?
0
 
LVL 1

Expert Comment

by:Moondancer
ID: 6338673
I will correct/handle this for you.

Moondancer
Community Support Moderator @ Experts Exchange
0
 
LVL 1

Expert Comment

by:Moondancer
ID: 6338683
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
 
LVL 3

Expert Comment

by:VSF
ID: 6340018
Thanks for your attention!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question