Solved

Small / Large Printing text in D1

Posted on 1997-08-28
7
132 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Suggested Courses
Course of the Month5 days, 12 hours left to enroll

626 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