Solved

Can't get PrintScale to work

Posted on 2000-05-16
2
634 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
Comment Utility
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
Comment Utility
Didn't work, but oh well ...
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

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…
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 demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

763 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

11 Experts available now in Live!

Get 1:1 Help Now