Solved

Using a MATRIX-printer!

Posted on 2001-07-27
12
272 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
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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

895 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

18 Experts available now in Live!

Get 1:1 Help Now