Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4266868
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T06:49:11+00:00 2026-05-21T06:49:11+00:00

In Crystal Reports 2008, there’s a Graphic Location image property where it can be

  • 0

In Crystal Reports 2008, there’s a “Graphic Location” image property where it can be set to a file path so when the report gets run, it uses the selected picture file instead of the one on the report. I tried setting this via the .NET API, but it’s only working some of the time.

In the report itself, I’ve set Graphic Location to {@LogoPath}, then when I run the report via .NET API, I set {@LogoPath} to the filename of the picture. I’ve put the formula on the report itself, and it’s indeed getting set to the correct filename, but the image on the report doesn’t always update. It would consistently show up for some time, then consistently not show it again.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T06:49:12+00:00Added an answer on May 21, 2026 at 6:49 am

    Here’s what I ended up using, the code is in Delpi Prism. One of the awkward thing to deal with is if the image being replaced is different size to the image on the report, Crystal doesn’t resize it correctly. The other problem was I needed to free the picture object manually otherwise Crystal sometimes doesn’t display it on the report.

    method SetShadingAndLogo(const AReport:ReportDocument);
    var
      LogoPath:String;
      PicObj:PictureObject;
      Logo:System.Drawing.Image;
      PicRatio:Double;
      ContWidth, ContHeight:Double;
      ContainerRatio:Double;
      NewDimension:Double;
      PosAdj:Integer;
      Scale:Double;
    begin
      for each Section:Section in AReport.ReportDefinition.Sections do
      begin
        for each RptObj:ReportObject in Section.ReportObjects do
        begin
          if RptObj.Name.StartsWith('LOGO', StringComparison.CurrentCultureIgnoreCase) and
            (RptObj.Kind = ReportObjectKind.PictureObject) then
          begin
            //set to company logo
            LogoPath := "C:\logo.jpg";
            PicObj := RptObj as PictureObject;
    
            if not System.IO.File.Exists(LogoPath) then
              PicObj.ObjectFormat.EnableSuppress := true
            else
            begin        
              Logo := System.Drawing.Image.FromFile(LogoPath);
    
              //work out the aspect ratios of the image and the container
              PicRatio := Double(Logo.Width) / Double(Logo.Height);
    
              //convert twips to pixels
              //96 is the default dpi for Windows, but should really check Windows settings
              //instead of hard coding
              ContWidth  := Double(TwipsToPx(PicObj.Width, 96));
              ContHeight := Double(TwipsToPx(PicObj.Height, 96));
    
              ContainerRatio := ContWidth / ContHeight;
    
              // adjust the size of the container on the report to maintiain the original
              // image's ratio
              if PicRatio > ContainerRatio then 
              begin
                // reset the vertical position to remain centred on the original location
    
                // get the new height of the container (in pixels)
                NewDimension := (ContWidth / Logo.Width) * Logo.Height;
    
                // get the movement (in twips)
                PosAdj := PxToTwips(Integer((ContHeight - NewDimension) / 2), Integer(Logo.VerticalResolution));
    
                // adjust the position
                PicObj.Top := PicObj.Top + PosAdj;
    
                // picture is wider so adjust the height accordingly
                // need to scale using the logo's dpi to resize correctly
                Scale := Double(PicObj.Width) / Double(PxToTwips(Logo.Width, Integer(Logo.VerticalResolution)));
                PicObj.Width := Integer(PicObj.Width * Scale);
                PicObj.Height := Integer(PicObj.Height * Scale);
              end
              else 
              begin 
                // picture is taller and needs to be scaled to height
                // reset the horizontal position to remain centred on the original location
    
                // get the new width of the container (in pixels)
                NewDimension := (ContHeight / Logo.Height) * Logo.Width;
    
                // get the movement (in twips)
                PosAdj := PxToTwips(Integer((ContWidth - NewDimension) / 2), Integer(Logo.VerticalResolution));
    
                // adjust the position
                PicObj.Left := PicObj.Left + PosAdj;
    
                // picture is taller and needs to be scaled to height
                // need to scale using the logo's dpi to resize correctly
                Scale := Double(PicObj.Height) / Double(PxToTwips(Logo.Height, Integer(Logo.VerticalResolution)));
                PicObj.Width := Integer(PicObj.Width * Scale);
                PicObj.Height := Integer(PicObj.Height * Scale);
              end;
    
              //must free the logo, otherwise Crystal sometimes doesn't display it on report
              Logo.Dispose;
    
              for each fm:FormulaFieldDefinition in AReport.DataDefinition.FormulaFields do
              begin
                if fm.Name.Equals("LogoPath") then
                  fm.Text := """"+LogoPath+"""";
              end;
            end;
          end;
        end;
      end;
    end;
    
    method TwipsToPx(const AValue, ADpi:Integer):Integer;
    begin
      //convert to twips using specified dpi, 96 is Windows' default dpi
      Result := System.Convert.ToInt32(Double(AValue) * ADpi / 1440);
    end;
    
    method PxToTwips(const AValue, ADpi:Integer):Integer;
    begin
      //convert to pixels using specified dpi, 96 is Windows' default dpi
      Result := System.Convert.ToInt32(Double(AValue) * 1440 / ADpi);
    end;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In Crystal Report Designer in VS 2008, I can go to the crystal reports
I have a crystal report designed in vs 2008 crystal reports. There is the
In VS 2008, I have a crystal main report with about 20 sub reports.
In SQL Reporting Services 2008, can you format a field conditionally? In Crystal Reports
Is there a way in Crystal Reports 2008 to have a preview of page
Is there free software that converts Crystal Reports .rpt files to SQL Reporting 2008
Background I have a Crystal Reports 2008 file that came my way from a
In Crystal reports, you can define default values for the report parameters. For example,
I have a report made with Crystal Reports 2008 that I need to deploy
We are using SAP Integration KIT and Crystal Reports 2008. The Crystal Reports are

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.