I am trying to carry out the images from a offline webpage loaded in the webbrowser control.
Following is the code.
Code:
WebBrowser wb = new WebBrowser();
wb.Navigate("Path of the offline web page [ImageTest.htm]");
HtmlElementCollection hec = wb.Document.Images;
foreach (HtmlElement he in hec)
{
string xstr = he.GetAttribute("src");
// Processing related to image
...............
...............
}
My problem is that the statement
Code:
HtmlElementCollection hec = wb.Document.Images
returns zero images or no ElementCollection in the HtmlElementCollection.
so i am not getting any image, though my offline document is having images.
Now interesting thing is that when i simplify the webpage by editing it, i can get the image in the collection.
Both the Normal and modified page are in the attachment.
ImageTest.htm is the original page.
ImageTest1.htm is the modified page.
The offline document that i have is composed in winword. Winword uses VML (Vector Markup Language) which converts <img> tags to <v:Imagedata> tags and blocks the working of <img> tag.
I tried to remove vml formatting from the doucment and got it working.
Can it be figured out that my webbrowser control can not process vml tags ie. it can not interpret <v:imagedata> as Image.
Is it possible to do something with vml formatting prior to loading document in web browser control?
No ofence, but MS Word is not a program that I'd use to make web pages. I'd use DreamWeaver, MS FrontPage and even Notepad. You are giving yourself too much hassle with doing it through Word. Ms Word puts a lot of unecessary stylesheets and stuff in there. Copy your word's text then Paste it in NotePad
No ofence, but MS Word is not a program that I'd use to make web pages. I'd use DreamWeaver, MS FrontPage and even Notepad. You are giving yourself too much hassle with doing it through Word. Ms Word puts a lot of unecessary stylesheets and stuff in there. Copy your word's text then Paste it in NotePad
True, but i want to make a complete solution, so it is necessary for me to interpret every html document irrespective of the editor in which it is composed.
And save it as an .html file - your project will work perfectly. As it should. Because you did this webpage in MS Word, it doesn't pick up the SRC attribute of the Images and doesn't pick up the IMG tag. Full stop.
Listen to what I'm saying, please I'm trying to help you, believe it or not
I am attching my HTML file here, along with 2 separate ways of looping through the HTML elements, one is easy, as I have shown, the second is very complicated
BTW, you'll see a folder called "Mine" in both projects - this you'll need to copy to your C Drive, as the web page is in there. For the second ( Complicated project ), there was a reference set to MS HTML Object Library; in case you're wondering....
Hope it helps...
Last edited by HanneSThEGreaT; June 15th, 2010 at 05:01 AM.
Listen to what I'm saying, please I'm trying to help you, believe it or not
Respected HanneSThEGreaT
I believe 100% that you are giving your 100% to help me out.
I am attching my HTML file here, along with 2 separate ways of looping through the HTML elements, one is easy, as I have shown, the second is very complicated
Hope it helps...
I have already tried with both type of methods and resulted in the hard luck.
I know that my problem is Word and believe me that i am not trying to harras anybody, but this is just my curosity to make it possible with that document too
Initially the task was over with the normal document, but when the word came in picture, questions were raised and i am just behind it to find the answer..
Hello shail24k
No problems at all, your'e not harrassing anyone LOL!
OK, if that is the case, the above methods will help us nothing. I'm thinking that we'll need to use a whole different approach. For example, use the TextReader / StreamReader to read the contents of the Word file(s), then try to conjure up something from that
Tell me this, do you only want to establish how many pictures are there in the file, or do you want to physically make use of those pictures - for example copy them / save them?
Tell me this, do you only want to establish how many pictures are there in the file, or do you want to physically make use of those pictures - for example copy them / save them?
The complete task is what,
1. Have to save the images in the folder.
2. The images will be edited by the designers.
3. The original images will be replaced with the modified one and then be sent in the form of mail.
The beauty of MS Word's way of doing things is that it already includes a folder along with the html file. For example, yours is imagetest.html - it generated a folder at the same location named imagetest_files with the pictures in it already. So logically I'd create a program that determines where the html file is, then identify its associated folder and copy the pictures from that folder into your own folder. Does that sound like a plan, or were you looking for something else?
For example, yours is imagetest.html - it generated a folder at the same location named imagetest_files with the pictures in it already
Ok, that can be done by this way, but when the designer will change the image, he will save it to another location. So need to change the src attribute of the image to locate that path.
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.