Solved

Using a MATRIX-printer!

Posted on 2001-07-27
12
270 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
  • 6
  • 3
  • 2
  • +1
12 Comments
 
LVL 3

Expert Comment

by:VSF
Comment Utility
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
Comment Utility
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
Comment Utility
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
 
LVL 4

Accepted Solution

by:
YodaMage earned 0 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 1

Expert Comment

by:Moondancer
Comment Utility
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
Comment Utility
Ok, thanks for the great job you guys do at EE.

VSF
0
 

Author Comment

by:hutelihut
Comment Utility
So sorry - of course VSF should have the points...

How do I give VSF the points?
0
 
LVL 1

Expert Comment

by:Moondancer
Comment Utility
I will correct/handle this for you.

Moondancer
Community Support Moderator @ Experts Exchange
0
 
LVL 1

Expert Comment

by:Moondancer
Comment Utility
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
Comment Utility
Thanks for your attention!
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

763 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now