-
Re: [02/03] web app to display tiff to pdf
Quote:
Originally Posted by mendhak
So you mean something like this?
MyImage.ImageUrl = TextBox1.Text
?
I may be misunderstanding, but answer this
What exactly is going to be in the textbox? Will it be a full URL like
http://www.example.com/abc.tiff or is it going to be a file path like c:\sony\entertainment.tiff?
If it's a filename, you'll need to use System.Io namespace to perform a file.copy of the file to the folder you want. If it's an actual URL to a website that's not yours, then you'll need to do an HttpWebRequest to dynamically download that file to the folder you want.
It is going to be a filepath that says e:\systemfiles\apogee\edgar.tif
and since such is the case (and I apologize for getting the two confused..)then I need to put the filepath in an application folder and then map the current path itself stored in the folder to the image control..if that's possible.
-
Re: [02/03] web app to display tiff to pdf
Since it is e:\systemfiles\apogee\edgar.tif, you will need to use System.Io.File.Copy to copy that file to a folder that you want, which is the application folder.
That part is easy, the next part is
Quote:
and then map the current path itself stored in the folder to the image control
Again... do you mean the work with the constructor as we were doing earlier, the constructor of the Bitmap? Be very careful with your words here. Each word you use changes the answer to your problem and can lead you down a path you needn't be. From earlier in this thread, you were trying to load data into a Bitmap because you want to convert it to a JPG to show it on a web page. So if you need to pass it to the constructor of the bitmap, then give it the new file path that you copied it to from the original E:\systemfiles\etc.
-
Re: [02/03] web app to display tiff to pdf
Quote:
Originally Posted by mendhak
Since it is e:\systemfiles\apogee\edgar.tif, you will need to use System.Io.File.Copy to copy that file to a folder that you want, which is the application folder.
That part is easy, the next part is
Again... do you mean the work with the constructor as we were doing earlier, the constructor of the Bitmap? Be very careful with your words here. Each word you use changes the answer to your problem and can lead you down a path you needn't be. From earlier in this thread, you were trying to load data into a Bitmap because you want to convert it to a JPG to show it on a web page. So if you need to pass it to the constructor of the bitmap, then give it the new file path that you copied it to from the original E:\systemfiles\etc.
That second part hasn't changed though, I need to display the result on a webpage whether it be pdf format or jpeg format. And as you can see from earlier in threead I did try to stream result through a bitmap constructor and that failed.
-
Re: [02/03] web app to display tiff to pdf
But now you have a location. You are going to use the File.Copy method to copy it to a location of your choice. Because it's a location of your choice, you have the path to the TIFF. You can then pass that location to the constructor of the BITMAP class.
About what you did earlier in the thread, I did try explaining to you several times about what you were doing wrong, but you either weren't listening or didn't understand it. However, I can't explain it in any more clarity than I did, I do not have the capability to do so. Look, I probably sound rude, but I'm just telling you my observations.
If you are now acquiescing and are willing to display the TIFF in any format that you want, then there is an alternative - you can display TIFF files via Apple Quicktime.
Code:
<OBJECT CLASSID="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" WIDTH="100%" HEIGHT="100%"
CODEBASE="http://www.apple.com/qtactivex/qtplugin.cab">
<PARAM name="SRC" VALUE="car.tif">
<PARAM name="SCALE" VALUE="aspect">
</OBJECT>
-
Re: [02/03] web app to display tiff to pdf
Ok. Backtracking. I remember you said this:
byte[] theByteArray = yourBlobDataFromDatabase;
MemoryStream ms= new MemoryStream(theByteArray);
The first statement would be set whatever fullpath is or whatever I have stored it as and then once it hit the second statement it would be mapped to ms. After that you would map ms to Image1.ImageUrl to get the resultant image. Correct ?
-
Re: [02/03] web app to display tiff to pdf
Because you now have the full path, you don't need MemoryStream. It is irrelevant. I only suggested it because you were mentioning a database. Now you have a full path. Forget MemoryStream.
Code:
Dim bmp As New System.Drawing.Bitmap(YourImageTifFile)
There. Your Bitmap object. And the path to your file.
Start and work with the BitmapObject.
-
Re: [02/03] web app to display tiff to pdf
wait a minute didn't I have this earlier in the thread ?
Code:
Dim strUrl As String = txtPath.Text
Image1.ImageUrl = strUrl
Dim YourImageTifFile As String = Image1.ImageUrl
*** Dim bmp As Bitmap = New Bitmap(YourImageTifFile)
Response.ContentType = "image/jpeg"
bmp.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg)
bmp.Dispose()
Exactly as such. And when I ran the application it said that statement outlined here*** drew a parameter is not valid error.
-
Re: [02/03] web app to display tiff to pdf
Delete
Image1.ImageUrl = strUrl
Dim YourImageTifFile As String = Image1.ImageUrl
and change
Dim bmp As Bitmap = New Bitmap(YourImageTifFile)
to
Dim bmp As Bitmap = New Bitmap(strUrl)
It makes no sense to get the value from the textbox and then assign it to an imageurl and then read it out.
If you are getting a parameter is not valid error, then look at the path being passed to the bitmap object.
The Bitmap constructor does take a path to a file. If you are getting parameter is invalid, then you are passing something wrong to it.
-
Re: [02/03] web app to display tiff to pdf
Part one..the main problem I realized the disk path is not correct. The disk path is not accessible on my client machine and hence that is a big part of the problem.
I was suggested to use a Replace statement to change the path to read the urls from a different disk path altogether and this did not work. So it is more than likely the program as written does work as specified it is just it can not place and image in an image control when it can not grab the physical location that points to the image at that point in time.
I will test this by setting my disk path to an image resident on my computer to verify this 100 percent but this is my working theory.
-
Re: [02/03] web app to display tiff to pdf
Ok. I have definitely proved that it is the path that is the problem.
my code now reads something like this:
Code:
Dim _stream As System.IO.Stream = New System.IO.FileStream("c:/images/AB00B114.Tif", System.IO.FileMode.Open)
Dim _bmp As New Bitmap(_stream)
Context.Response.ContentType = "image/gif"
_bmp.Save(Context.Response.OutputStream, ImageFormat.Gif)
_bmp.Dispose()
_stream.Close()
The sample jpg image that I pointed to in strURL =Image1.ImageUrl.. I took from the My Pictures Folder and substituting the latter ( Image1.ImageUrl for the "c:/images... portion worked..it showed the the full jpg image so the code is sound to convert/ view a tif file.
Now I have to go back and have a conversation with whoever supplied me with that path information because even if I move the path info into an app folder in my web application it would not make a bit of difference since it still doesn't know where the images are being pulled from.
-
Re: [02/03] web app to display tiff to pdf
Ok. Just for giggles before I rule that out completely.. how would I move data that contains " fullpath" from the table in my database into a local folder in my web application to be saved there..to see if the same result is produced ?
-
Re: [02/03] web app to display tiff to pdf
Quote:
Originally Posted by Christopher_Arm
The sample jpg image that I pointed to in strURL =Image1.ImageUrl.. I took from the My Pictures Folder and substituting the latter ( Image1.ImageUrl for the "c:/images... portion worked..it showed the the full jpg image so the code is sound to convert/ view a tif file.
That's brilliant. So it's just a matter of placement now.
-
Re: [02/03] web app to display tiff to pdf
Quote:
Originally Posted by Christopher_Arm
Ok. Just for giggles before I rule that out completely.. how would I move data that contains " fullpath" from the table in my database into a local folder in my web application to be saved there..to see if the same result is produced ?
Not sure I understand this. Data that contains fullpath? What does that mean and what format is it in?
-
Re: [02/03] web app to display tiff to pdf
Quote:
Originally Posted by mendhak
Not sure I understand this. Data that contains fullpath? What does that mean and what format is it in?
1) Ok. To begin with there is a table I have where "fullpath" is a disk path stored in one of the columns that points to the image location for each recordset. It is designated as e:\blah blah.tif which means nothing to my machine as that location is not valid to my machine
2) Now since I am getting the network path not found error which suggests that my client machine does not have the accessible permissions by the admin to access the path directly via my dataset. Of course putting one and two together this all makes perfect sense now.
3) Now through my test earlier, I was able to access the disk path C:\Documents\MyPictures that is accessible to my machine. So it stands reason that I might simply need to migrate the data in this case fullPath into a folder added to my web application. For local access to the data that can't be reached directly funneling it by the query or by accessing it through a replace statement changing the string to access it by way of a network share I do not have permissions for...
This should be not unlike retrieving PDF files that are at the end of some physical path stored in a table that you would want to display in a similar fashion.
Something local is the key that will solve the problem entirely. The problems I am encountering at this point are a matter of accessing the actual relevant data pointing to the location of the images.
So that each time or pass in the dataset which is populated by my query has fullpath e:\ blah\ blah.tif in it places that location in my folder making it c:\blah\blah.tif and then my web app should be able to access the tif file to convert it locally and display it without any problems.
Essentially I need to migrate each time a record is selected that particular full path stored here and I am already doing that somewhat by selecting individuals records via my query I am pulling each fullPath and populating my webform.
Code:
txtPath.Text = ds.Tables(0).Rows(0)("fullpath").ToString()
Now what I am thinking is that I need to modify my code
and also place the resulting "fullPath" in a folder I will add to my application called ImageFiles.
The string of the physical disk path will be then grabbed from the folder location and placed it the first line of the code here where the string grabbed from the folder locally would be read where c:\images is here***
Code:
***Dim _stream As System.IO.Stream = New System.IO.FileStream("c:/images/AB00B114.Tif", System.IO.FileMode.Open)
Dim _bmp As New Bitmap(_stream)
Context.Response.ContentType = "image/gif"
_bmp.Save(Context.Response.OutputStream, ImageFormat.Gif)
_bmp.Dispose()
_stream.Close()
-
Re: [02/03] web app to display tiff to pdf
But each time the record is accessed and you get E:\, how will you migrate it from E:\ to C:\ if you don't have permissions?
Can't you perform the migration manually and then get all the TIF files to be stored in the C:\ path?
-
Re: [02/03] web app to display tiff to pdf
Quote:
Originally Posted by mendhak
But each time the record is accessed and you get E:\, how will you migrate it from E:\ to C:\ if you don't have permissions?
Can't you perform the migration manually and then get all the TIF files to be stored in the C:\ path?
How would I go about that exactly if I am denied permissions to access where the TIF files actually are ? The network path I was provided does exist but I do not have permissions to access it and of course how it is stored in the database as e:\..well e :\ is irrelevant since my machine does not recognize e:\ at all. That is the big problem I am faced with here. Is there another way to go about this from a manual standpoint ?
Because if not there is no manual option available to me to use.
And the solution I posed would do nothing save transfer the problem over to the folder since e:\ for all intents and purposes which again is irrelevant and refers to my DVD-RW drive.
-
Re: [02/03] web app to display tiff to pdf
I suppose there is another way to do this. If you know the network path, then you can convert
e:\path.tif
to
\\uncshare\folder\path.tif
Correct?
If you use ASP.NET impersonation so that you get your ASP.NET application to run under the security context of the user, then the user logged in may (will?) have permissions on that shared folder. This means that you will not get an access denied error message when you try this.
In order to do this, you will need to
1. Set windows authentication on your application
2. Set <identity impersonate="true"> in your web.config file.
-
Re: [02/03] web app to display tiff to pdf
Quote:
Originally Posted by mendhak
I suppose there is another way to do this. If you know the network path, then you can convert
e:\path.tif
to
\\uncshare\folder\path.tif
Correct?
If you use ASP.NET impersonation so that you get your ASP.NET application to run under the security context of the user, then the user logged in may (will?) have permissions on that shared folder. This means that you will not get an access denied error message when you try this.
In order to do this, you will need to
1. Set windows authentication on your application
2. Set <identity impersonate="true"> in your web.config file.
Ok. Dumb question I am asking here but is impersonation in the web config set the same way in Visual Studio 2008 ?
-
Re: [02/03] web app to display tiff to pdf
Ok I just checked this with MSDN and it is the same
You place this in between <system.web> </system.web>
And still I get network path not found issue and the path is a valid one and the Image1.ImageUrl picks up the path as stated.
Could it be before it gets to this part here
Code:
Dim _stream As System.IO.Stream = New System.IO.FileStream(Image1.ImageUrl, System.IO.FileMode.Open)
that Image1.ImageUrl needs to be passed in a byte array of some sort as a buffer before it is streamed ? But then would that even make a difference in resolving the problem it doesn't recognize the path as valid evne if it were passed through a byte the outcome would still be the same wouldn't it ?
-
Re: [02/03] web app to display tiff to pdf
Ok. Last thing to try that I can think of... just humor me here Mendhak...hmm ok how about...
each time the query is called my SELECT statement that has "fullpath" in it. How about placing the "fullpath" string data which has the path pointing to x image and save it to a ImageFolder ? I have done so with a filefield control in the past but not a textbox.
I have forgotten how do that exactly in any case.
Then like I said earlier we can take the existing data from the folder and stream that out to get the image in question.
-
Re: [02/03] web app to display tiff to pdf
Quote:
Originally Posted by Christopher_Arm
Ok. Dumb question I am asking here but is impersonation in the web config set the same way in Visual Studio 2008 ?
Yes.
-
Re: [02/03] web app to display tiff to pdf
Quote:
Originally Posted by Christopher_Arm
Ok I just checked this with MSDN and it is the same
You place this in between <system.web> </system.web>
And still I get network path not found issue and the path is a valid one and the Image1.ImageUrl picks up the path as stated.
Could it be before it gets to this part here
Code:
Dim _stream As System.IO.Stream = New System.IO.FileStream(Image1.ImageUrl, System.IO.FileMode.Open)
that Image1.ImageUrl needs to be passed in a byte array of some sort as a buffer before it is streamed ? But then would that even make a difference in resolving the problem it doesn't recognize the path as valid evne if it were passed through a byte the outcome would still be the same wouldn't it ?
I don't see what you placed in the web.config file. Show me exactly what you put there.
Did you set windows authentication in the security properties for the virtual directory?
Did you debug and step through the code?
Does the path that you're passing to it actually exist? Did you perform the appropriate replacements to make it a proper UNC path and not a normal e:\ path?
-
Re: [02/03] web app to display tiff to pdf
Quote:
Originally Posted by Christopher_Arm
Ok. Last thing to try that I can think of... just humor me here Mendhak...hmm ok how about...
each time the query is called my SELECT statement that has "fullpath" in it. How about placing the "fullpath" string data which has the path pointing to x image and save it to a ImageFolder ? I have done so with a filefield control in the past but not a textbox.
I have forgotten how do that exactly in any case.
Then like I said earlier we can take the existing data from the folder and stream that out to get the image in question.
The data in "fullpath" is a string. It is a string which means it is an entity that lives in the memory and means nothing in terms of the data to be saved to disk. It's like the number "7". You cannot save 7 to disk, you'll need to create a file and put it in there. But then it won't become 7, it'll become a file that happens to contain 7.
Similarly for fullpath, it won't actually be the file you want because it's a string and so will not help you at all.
-
Re: [02/03] web app to display tiff to pdf
Quote:
Originally Posted by mendhak
The data in "fullpath" is a string. It is a string which means it is an entity that lives in the memory and means nothing in terms of the data to be saved to disk. It's like the number "7". You cannot save 7 to disk, you'll need to create a file and put it in there. But then it won't become 7, it'll become a file that happens to contain 7.
Similarly for fullpath, it won't actually be the file you want because it's a string and so will not help you at all.
I agree. This might be a losing battle after all simply because the program from a logical standpoint works fine. It takes a tif file and put it on display from a physical disk path from the sample I used. However the problem exists with the actual physical path I have been provided. I did place the following in between <system.web></system.web> in my web.config file in that case <identity impersonate = "true" > and so on and that was fine but it did not solve the network path error I was getting at all.
I have also reasoned that the path not only does not exist at least from the angle where I wanted to get the path from the database and directly stream it and that was e:\ blah blah blah and that showed a device not ready error as e :\ is my dvd-RW. And the replace statement that replaced e:\ with uncshare\doc\path.tif did not work because I did not have permissions to access it from the admin.
Again this has nothing to do with the program as written..this is a network share issue. For all intents and purposes I have accomplished my objectives..the issue has become one of data integrity or rather data reliability.
-
Re: [02/03] web app to display tiff to pdf
Quote:
Originally Posted by Christopher_Arm
I agree. This might be a losing battle after all simply because the program from a logical standpoint works fine. It takes a tif file and put it on display from a physical disk path from the sample I used. However the problem exists with the actual physical path I have been provided. I did place the following in between <system.web></system.web> in my web.config file in that case <identity impersonate = true/ > and so on and that was fine but it did not solve the network path error I was getting at all.
And windows authentication set to true in IIS?
-
Re: [02/03] web app to display tiff to pdf
Quote:
Originally Posted by mendhak
And windows authentication set to true in IIS?
Yes.