Home General

placing images on a page

edited February 2011 in General
Hi,

I have a very simple report to create, that should contain 22 little
images 45X40 mm. From these, there are 3 rows I placed on the header
band and 2 rows I placed on the footer band.

The detail band is supposed to have a very small number of rows, most
of the time probably it will have 1 row. This row has 3 columns which
are placed somehow to the center of the page.

Now, I have 4 remaining images. I want to place 2 images on the right
side and 2 images on the left side, in the remaining space. Practically
the stuff looks like this

A B C D
E F G H
I_xxx_J
K_yyy_L
M_yyy_N
O P Q R
S T U W

A to W are the images
xxx are some labels on the header band
yyy is my detail region
Once again: first 3 rows on the header, last 2 rows on the footer.

The problem I have is that I don't know how to place images K to N. I
tried to put them on the detail band, on Report.OnEndPage, with code
like this (the code supposedly should insert the image K in the above
diagram):

procedure TThreadMail.EndPageReport(Sender: TObject);
var
Image: TppImage;
begin
Image := TppImage.Create(FReport);
Image.Name := 'ppImage11';
Image.Band := FReport.DetailBand;
Image.MaintainAspectRatio := FALSE;
Image.Stretch := TRUE;
Image.Left := 0;
Image.Top := 0;
Image.Height := 40;
Image.Width := 45;
JPEG2Image(Image, 'BEE45');
end;

Any ideas how can I acomplish this task?

Comments

  • edited February 2011
    Hi Lucian,

    1. The OnEndPage event fires too late to add a component to the report.
    You will need to use an event that fires before the detail band is generated
    (Band.BeforePrint, Report.OnStartPage).

    2. It does not look like you are assigning the Picture property of the
    TppImage component. This is required for an image to display.



    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited February 2011
    Nico Cizik (Digital Metaphors) wrote:


    Ok, but the detail has just 8mm height, while my images are 40mm
    height. Will that work, inserting them on the detail band without
    altering it's height for other rows to come?


    That it's done through the method JPEG2Image, which works for all other
    images and looks like this

    procedure JPEG2Image(AImage: TppImage; const ResName: string);
    var
    Jpg: TJPEGImage;
    begin
    Jpg := ... other code grabbing a jpeg from resources
    if Assigned(Jpg) then
    try
    AImage.Picture.Bitmap.Assign(Jpg);
    finally
    Jpg.Free;
    end;
    end;

    regards
    Lucian
  • edited February 2011
    > I have a very simple report to create, that should contain 22 little

    I think I wasn't clear enough. It's not only images that the report
    will contain. It's also a few bits of data, I use a TppJITPipeline to
    feed the report. The images are supposed to wrap the data and the data
    practically are some static text I added on the header and the stuff
    coming from the pipeline in the center of the page. Supposedly there
    may be a maximum of 10 records and a minimum of 1. In all cases, I have
    to draw the remaining 4 images (40mm height), 2 on the left and 2 on
    the right in the detail area, but obviously the images are 5 times the
    detail band height.

    Lucian
  • edited February 2011
    Hi Lucian,

    Thanks for the clarification. I had thought you were using a single static
    height detail band.

    One option is to create a PageStyle band and place the images inside it.
    The PageStyle can be the height of the page and all its components will
    print behind the rest of the report.

    Another is to manually add the images to the page rather than to the band
    using DrawCommands. See the following article on adding a watermark to a
    page. The same concept will apply except you will be creating and adding
    TppDrawImage object rather than text. Note also that drawcommands are
    positioned relative to the entire page in microns so conversions will need
    to be made.

    http://www.digital-metaphors.com/rbWiki/Delphi_Code/Formatting/How_To...Manually_Add_a_Watermark_to_a_Page


    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited February 2011
    > One option is to create a PageStyle band

    Yeah, I got there as well.



    This I don't understand, but I am not finished. I'll see how it goes


    Yes, that's what threw me on the right track.
    Thx
  • edited February 2011
    Cool, thanks.
    It Worked
    Lucian
This discussion has been closed.