Solved

Small / Large Printing text in D1

Posted on 1997-08-28
7
127 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

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…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

896 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

13 Experts available now in Live!

Get 1:1 Help Now