Solved

Small / Large Printing text in D1

Posted on 1997-08-28
7
129 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
ID: 1342847
Mayby Printer.Canvas.Refresh ?
Tell more how you doing the change of Resolution;
0
 

Author Comment

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

Expert Comment

by:mirek071497
ID: 1342849
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
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.

 
LVL 5

Accepted Solution

by:
ronit051397 earned 150 total points
ID: 1342850
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
ID: 1342851
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
ID: 1342852
The Lloyd's help file is available on:
http://www.borland.com/devsupport/delphi/downloads/index.html
0
 
LVL 3

Expert Comment

by:mirek071497
ID: 1342853
Thank you very much.
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

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…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

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