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

Multiple images in a TppImage

edited October 2001 in General
Is it possible to load mutiple images into a single TppImage? I need to
print a variable number of images and I thought this might be simpler than
dynamically creating all the TppImages at runtime.

Bill

Comments

  • edited October 2001
    I am trying the dynamic creation route, but my images no longer show up. I
    was loading the images in the band BeforeGenerate, so that's where I put the
    new code. Everything appears to work, but no images display or print. I'm
    stumped as to why this would work differently than using a design-time
    ppImage. All the properties appear correct, and I assign the image Band
    correctly.

    Thanks for any further advice.

    Bill
  • edited October 2001
    The band event timing is too late to add images to the band. If you don't
    know how many images to print until each detailband prints, then you could
    use a subreport in the detail band, place one image component in the
    subreport detail abnd, and feed the subreport image data through a
    JITPipeline.


    Cheers,

    Jim Bennett
    Digital Metaphors


  • edited October 2001
    Jim,

    Thanks, I'm not sure I understand your answer. (Actually, I'm sure I
    don't!) How does having a single image in a subreport help me in the
    instances where I need to print multiple images? Can I create multiple
    ppImages via the JITPipeline, or do I somehow put multiple images on the
    single ppImage? Sorry, but I'm confused. I have looked through help and
    the examples, but can't find anything that helps.

    Also, just as a general question, is there ever any chance of having an
    event that's early enough to handle th process as on a form? It would be
    nice to use the same techniques.

    Thanks again for your help.

    Bill



  • edited October 2001
    Jim,

    I have managed to sort of stumble through some of this, but only when I have
    a field defined in the subreport and attached to the JITPipeline. I can
    create the fields dynamically, but I'm not sure how to reference them to set
    their properties. (The field names I just base on the image array index.)

    I have looked through the sample reports, but I don't see anything there
    that helps.

    Bill
  • edited October 2001
    Ok, I'm getting slightly less confused. I am now creating all the
    JITPipeline fields correctly, but having trouble creating and positioning
    the corresponding ppDBImages on the subreport since the ppDBImage Parent is
    read-only. So how do I get the ppDBImages on the subreport?

    I can get this to work if I create the ppDBImages at design-time, but that
    doesn't help since the number varies by record.

    Thanks for any pointers!

    Bill
  • edited October 2001
    Perform a report object loop looking for a particular subreport and pull the
    childreport object from it. Here, I created a subreport called sbrImages
    and create two dbIMages in its detail band.

    uses
    ppJPEG;

    procedure TForm1.Button1Click(Sender: TObject);
    begin
    AddImagesToReport(ppReport1);

    ppDesigner1.ShowModal;
    end;

    procedure TForm1.AddImagesToReport(aReport: TppCustomReport);
    var
    liBand: Integer;
    liObject: Integer;
    lObject: TppComponent;
    begin

    for liBand := 0 to aReport.BandCount-1 do

    for liObject := 0 to aReport.Bands[liBand].ObjectCount-1 do
    begin
    lObject := aReport.Bands[liBand].Objects[liObject];

    if (lObject is TppSubreport) and (lObject.UserName = 'sbrImages')
    then
    CreateImages(TppSubreport(lObject));
    end;

    end;


    procedure TForm1.CreateImages(aSubreport: TppSubreport);
    var
    lChildReport: TppChildReport;
    lImage1: TppDBImage;
    lImage2: TppDBImage;
    begin

    lImage1 := TppDBImage.Create(Self);
    lImage1.Top := 0;
    lImage1.Left := 0;
    lImage1.Width := 2;
    lImage1.Height := 2;
    lImage1.MaintainAspectRatio := True;

    lImage2 := TppDBImage.Create(Self);
    lImage2.Top := 0;
    lImage2.Left := 3;
    lImage2.Width := 2;
    lImage2.Height := 2;
    lImage2.MaintainAspectRatio := True;

    lChildReport := TppChildReport(aSubReport.Report);

    lImage1.Band := lChildReport.Detailband;
    lImage2.Band := lChildReport.Detailband;

    {need to determine image of greater bottom here}
    lChildReport.DetailBand.Height := lImage1.Top + lImage1.Height;

    end;


    Cheers,

    Jim Bennett
    Digital Metaphors


This discussion has been closed.