Solved

Printing with different printer

Posted on 2002-05-13
8
177 Views
Last Modified: 2010-04-04
Hi,

 It seem that printing with different printer result in some problem with the font. I was using a Canon Bj-200e and i didnt have the problem with the font but i change the printer for a HP DeskJet 920c and the font output is weird.

 I use the font "ARIAL" but the output of the HP is printing some kind of fixed font (each caracter have the same length) so the text take more space.

Is this in my rpogram the problem or the HP dont support "ARIAL" font??

Here the code i use before BeginDoc

 Printer.PrinterIndex := -1;    
 Printer.Title := 'BDM';  
 Printer.Orientation := poPortrait;

 H1mm := GetDeviceCaps(Printer.Handle, LogPixelsX) / 25.4;
 V1mm := GetDeviceCaps(Printer.Handle, LogPixelsY) / 25.4;

 Printer.Canvas.Font.PixelsPerInch := GetDeviceCaps  (Printer.Handle, LogPixelsX);

 Printer.BeginDoc;
 with Printer.Canvas
  do
   begin
    Brush.Color := clWhite;
    Brush.Style := bsClear;

    Font.Name := 'Arial';
    Font.Size := 20;
    Font.Style := [fsBold];
    Font.Pitch := fpFixed;
    TextOut(trunc(MidX - (TextWidth('XYZ') / 2)),
            TopY + trunc(1 * V1mm),'XYZ');

If you can help me, i would appreciate it.

Thanks

Sierra
0
Comment
Question by:sierra20
  • 4
  • 3
8 Comments
 
LVL 6

Expert Comment

by:DrDelphi
ID: 7006891
According to HP's website this printer doesn't support Arial fonts directly. Note:

http://www.hp.com/cposupport/printers/support_doc/bpd08808.html#P162_5153


-Also, there seems to be a lot of driver updates for all of their models. You might want to check that you have the latest and greatest.



Good luck.
0
 

Author Comment

by:sierra20
ID: 7006949
Hi,

Thanks DrDelphi, i didnt see this page on their web site.

But what font should i use if i want my program to work on any printer?? Is there a standard font that every printer use.

Thanks

Sierra
0
 

Author Comment

by:sierra20
ID: 7006972
Hi,

 I forget to write this in the previous comment.

 If ARIAL font is not supported, how a program like MS-Word can print the font???

Thanks
0
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 
LVL 6

Expert Comment

by:DrDelphi
ID: 7007037
To answer both of your questions at once:

I believe that what Word does is to print to an offscreen bitmap first and then draw that bitmap on the printer canvas as opposed to drawing directly on the printer canvas. This way it makes no difference if a particular font is not supported by the printer. As long as the O/S supports it, you're printing. Now, as to what can/should you do to make your application portable to any machine:

See above! <g>


Good luck!!
0
 

Author Comment

by:sierra20
ID: 7007088
Hi,

Can you give me an example of how to do what you proposing.
I add some more point for that.

Thanks
0
 
LVL 6

Expert Comment

by:DrDelphi
ID: 7007191
Sure..off the top of my head:

var BMP:TBitmap;
begin
  BMP:=TBitmap.create;
  With Bmp do
  begin
   Width:=PageWidth;
   {use printer.canvas.Cliprect.right or getdevicecaps for this}
   Height:=PageHeight;
   {See above}
    with canvas do
    begin
     Brush.Color := clWhite;
     Brush.Style := bsClear;
     Font.Name := 'Arial';
     Font.Size := 20;
     Font.Style := [fsBold];
     Font.Pitch := fpFixed;
     TextOut(trunc(MidX - (TextWidth('XYZ') / 2)),
           TopY + trunc(1 * V1mm),'XYZ');
 
    end;
  end;
  Printer.BeginDoc;
  Printer.Canvas.Draw(0,0,bmp);
  Printer.EndDoc;
  FreeAndNil(bmp);  
end;

Good luck!!
0
 
LVL 2

Accepted Solution

by:
mikepj earned 200 total points
ID: 7007391
I print using Arial fonts all the time on a variety of printers and I'm quite sure it doesn't revert to some other font.  Windows takes care of all that.

I think there is a problem here:

  Font.Pitch := fpFixed;

I think that should read:

  Font.Pitch := fpVariable;

In fact, I don't set Font.Pitch at all.

MP
0
 

Author Comment

by:sierra20
ID: 7008431
Hi
  You were right Mike, that was the problem. It seem the canon driver dont care about Pitch but HP does.

Thanks for your help both of you.

Sierra


 
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

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…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

786 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