Solved

Small / Large Printing text in D1

Posted on 1997-08-28
7
126 Views
Last Modified: 2012-05-04
if I use Delphi 1.0's Printers unit to print docs I find
the following problem. After one print, if I change the printer resolution and reprint the fonts on my printout go
wacko (either bigger or smaller depending on which way the
resolution was changed) Any ideas on how to fix this?
0
Comment
Question by:boabyte
  • 4
  • 2
7 Comments
 
LVL 3

Expert Comment

by:mirek071497
Comment Utility
Mayby Printer.Canvas.Refresh ?
Tell more how you doing the change of Resolution;
0
 

Author Comment

by:boabyte
Comment Utility
I change the Printer resolution using the standard Delphi PrintDialog component.
0
 
LVL 3

Expert Comment

by:mirek071497
Comment Utility
I can't test this because my printer have only one resolution but mayby you assing font in bad place or you made other mistake.

Try this example from Delphi Help.

procedure TForm1.Button1Click(Sender: TObject);
var
  Line: Integer;
  PrintText : TextFile;
begin
  if PrintDialog1.Execute then
  begin
    AssignPrn(PrintText);
    Rewrite(PrintText);
    {assign the current Font setting for Memo1 to the Printer object's canvas}
    Printer.Canvas.Font := Memo1.Font;
    for Line := 0 to Memo1.Lines.Count - 1 do
      Writeln(PrintText, Memo1.Lines[Line]);
    System.Close(PrintText);
  end;
end;

0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
LVL 5

Accepted Solution

by:
ronit051397 earned 150 total points
Comment Utility
This is from Lloyd's Help File. I Didn't check it.

Q:  How do I print to different printer resolutions?

A:  Despite what Delphi's help says you have to change the printer object's Font.PixelsPerInch.  And for some reason, you have to set it AFTER calling an API routine that gets the printer's hDC. The following function does it.  After calling this function, you can use Font.Size to set a font size independently of the printer's resolution.

 {-------------------------------------------------------------
Sets the logical dots per inch for the printer and sets the printer axes to point RIGHT and DOWN.  Thus (0,0) is at the top left corner of the page. Returns the page size in logical coordinates.

Note:  Must be called AFTER Printer.BeginDoc.
 --------------------------------------------------------------}

function SetPrinterScale: TPoint;

var
  DeviceDpiX, DeviceDpiY : integer;
begin
  with Printer do begin
    DeviceDpiX := GetDeviceCaps(Handle, LOGPIXELSX);
    DeviceDpiY := GetDeviceCaps(Handle, LOGPIXELSY);
    SetMapMode(Handle, MM_ISOTROPIC);
    SetWindowExt(Handle, DeviceDpiX, DeviceDpiY);
    SetViewPortExt(Handle, DeviceDpiX, DeviceDpiY);
    Result := Point(PageWidth, PageHeight);
    with Canvas do begin
      DPtoLP(Handle, Result, 1); { This API call is required... }
      Font.PixelsPerInch := DeviceDpiY; { Manual setting is required to make this work. }
    end;
  end;
 end;

{ This code came from Lloyd's help file! }
0
 
LVL 3

Expert Comment

by:mirek071497
Comment Utility
Hi ronit! What is the Lloyd's Help and where i can get this ? I hear more but know nothing about this.
0
 
LVL 5

Expert Comment

by:ronit051397
Comment Utility
The Lloyd's help file is available on:
http://www.borland.com/devsupport/delphi/downloads/index.html
0
 
LVL 3

Expert Comment

by:mirek071497
Comment Utility
Thank you very much.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

772 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

10 Experts available now in Live!

Get 1:1 Help Now