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

dbImage AutoSize MaxSize

edited June 2011 in General
A bit of background:
We scan documents and save them as varbinary in our database. We then print
them on reports using tppDBImage of Enterprise 12. The documents vary on
size front the size of a ID Card to a 8.5x14 sheet.

We would like to print them as close as possible to their original size.
The problem is that the AutoSize option will on occasions make the width and
height of the dbImage bigger than the printable area of the report.
When the width is too big the image wont print and when the height is to
large the report will print infinite pages.

How can I AutoSize the DBImage for small images while for large images I
would need to limit the growth to the size of the page minus the margin?
In other words the dbImages should not auto-growth beyond the printable area
of a page.

Thanks
Temoc Navarro

Comments

  • edited June 2011
    Try implementing the DBImage.OnPrint event to check the size.

    begin

    if myDBImage.Width > FMaxWidth then
    myDBImage.Width := FMaxWidth;


    if myDBImage.Height > FMaxHeight then
    myDBImage.Height := FMaxHeight;

    end;

    If you want to check the size of the graphic, check
    DBImage.Picture.Width/Height.


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

    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
  • edited June 2011
    Thanks for the hint.

    This is what worked:
    ppGroupFooterBand2BeforePrint(Sender: TObject);
    var lTooBig : Boolean;
    begin
    ppDBImageStatic.Width := FImageMaxWidth;
    ppDBImageStatic.Height := FImageMaxHeight;

    lTooBig := (ppDBImageAutoSize.Picture.Width > FPictureMaxWidth) or
    (ppDBImageAutoSize.Picture.Height > FPictureMaxHeight);

    ppDBImageAutoSize.Visible := Not lTooBig; //if the image is small print
    the dbImage that is set as AutoSize.
    ppDBImageStatic.Visible := lTooBig; //if the image is too big the print
    the dbImage that is static max width and height.

    end;

    Temoc Navarro

  • edited June 2011

    As a further refinement, you might want to remove the ppDBImageAutoSize
    object. Just use the ppDBImageStatic object and either set the Width and
    Height to the Picture.Width and Picture.Height or set it to PictureMaxWidth,
    PictureMaxHeight. Also in your code, I am not clear on why you have
    ImageMaxWidth and PictureMaxWidth - I was thinking these would be the same
    value.


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

    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
This discussion has been closed.