Centre-align image in a report [BC24 Cloud]

garmoogarmoo Member Posts: 21
I need to centre-align an image from a Customer card on a report, however the image can be different dimensions depending on what the end user uploads. I found this link which should work for OnPrem instances but in order to do so, you need to set EnableExternalAssemblies property to true on the report and this isn't allowed for Cloud development.

Is anyone aware of another way to centre align images?

Best Answer

  • garmoogarmoo Member Posts: 21
    edited 2024-10-03 Answer ✓
    I have RecordImagePadding as a column in my dataset which is calculated as below
     trigger OnAfterGetRecord()
                var
                   RecordTenantMedia: Record "Tenant Media";
                   RecordmageWidth: Decimal;
                   RecordImageHeight: Decimal;
                begin
                    if Record.Picture.Count > 0 then begin
                        RecordTenantMedia.Get(Record.Picture.Item(1));
                        RecordTenantMedia.CalcFields(Content);
                        RecordImageWidth := Round(RecordTenantMedia.Width * 0.75, 1, '=');    //converting to Pt
                        RecordImageHeight := Round(RecordTenantMedia.Height * 0.75, 1, '=');  //converting to Pt
                        //500 is the width of the layout image box
                        //300 is the height of the layout image box
                        RecordImagePadding := Round((500 - round((RecordImageWidth / round((RecordImageHeight / 300), 1, '=')), 1, '=')) / 2, 1, '=');
                    end;
                end;
    

    I then went to Report Properties, Size, and set the left padding to the expression
    =Cstr(Last(Fields!RecordImagePadding.Value)) + "pt"
    

Answers

  • garmoogarmoo Member Posts: 21
    edited 2024-10-03 Answer ✓
    I have RecordImagePadding as a column in my dataset which is calculated as below
     trigger OnAfterGetRecord()
                var
                   RecordTenantMedia: Record "Tenant Media";
                   RecordmageWidth: Decimal;
                   RecordImageHeight: Decimal;
                begin
                    if Record.Picture.Count > 0 then begin
                        RecordTenantMedia.Get(Record.Picture.Item(1));
                        RecordTenantMedia.CalcFields(Content);
                        RecordImageWidth := Round(RecordTenantMedia.Width * 0.75, 1, '=');    //converting to Pt
                        RecordImageHeight := Round(RecordTenantMedia.Height * 0.75, 1, '=');  //converting to Pt
                        //500 is the width of the layout image box
                        //300 is the height of the layout image box
                        RecordImagePadding := Round((500 - round((RecordImageWidth / round((RecordImageHeight / 300), 1, '=')), 1, '=')) / 2, 1, '=');
                    end;
                end;
    

    I then went to Report Properties, Size, and set the left padding to the expression
    =Cstr(Last(Fields!RecordImagePadding.Value)) + "pt"
    
Sign In or Register to comment.