Solved

Printing with different printer

Posted on 2002-05-13
8
175 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
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 

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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

707 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

16 Experts available now in Live!

Get 1:1 Help Now