Solved

Can't get PrintScale to work

Posted on 2000-05-16
2
646 Views
Last Modified: 2011-10-03
Hi,

I've said this, I don't know how many times, but I'm sorta' a novice with Delphi.

How do I get this to work?

(From the Delphi Help Files)
type TPrintScale = (poNone, poProportional, poPrintToFit);
property PrintScale: TPrintScale;

Question is, how do I impliment it with this?

procedure TForm1.Print1Click(Sender: TObject);
begin
    with Printer do
    begin
    PrintScale := poProportional;
    BeginDoc;      { start printing }
    Canvas.Draw(0, 0, Image1.Picture.Bitmap);      { draw Image at top left corner of printed page }
    EndDoc;      { finish printing }
    end;

end;
0
Comment
Question by:fibdev
2 Comments
 
LVL 5

Accepted Solution

by:
TheNeil earned 25 total points
ID: 2816291
When you're trying to output a bitmap I'd forget about using the Printscale property and stretch the image yourself using StretchDraw e.g.:

Printer.Canvas.StretchDraw(RECT(0, 0, 100, 100), Image1.Picture.Bitmap);

This of course will ruin the aspect ratio but you can work that out like so:

rX := Printer.PageWidth / Image1.Picture.Bitmap.Width;
rY := Printer.PageHeight / Image1.Picture.Bitmap.Height;

IF rY > rX
THEN
  rY := rX
ELSE
  rX := rY;

iW := ROUND(Image1.Picture.Bitmap.Width * rX);
iH := ROUND(Image1.Picture.Bitmap.Height * rY);

iCx := (Printer.PageWidth - iW) DIV 2;
iCy := (Printer.PageHeight - iH) DIV 2;

Printer.Canvas.StretchDraw(RECT(iCx, iCy, iCx + iW, iCy + iH), Image1.Picture.Bitmap);

I'm pretty sure that's right but I might have got the initial division the wrong way around

Hope that helps

The Neil =:)
0
 
LVL 3

Author Comment

by:fibdev
ID: 2823665
Didn't work, but oh well ...
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

830 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