Solved

Small / Large Printing text in D1

Posted on 1997-08-28
7
128 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
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 
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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Windows Drag & Drop Location 2 100
how to manage invalidate between two tvirtualstringtree in same form? 1 113
Performance of SQL statement 37 111
SUM 2 INTEGER ARRAYS INTO 1 10 100
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
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…

808 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