Solved

Printing with different printer

Posted on 2002-05-13
8
180 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
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Process Javascript errors with Delphi TWebBrowser 1 179
DBGrid or StringGrid ? 6 105
firemonkey Android Listview Sort items 7 55
Delphi Seattle StructureView color 1 15
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…
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…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

820 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