Home General
New Blog Posts: Merging Reports - Part 1 and Part 2

TppImage fit to page

edited January 2009 in General
I have a report that only has one TppImage on it. I use the report to
print various images of all different types and sizes. Lately I have
users that are printing bigger images and my sizing code isn't working
that well, it prints them all shrunk up and there is plenty of space on
the page.

I think part of the problem is that my detail band that the TppImage is
on, is not filling the page.

Basically if the picture being printed is small enough to print on the
page, just print it. Otherwise I want to make the TppImage fit the
entire page and restrict the picture into the confines of the TppImage.

I'm just not sure when to set which properties: AutoSize, Center,
MaintainAspectRatio, ShiftWithParent, Stretch

Also how to I make the Detail band and/or the TppImage fit to the entire
page height/width?

Comments

  • edited January 2009
    Set Image.Stretch and MaintainAspectRatio to True.

    With those two settings, the image will fill the boundary defined by the
    TppImage.Width and Height - but without distorting the picture by stretching
    the height or width out of proportion.

    Band.Height is the height of the detail band in report units. Remove the
    header/footer bands if you only want the detail band.

    Image.Height/Width is the size of the image control in report units

    Image.Picture.Height/Width is the size of the image in pixels (i.e. bmp
    size)




    --
    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com

    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
  • edited January 2009
    So can I safely hard code the detail bands height or will that not
    always work with different printers or something?

    procedure TfrmImaging.rptJustImageBeforePrint(Sender: TObject);
    begin
    rptJustImage.Bands[0].Height := 1000;
    imgJustImage.Height := 1000;




  • edited January 2009

    1. What Report.Units that you are using? For example, if you are using
    utInches and set the Height to 1,000, then that will not fit on a page.
    Perhaps you are using utScreenPixes. If so note that screen pixels per inch
    can vary from machine to machine - based on whether the user is using large
    fonts.

    2. The layouts you create have a default margin of 1/4 inch on each side. I
    would leave some room when setting the Band.Height. Most printers have an
    unprintable area - typically about 1/4 inch around the page - RB queries
    Windows to get that information from the printer driver and tries to
    compensate for it.


    --
    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com

    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
  • edited January 2009
    It seems I have a very similar problem using Delphi 2007 and RB 10.09.

    I have a report with only one jpeg image (type blob in an Interbase
    Database) plus 2 lines in the header nad and oe line + the printed date in
    the footer band.

    The usefull print area is 1007 x 756 screen pixels.

    I use JITVAriables in order to define the size of the image and use a
    beforePrint procedure (see below).

    It works perfectly if the image size is smaller then the printable area.
    If it is larger than the printable area , I'd like to have it scretched in
    order to maintain the Aspect ratio and fit on the printable area.
    Unfortunately, whatever the options I set (Strech or MaintainAspectRatio),
    the image isn't resized and is dispalyed with an important overflow (with a
    bad quality) outside of the printable area !!
    I can provide a sample image if necessary.

    What do I forget ?

    Many thanks ,

    Claude

    Here is the Procedure :

    procedure ReportBeforePrint;
    var h,l:integer;
    begin
    Label1.Caption := JITPVariable['S_TITRE'];
    dbImage1.Stretch := JITPVariable['B_STRETCH'];
    dbImage1.Height := JITPVariable['I_HEIGHT'];
    dbImage1.Width := JITPVariable['I_WIDTH'];

    h:=Report.PrinterSetup.PaperHeight-Report.Header.Height-Report.Footer.Height
    -Report.PrinterSetup.MarginTop-Report.PrinterSetup.MarginBottom;
    l:=Report.PrinterSetup.PaperWidth-Report.PrinterSetup.MarginLeft
    -Report.PrinterSetup.MarginRight;
    Line1.Width:=l;
    Line2.Width:=l;
    if dbImage1.Height>h then {le redimentionnement n'a pas l'air de
    fonctionner}
    begin
    dbImage1.Height:=h;
    end;
    if dbImage1.Width>l then
    begin
    dbImage1.Width:=l;
    end;
    dbImage1.Top:=h/2-dbImage1.Height/2;
    dbImage1.Left:=l/2-dbImage1.Width/2;
    end;

    ____________________________________________________________________________________________

This discussion has been closed.