Display image in Crystal reports using URL

I want to show the image in a crystal report. The script looks something like this.

I have a database where my image path is saved. for example ftp: //Images/1.jpg

Now I want to repeat this image in the crystal report.

When I fill in my own datatable, it shows me the full URL. When I display this field in a GridView, I use imageBoxto display my image, and it works very well for me.

But when I try to do the same with crystal reports, it starts showing the image path as is. Now, instead of the path, I want the image to be displayed.

+5
source share
4 answers

I know that if you use Crystal Reports included with Visual Studio, this is not supported. It will display images stored in the db field, but not from the url.

I think (but I don’t know for sure) that no version of Crystal supports the ftp protocol for displaying images.

-1
source

OK, so the tear track to show images in a CR report on the Internet is as follows:

1) The following is assumed:

a) CR 2008 aka CR 12. I do not know about earlier versions, but XIR2 (11.5) can work.

b) Requires web-based image display in reports, with the development of a local workstation and preview

c) IIS, ASP.NET Application, .NET 4.0

d) Crystal Reports ( , , aspnet_client :

**system_web
   4_0_30319
      crystalreportviewers12**

.

-. - , ...

e) - , .

f) .

g) JPG, PNG BMP . AFAICT. , Word, PDF .., , . ...

h) , - -, -. , D:\MyDocuments

FTP, , , .

2) , -. , , , , 0: N , , . , , , . , , :

D:\MyDocuments\folderA\folder1\area51\whatever\myfile.png

, , , - .

3) D:\MyDocuments // . , .

4) , CR . () INI (ummm, OK) ( , ?) , (, - ?)

5) , , , N/ , (2) , , CR. - , , ....

6) a > BACK SLASHES . Shared StringVar FullQualifiedThumbnailFileName () , (4), Shared StringVar DocRoot () PLUS . , FullyQualifiedThumbnailFileName :  {@DocRoot} FolderLocationFromDB ThumbnailFileNameFromDB :

D:\MyDocuments\folderA\folder1\area51\whatever\tn_myfile.png

7) , . - , , . , REAL FullyQualifiedThumbnailFileName. , . -, .

8) , " ", "" .

, - , CR , -.

:

{@FullQualifiedThumbnailFileName} . - Windows DOS - .

9) , "file://". httpContext.Current.Session, . , .... WebURLRoot

10) txtImageURL. , , , ? - :

if  lowercase( {@WebURLRoot} ) = "file://" THEN
  {@WebURLRoot} & 
       REPLACE(  {@txtDocumentFileFullyQualifiedName},"/","\") 
else
  URLENCODE( {@WebURLRoot} & 
      REPLACE( 
         {*DocumentFileNameFromYourSource*} 
      ,"\","/")  )

DocumentFileNameFromYourSource WebURLRoot , , DocRoot. . , , :

file://D:\MyDocuments\folderA\folder1\area51\whatever\myfile.png

. :

http://somewebhost/website/folderA/folder1/area51/whatever/myfile.png

http://localhost/website WebURLRoot. , -. , , , ?

{@txtImageURL} , , - . AKA - - .

txtImageURL . . URLEncode Crystal -.

txtImageURL , .

11) CR RPT

a) , Windows C:\MyDocuments, . , .

b) , ,

c) , Windows ,

d) URL -, :// http://localhost/website/at runtime -.

e) URL- , URL- -, .

? . , 2.

#

1) , , URL- - . Crystal Reports Viewer. , , , -, , Google, , . Global.asax.cs Session_Start, autover... , URL...:

//  so Crystal can receive the APP_Path as an argument
// Code that runs when a new session is started
// http://aquesthosting.headtreez.com/doc/d9ccf4d8-1873-469e-9dca-815e5854b963
string appPath = System.Web.HttpContext.Current.Request.ApplicationPath.ToLower();
if (appPath == "/") //a site 
    appPath = "/";
else if (!appPath.EndsWith(@"/")) //a virtual directory i.e. in a subfolder
    appPath += @"/";
Session["APP_Path"] = appPath;  //stores the value to a session variable for us to use

2) , , Session [ "APP_Path" ] :

//  START CHANGE
// this next check seems unlikely
if(! (HttpContext.Current.Session  == null))
{
//  pass HttpContext.Current.Session["APP_Path"].ToString() as a parameter 
if (!(String.IsNullOrEmpty(HttpContext.Current.Session["APP_Path"].ToString())))// set in Global.asax.cs Start_Session
    exporter.Arguments.Add(exporter.Arguments.Count, HttpContext.Current.Session["APP_Path"].ToString()); // to last parameter position
else
    exporter.Arguments.Add(exporter.Arguments.Count, String.Empty); // or nothing to last parameter position
//   end change
}

. . , . - , , . . -, - , , - .

3) , , URL- - ://. , , -, - http://localhost/website/.

Gotchas:

1) . , , Windows/DOS, - Windows/DOS :// .

2) .. , URL-...

3) , - Crystal, , . , DocRoot WebSiteRootURL, ( , ), , .

4) , . , Shared StringVar xyz. , (. 3 ). , , , , .

5) " " . , - , . , , , , .., , - . .

6) // DOS/Windows ( ). -, , , , , .

7) - , Junction Magic ~/MyDocuments D:\MyDocuments .. -, , , D:\MyDocuments, , -. , , , Virtual Directory - . , , - klutzy.

8) ? , . , IIS_IUSR , / ..

9) ? , , , SAP...

BLAST -

, -, Request URL- -. , .
, , , , CR OLE Windows... . . , -, DOS/Windows, -, , . ~/Folder/Folder/File.png, , - - , , , , - , .

. .

+5

... ( VS 2013) - !!!

1) insert- > picture

2) → →

3)

-

 "E:\tmp\wrk\s1.jpg"

+1

: CrystalImageHandler.aspx ( : c:\inetpub\wwwroot). 2 :

  • ISS Default Web SiteAdvanced SettingsPhysical Route %SystemDrive%\inetpub\wwwroot YourFolderName
  • %SystemDrive%\inetpub\wwwroot

. , .

0

All Articles