Solved

Printing with different printer

Posted on 2002-05-13
8
176 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
 
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
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.

 

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

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

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

911 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

22 Experts available now in Live!

Get 1:1 Help Now