-
[02/03] web app to display tiff to pdf
Iam working on a application in asp.net to display tiff images however I realized there is no direct way to do this except thorugh conversion to another file standard like JPEG or PDF. So I came up with this and I get an invalid parameter error. Anyone know what could be the cause of this ? In this case from the below sample code I used tiff to jpeg format. If I figure this out if it is safe to assume that I shoukd be able to do the same for a tiff to pdf conversion.
Code:
Private Sub btnUpload_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnUpload.Click
Dim originalimg, thumb As System.Drawing.Image
Dim objConn As SqlConnection = New SqlConnection("server =dummy-SQL;database =x_blah;uid=x_blaise;password=SSSSS")
objConn.Open()
Dim ds As DataSet = New DataSet
Dim dv As DataView
Dim objCommand As SqlCommand
Dim objDataAdapter As New SqlDataAdapter
objDataAdapter.SelectCommand = New SqlCommand
objDataAdapter.SelectCommand.Connection = objConn
objDataAdapter.SelectCommand.CommandText = _
"SELECT FirstName +''+''+ LastName as Name, SN,Suffix, cast(Floor(cast(Date_Orig as Float)) as Datetime)as Date, Code,record, count,App, Fil, file,page, fullpath from dbo.t_S where hex_Number = '" & CStr(txtNo.Text) & "'"
objDataAdapter.Fill(ds, "dbo.x_blah")
dv = New DataView(ds.Tables("dbo.x_blah"))
'dataset filled now populating corresponding text fields'
txtLastName.Text = ds.Tables(0).Rows(0)("Name").ToString()
txtSN.Text = ds.Tables(0).Rows(0)("SN").ToString()
txtOrigin.Text = RTrim(ds.Tables(0).Rows(0)("Date").ToString())
txtApp.Text = ds.Tables(0).Rows(0)("App").ToString()
txtPageNum.Text = ds.Tables(0).Rows(0)("page").ToString()
txtPath.Text = ds.Tables(0).Rows(0)("fullpath").ToString()
' now getting ready to view the image in the recordset taken from fullpath '
Dim strURL As String = Replace(txtPath.Text, "c:\BloodBank\", "\\nxs-appX\gelatin$\")
'Dim img As Image = Image.FromFile(strURL)
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()
-
Re: [02/03] web app to display tiff to pdf
I 've updated the last portion and now it gives me an error of invalid parameter around the line of code that defines the Bitmap.
Here:
Code:
Dim YourImageTifFile As String
YourImageTifFile = Image1.ImageUrl
Dim bmp As New System.Drawing.Bitmap(YourImageTifFile)
Response.ContentType = "image/jpeg"
bmp.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg)
bmp.Dispose()
Return
-
Re: [02/03] web app to display tiff to pdf
Look at the constructors for the Bitmap class.
http://msdn.microsoft.com/en-us/libr...ap.bitmap.aspx
You will need to pass one of the types it's expecting, I don't think you can pass it an image URL.
-
Re: [02/03] web app to display tiff to pdf
The closest you can get to it is passing the disk path to the image.
-
Re: [02/03] web app to display tiff to pdf
Quote:
Originally Posted by mendhak
The closest you can get to it is passing the disk path to the image.
so...based on this train of thought I was thinking if I put a folder in my web application and downloaded the blob data which are url pointing the location of the files stored as varchar (that are tif files) into that folder by some sql query and then put the tif files in the folder could I then put the path of the folder holding the image files and get the current one that matches the individual recordset therefore everything is local to application and accessible immediately. Could that work ? Moving the urls pointing to the images in x folder and then referencign the path to that image folder in my web application ?
-
Re: [02/03] web app to display tiff to pdf
If it's BLOB data in your database, you should be able to get the byte array and put that into a Stream. You can then pass the Stream to the constructor. This way you don't have to save the file to disk and 'waste resources'.
-
Re: [02/03] web app to display tiff to pdf
Quote:
Originally Posted by mendhak
If it's BLOB data in your database, you should be able to get the byte array and put that into a Stream. You can then pass the Stream to the constructor. This way you don't have to save the file to disk and 'waste resources'.
Are there any tips or examples on how that would be done..I know I saw something on the subject recently ?
-
Re: [02/03] web app to display tiff to pdf
Code:
byte[] theByteArray = yourBlobDataFromDatabase;
MemoryStream ms= new MemoryStream(theByteArray);
-
Re: [02/03] web app to display tiff to pdf
something like this then perhaps ?
Code:
Dim theByteArray() As Byte = ds.Tables(0).Rows(0)("fullpath")
Dim ms As MemoryStream = New MemoryStream(theByteArray)
Dim strURL As String = Replace(txtPath.Text, "e:\blah\", "\\mblah\d$\")
'Dim img As Image = Image.FromFile(strURL)
Image1.ImageUrl = strURL
Dim YourImageTifFile As String
YourImageTifFile = Image1.ImageUrl
Dim bmp As New System.Drawing.Bitmap(Server.MapPath(YourImageTifFile))
Response.ContentType = "image/jpeg"
bmp.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg)
bmp.Dispose()
-
Re: [02/03] web app to display tiff to pdf
Well, no, because you're loading the stream but not passing it to the constructor.
Code:
Dim bmp As New System.Drawing.Bitmap(ms)
Just out of curiosity, is 'thefullpath' the name of the column in your table which has BLOB data in it?
-
Re: [02/03] web app to display tiff to pdf
Quote:
Originally Posted by mendhak
Well, no, because you're loading the stream but not passing it to the constructor.
Code:
Dim bmp As New System.Drawing.Bitmap(ms)
Just out of curiosity, is 'thefullpath' the name of the column in your table which has BLOB data in it?
yes and this has given me a string can be passed as a one dimensional byte error. fullpath on the database end is a VARCHAR.
so then something like this:
Code:
Dim theByteArray As Byte = "fullpath"
Dim ms As MemoryStream = New MemoryStream(theByteArray)
Dim bmp As New System.Drawing.Bitmap(ms)
Response.ContentType = "image/jpeg"
bmp.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg)
bmp.Dispose()
Return
ok that's giving me this error:Input string was not in a correct format.
btw the rest of the code above the snippet looks like this:
Code:
txtPath.Text = ds.Tables(0).Rows(0)("fullpath").ToString()
Dim strURL As String = Replace(txtPath.Text, "e:\bl\", "\\blah\b$\")
Dim imageBytes() As Byte = Nothing
Image1.ImageUrl = strURL
Dim theByteArray As Byte = "fullpath"
Dim ms As MemoryStream = New MemoryStream(theByteArray)
Dim bmp As New System.Drawing.Bitmap(ms)
-
Re: [02/03] web app to display tiff to pdf
Let's step back for a moment here. Do you or don't you have BLOB data in your database? Posts #5, 6 and 7 give me the impression that you have the file stored inside the database. So I was trying to help you by mentioning how you'd use a byte array in a Bitmap constructor. But now you're telling me that you have a path to the file which is already on disk instead. Which one is it?
-
Re: [02/03] web app to display tiff to pdf
Quote:
Originally Posted by mendhak
Let's step back for a moment here. Do you or don't you have BLOB data in your database? Posts #5, 6 and 7 give me the impression that you have the file stored inside the database. So I was trying to help you by mentioning how you'd use a byte array in a Bitmap constructor. But now you're telling me that you have a path to the file which is already on disk instead. Which one is it?
I have both quite frankly the url that points to the image is stored in a SQL database. However it also the images are also existing on a disk path as is evident with the replace code above.
I would prefer to use the disk path method even though it might waste resources.
-
Re: [02/03] web app to display tiff to pdf
So we're back to square 1.
Since this
ds.Tables(0).Rows(0)("fullpath").ToString()
contains the full path to the image, just pass that to the Bitmap constructor.
-
Re: [02/03] web app to display tiff to pdf
Quote:
Originally Posted by mendhak
So we're back to square 1.
Since this
ds.Tables(0).Rows(0)("fullpath").ToString()
contains the full path to the image, just pass that to the Bitmap constructor.
Code:
Dim bmp As New System.Drawing.Bitmap(ds.Tables(0).Rows(0)("fullpath").ToString())
Response.ContentType = "image/jpeg"
bmp.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg)
bmp.Dispose()
ok. I feel like I am missing something after defining the bmp constructor. And it is throwing an invalid parameter error.
-
Re: [02/03] web app to display tiff to pdf
Does
ds.Tables(0).Rows(0)("fullpath").ToString()
evaluate (debug it to see) to a complete path on your machine?
Like
C:\something\blah\image.jpg
?
-
Re: [02/03] web app to display tiff to pdf
Quote:
Originally Posted by mendhak
Does
ds.Tables(0).Rows(0)("fullpath").ToString()
evaluate (debug it to see) to a complete path on your machine?
Like
C:\something\blah\image.jpg
?
I 'll have to see what happens by doing that today. However a serious glitch I am seeing is the breakpoints are not firing in debug mode in VS2003. And that I can't explain.
ok I get a specified cast is not valid error upon hitting this line
Dim bmp As System.Drawing.Bitmap() = (ds.Tables(0).Rows(0)("fullpath"))
-
Re: [02/03] web app to display tiff to pdf
I recently tried this to no avail with the same error returned:
Specified cast is not valid.
Code:
Dim BytesArr() As Byte = DirectCast(ds.Tables(0).Rows(0)("fullpath"), Byte())
Dim stream As New MemoryStream(BytesArr, True)
stream.Write(BytesArr, 0, BytesArr.Length)
Dim bmp As System.Drawing.Bitmap = New System.Drawing.Bitmap(stream)
bmp.Save(Server.MapPath("ImagesFiles\pic.jpeg"))
stream.Close()
Me.Image1.ImageUrl = Server.MapPath("images\pic.jpeg")
-
Re: [02/03] web app to display tiff to pdf
try this (Make sure ds.Tables(0).Rows(0)("fullpath") has valid byte data in it,if u want check it out with northwinds category table first)
Code:
Dim Image() As Byte = ctype(ds.Tables(0).Rows(0)("fullpath"), Byte())
Dim fs As New FileStream(Server.MapPath("images\pic.jpeg"), FileMode.CreateNew)
Dim bw As New BinaryWriter(fs)
bw.Write(Image)
bw.Close()
Image1.ImageUrl = "images\pic.jpeg"
Hope this will help u.
-
Re: [02/03] web app to display tiff to pdf
damn. he is right.... no wonder I had an invalid cast error thrown there isn't byte data in the SQL database. Instead fullpath is represented as a VARCHAR datatype. The urls stored in fullpath( a column in the database) pointing to the locations the images are stored are all varchar. How do I get around this mess ?:confused:
-
Re: [02/03] web app to display tiff to pdf
if you are saving file path of the image than you should copy the original image to you "images\" and rest will be same........isn't it?
-
Re: [02/03] web app to display tiff to pdf
Quote:
Originally Posted by riteshjain1982
if you are saving file path of the image than you should copy the original image to you "images\" and rest will be same........isn't it?
I am going to have to find a way to populate a folder I will add to my application to basically have the urls that are pointing to the image locations placed in the application folder and then once there the code will have to grab the current url that matches the recordset from the db and then show the image that is being pointed to by the URL by streaming this through a byte array and then the image control itself.
-
Re: [02/03] web app to display tiff to pdf
Quote:
Originally Posted by Christopher_Arm
I am going to have to find a way to populate a folder I will add to my application to basically have the urls that are pointing to the image locations placed in the application folder and then once there the code will have to grab the current url that matches the recordset from the db and then show the image that is being pointed to by the URL by streaming this through a byte array and then the image control itself.
if you gona a store image in your application folder and it's path in your DB than whats need to reconvert in into stream of byte and back to image for image control :rolleyes: ..
may me you should store the images as ID.extension in your image folder so later on will be more easy to retrive it back from DB to Image control
-
Re: [02/03] web app to display tiff to pdf
Quote:
Originally Posted by riteshjain1982
if you gona a store image in your application folder and it's path in your DB than whats need to reconvert in into stream of byte and back to image for image control :rolleyes: ..
may me you should store the images as ID.extension in your image folder so later on will be more easy to retrive it back from DB to Image control
Fair enough. I only realized afterwards that didn't make much sense to go back the database if everything I needed was stored at a given file location in my application. However the last part that you mentioned sounds ok although if you look earlier in this thread Mendhak mentions this might be wasteful in terms of resources handled by my application.
-
Re: [02/03] web app to display tiff to pdf
hmm well buddy didnt knew that but if i not understood wrong your req. is "you have some image files related to particular record and u want that to be shown in image control".....in this case according to me first of all you should not stored files in DB (blob)directly,secondly if image file is coming from user than renames and stored under one particular folder with renaming them as i said above,so there wont be any probelm.
-
Re: [02/03] web app to display tiff to pdf
Quote:
Originally Posted by riteshjain1982
hmm well buddy didnt knew that but if i not understood wrong your req. is "you have some image files related to particular record and u want that to be shown in image control".....in this case according to me first of all you should not stored files in DB (blob)directly,secondly if image file is coming from user than renames and stored under one particular folder with renaming them as i said above,so there wont be any probelm.
My primary concern step by step.or rather taking things one step at a time is a) converting a varchar which is what "fullpath" is coming in as into this statement here from my DB into this dataset that I am attempting to store in this bytearray here...
Dim BytesArr() As Byte = DirectCast(ds.Tables(0).Rows(0)("fullpath"), Byte())
causing my error of specific cast invalid in the first place. Because it doesn't like the casting of string into byte directly I am afraid. I first have to find a way around this somehow. Then I can move forward.
-
Re: [02/03] web app to display tiff to pdf
Quote:
Originally Posted by Christopher_Arm
My primary concern step by step.or rather taking things one step at a time is a) converting a varchar which is what "fullpath" is coming in as into this statement here from my DB into this dataset that I am attempting to store in this bytearray here...
Dim BytesArr() As Byte = DirectCast(ds.Tables(0).Rows(0)("fullpath"), Byte())
causing my error of specific cast invalid in the first place. Because it doesn't like the casting of string into byte directly I am afraid. I first have to find a way around this somehow. Then I can move forward.
solution depend upon the way you want to save file
1>If you want to save file in BLOB format than first change the code which saves your data into DB,there convert the image into byte using...
Code:
Dim fs As New IO.FileStream(strFilePathName, _
IO.FileMode.Open)
Dim br As New IO.BinaryReader(fs)
Dim abyt() as byte
abyt = br.ReadBytes(CInt(fs.Length))
br.Close()
Save abyt value in you "fullPath" column and it will resolve u r problem
2>If you save only image Path in "fullPath" coulmn than solution i told in previous post will help u.
-
Re: [02/03] web app to display tiff to pdf
ok fullpath has to be converted to a byte so I used this:
Code:
Dim strURL As String = Replace(txtPath.Text, "e:\blah\", "\\blah\dblah$\")
Dim bRet(strURL.Length - 1) As Byte
For i As Integer = 0 To strURL.Length - 1
bRet(i) = Asc(strURL.Substring(i, 1))
Next
Dim ms As MemoryStream = New MemoryStream(bRet)
Dim bmp As New System.Drawing.Bitmap(ms)
bmp.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg)
bmp.Dispose()
of course this gives me invalid parameter error..but I feel closer to the solution.
-
Re: [02/03] web app to display tiff to pdf
Quote:
Originally Posted by Christopher_Arm
ok fullpath has to be converted to a byte
you wont achived anything by saving PATH as byte,u need to convert and save File at that path into Array of byte.
-
Re: [02/03] web app to display tiff to pdf
Quote:
Originally Posted by riteshjain1982
you wont achived anything by saving PATH as byte,u need to convert and save File at that path into Array of byte.
ok are you saying to change as Byte to as File because if so I am getting an integer can not be converted to system.IO.File appearing now.
right about here an this point in the code***
Code:
Dim bRet(Image1.ImageUrl.Length - 1) As File
For i As Integer = 0 To Image1.ImageUrl.Length - 1
***bRet(i) = Asc(Image1.ImageUrl.Substring(i, 1))***
Next
Dim ms As MemoryStream = New MemoryStream(bRet)
Dim bmp As New System.Drawing.Bitmap(ms)
bmp.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg)
bmp.Dispose()
-
Re: [02/03] web app to display tiff to pdf
-
Re: [02/03] web app to display tiff to pdf
Quote:
Originally Posted by Christopher_Arm
I 'll have to see what happens by doing that today. However a serious glitch I am seeing is the breakpoints are not firing in debug mode in VS2003. And that I can't explain.
ok I get a specified cast is not valid error upon hitting this line
Dim bmp As System.Drawing.Bitmap() = (ds.Tables(0).Rows(0)("fullpath"))
If your breakpoints don't work, go to your temporary asp.net files folder and delete everything in there.
C:\windows\Microsoft.NET\Framework\v1.1.4322\Temporary ASP.NET Files
Also, turn off the Indexing Service on your machine.
Start > Run > services.msc
-
Re: [02/03] web app to display tiff to pdf
Quote:
Originally Posted by Christopher_Arm
damn. he is right.... no wonder I had an invalid cast error thrown there isn't byte data in the SQL database. Instead fullpath is represented as a VARCHAR datatype. The urls stored in fullpath( a column in the database) pointing to the locations the images are stored are all varchar. How do I get around this mess ?:confused:
That's what I said in post #14. It's a path to an image. It's not the byte data of an image. You don't need the stream anymore.
-
Re: [02/03] web app to display tiff to pdf
Quote:
Originally Posted by Christopher_Arm
ok are you saying to change as Byte to as File because if so I am getting an integer can not be converted to system.IO.File appearing now.
right about here an this point in the code***
Code:
Dim bRet(Image1.ImageUrl.Length - 1) As File
For i As Integer = 0 To Image1.ImageUrl.Length - 1
***bRet(i) = Asc(Image1.ImageUrl.Substring(i, 1))***
Next
Dim ms As MemoryStream = New MemoryStream(bRet)
Dim bmp As New System.Drawing.Bitmap(ms)
bmp.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg)
bmp.Dispose()
OK, let me repeat myself, this time I'll try to be clearer.
You have a fullpath value in your database. The fullpath value is a string or varchar (same thing). You mentioned that you don't have the actual byte data in your database. The fullpath is the location of the actual image that you want to work with. Therefore, there is no binary data involved here. Get rid of your memorystream code.
One of the constructor arguments that Bitmap takes is a path to an image. A path to an image. That means your fullpath value. So all you need at this point is to pass fullpath to your Bitmap constructor.
vb Code:
Dim bmp As New System.Drawing.Bitmap(ds.Tables(0).Rows(0)("fullpath").ToString())
Do whatever you need to to find out what the value of
ds.Tables(0).Rows(0)("fullpath").ToString()
is.
Response.Write it out to the page if you have to. You will also need to ensure that an image actually exists at the location that fullpath is pointing to. If there is no image there, then you need to rethink how (and why) you're storing the value of fullpath the way that you are.
-
Re: [02/03] web app to display tiff to pdf
Good lord. I still haven't solved this one yet. txtPath.text where is set equal to ds.Tables(0).Rows(0)("fullpath").ToString() is equal to the c:\blah\blah.tif file.
Now what ? I had seen demonstrated that the url does indeed point to an iamge.
-
Re: [02/03] web app to display tiff to pdf
And does the c:\blah\blah.tif file exist?
-
Re: [02/03] web app to display tiff to pdf
ok this ties in..how do I take textbox data and place that specific data into that app folder. The data of course is the url location. That way I will grab the location from the folder and place it in the image control and it should work Mendhak.
-
Re: [02/03] web app to display tiff to pdf
Quote:
Originally Posted by mendhak
And does the c:\blah\blah.tif file exist?
Yes. the problem is that I don't have access permissions to the folder in question to grab the urls from there that point to the image. The folder exists on a network share I am denied. So a new strategy is required, instead I have my dataset which has the records of all the data I am looking for placed into textboxes right ? Including fullpath which is the URL pointing to x image. Ok. Then I need to store the URL's into a application folder and then grab them locally from there map them to the image control. Once that is done they should appear without any problems.
-
Re: [02/03] web app to display tiff to pdf
Quote:
Originally Posted by Christopher_Arm
ok this ties in..how do I take textbox data and place that specific data into that app folder. The data of course is the url location. That way I will grab the location from the folder and place it in the image control and it should work 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.
-
Re: [02/03] web app to display tiff to pdf
Quote:
Originally Posted by Christopher_Arm
Yes. the problem is that I don't have access permissions to the folder in question to grab the urls from there that point to the image. The folder exists on a network share I am denied. So a new strategy is required, instead I have my dataset which has the records of all the data I am looking for placed into textboxes right ? Including fullpath which is the URL pointing to x image. Ok. Then I need to store the URL's into a application folder and then grab them locally from there map them to the image control. Once that is done they should appear without any problems.
I am not sure how you're mapping it to a full URL but in that case, yes, use an HttpWebRequest to download the file to a folder of your choice so that you can get the binary data out of it and give it to your Bitmap object.
-
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.