Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Printing with different printer

Posted on 2002-05-13
8
Medium Priority
?
188 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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 800 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

Independent Software Vendors: 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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…

824 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