Cannot Save Full Web Page as Image (anymore)

Unanswered Cannot Save Full Web Page as Image (anymore)

  • mercredi 28 mars 2012 16:01
     
      A du code

    I have an application that is supposed to capture an entire web page as an image.  Here, "supposed to" are the operative words.  This application used to work fine.  Now it doesn't work anymore.  It is based on the Code Project article at This Link.  The main differences are that my application allows user to input an IE window title, and specify an output image file name.  Otherwise, it works similarly.

    Basically, the application finds the document window of the IE window, and obtains both the visible window size and the actual document size, using code like this: 

                    myDoc.body.setAttribute("scroll", "yes", 0);
                    int docWidth = Convert.ToInt32(myDoc.body.getAttribute("scrollWidth", 0));
                    int docHeight = Convert.ToInt32(myDoc.body.getAttribute("scrollHeight", 0));
                    int screenWidth = Convert.ToInt32(myDoc.body.getAttribute("clientWidth", 0));
                    int screenHeight = Convert.ToInt32(myDoc.body.getAttribute("clientHeight", 0));

    It then proceeds to take snapshots of each visible "page" of the document, add them to a bitmap object, then scroll the screen using this code, which is in the middle of an "i" loop:

        myDoc.body.setAttribute("scrollTop", (screenHeight - 5) * i, 0);

    The loop repeats until the entire height of the web page is saved.  At that point, it saves the resulting bitmap to a file.

    So here's the problem:  Ever since I upgraded my Adobe Reader from 9.x to 10, the scrolling part stopped working.  I end up with a bitmap where the top portion is the first screen of my active page, but the balance of the image is just black.  This happens whether I use my application or the Code Project application linked above.

    Not only does the scrolling not work, but the "scrollHeight" and "clientHeight" attributes are now equal, where the former used to be much larger than the latter on a tall page.  Even after I manually set the "scrollTop" attribute to a large number, retrieving it again always returns 0, so it stays on the first "page" of the entire web page.

    To fix this, I uninstalled and reinstalled IE 7, and down-graded my Adobe Reader X back to 9.x version.  I did both of these steps multiple times and in different orders.  Still, keeps not working.

    Yesterday, I upgraded to IE 8, and STILL doesn't work.  That Adobe Reader X did a number on my system.  I don't want to re-image my entire system.  I tried for some time to find references to this issue on the Adobe forums, and posted a question about it, but they never got back to me.

    Can anybody on this forum provide any input?  Just to further confuse the issue:  My company has a web site for users to sign up for their insurance.  At the end of the signup, there is a button to get a print preview of the entire series of screens which were gathering information during signup.  I don't know exactly how it works, but the code creates a new browser window, and copies the entire web site from memory to the new window, including stylesheet info, frames info, html, data entered, everything.  On THAT browser window, my code still works, and scrolls the window properly.

    TIA...


    Ron Mittelman

Toutes les réponses

  • mercredi 28 mars 2012 20:49
     
     

    Hi Ron,

    this forum is for questions about html, css and scripting for Web developers using MSIE browsers.

    I think your best bet would be to ask/pay the CodeProject author.

    Regards.


    Rob^_^

  • mercredi 28 mars 2012 21:06
     
     

    Hi Rob,

    While I appreciate your comment, contacting the CodeProject author would be fruitless for these reasons:

    • The code works fine on other PCs in my office
    • The code as published in codeProject does not work on IE7 or above.  This is because of the different object heirarchies of the different browser versions.  My code has been modified to act properly depending on browser version.

    Furthermore, I'm convinced this is exactly the type of issue that these forums should be able to address.  I may have the wrong particular forum, but I DO need an IE-related Microsoft forum.  As mentioned previously, I did post this issue on the Adobe forums, and not one person replied.  The MS forums, in contrast, are very responsive.  My issue with some code working, then not working, in IE should be addressed in some MS forum.

    Perhaps somebody can direct me to a better MSDN forum?

    Thanks...


    Ron Mittelman

  • mercredi 28 mars 2012 23:07
     
     

    You don't yell to a busy street when looking for doctors. You go to hospitals for them. High traffic does not get you a better answer rate.

    The article you sited is not using documented IE APIs like IHTMLElementRender::DrawToDC, it is surprising that it worked on your system for so long. No, IE APIs are not discussed in this forum, there is another forum for them.

    Before you go to that forum, you probably want to make sure your problem is IE-related. Why you mention Adobe Reader? Are you drawing PDF files in a webbrowser control? If so IE does not control the drawing, it is Adobe's Reader does the drawing. If Adobe is drawing to the screen directly, skipping the container, there is nothing IE can give you about what is on the screen.



    The following is signature, not part of post
    Please mark the post answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem.
    Visual C++ MVP





  • jeudi 29 mars 2012 02:12
     
     

    I guess you think your 112,015 points entitle you to be condescending to others.  I have no idea what you mean by yelling at a busy street.  I went to what I thought was the proper forum, and stated my problem as clearly as possible.  I also mentioned posting to the Adobe forums, which nobody answered.  I was complimenting the MSDN forum members by saying how responsive they are.

    While Rob told me this was the wrong forum and suggested I contact the author, at least he stated that with respect.  You see my answer to him explaining why approaching the author would probably not work.

    Your last paragraph tells me you did not understand my inquiry at all.  If you were more interested in helping a fellow developer than putting him/her down, perhaps you would have paid more attention to my inquiry.  Nowhere did I say that I was trying to draw PDF files, or address Adobe Reader directly.  I very clearly stated that my code is designed to save the displayed contents of a web page to an image file, using well-established and documented Microsoft objects, in this case ShDocVw.  The code worked perfectly well on multiple PCs, and only stopped working on mine after I upgraded my Adobe Reader 9.3 to Adobe Reader X.

    I guess you addressed my last statement by directing me to the other forum, but you would have done much better simply replying with the last sentence in your second paragraph above.  I have no idea why you think being an MVP entitles you to talke down to other members.


    Ron Mittelman

  • jeudi 29 mars 2012 05:54
     
     

    I did not say anything about your personality, not sure why you think I am taking down to you. 

    By saying "yelling to a street", I mean you posted to a wrong forum, got pointed out by a forum member, and insist to stay here because it is more responsive. A responsive forum that does not cover your question does not help you to get the help you need, as you may already found out. Staying here instead of going to a closer forum only reduce your question's exposure to the experts who can help you. If you are looking for doctors, at least go to a street next to a hospital first. Don't get offended if someone tell you a hospital is not nearby. This forum is for web designers who write web sites instead of applications. Asking them to fix your application is like asking a bunch of TV show producers to fix your customized TV.

    I mention PDF files because you mention Adobe Reader, which opens PDF files instead of web pages. An Adobe Reader upgrade does not affect IE's rendering of web pages as it is not loaded by IE until a PDF file is rendered. I don't know why you mention the software, so I want to double check.

    If I merely direct you to the correct forum without addressing the issue of abusing a forum's traffic, that creates a bad example that others will follow. I have been in online community for more than a decade and already see more than enough forums die because of lowering the bar of off-topic posts.



    The following is signature, not part of post
    Please mark the post answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem.
    Visual C++ MVP




  • jeudi 29 mars 2012 06:27
     
     

    Ron,

    your in the wrong forum (full stop). Sheng has directed you to the topic specific MSDN forum - IE Extension Development forum... these are all public forums.... anybody (if they think they have an answer) can respond to questions.... the problem is the expectations of ppl asking questions.... (yelling in a busy street).... we volunteer our time, we do not work for nor represent MS...

    you have three choices ...Post to the correct forum, Ask the original author of your software for help/support or raise a paid support ticket with support.microsoft.com...

    One has to ask why you have not first acknowledged the efforts of the original author by making enquiries with them first...theCodeProject is a public developer community also. Your contribution there on the authors thread would contribute to the knowledge of all. Unfortunately you have chosen the wrong MSDN forum, and your question is Off Topic.

    I trust that once you find a solution you will publish it in the public domain at thecodeproject, acknowledging the work of the original author building apon the effort that they originally authored.


    Rob^_^

  • jeudi 29 mars 2012 15:11
     
     

    Sorry if I over-reacted to your reply. I was quite willing to switch to a better forum if one existed. I see nothing in my comments about insisting on staying with the wrong forum.  I only commented in general about the better responsiveness of the MSDN forums, and that I would prefer to stay with them.  Please review my last 2 sentences to Rob.  I distinctly asked to be directed to a more appropriate forum.  Then you begin telling me how I should not insist on staying with the wrong forum.  You did not pay attention to my original post, or you would not have said what you did, as well as ask about why I was mentioning Adobe reader.  My code A) uses published MS technology, and B) has nothing to do with Adobe Reader.  Only that my code stopped working after upgrading to Reader X. Adobe Reader definitely has some interaction with the browser.  This is beyond my level of knowledge, but it does install browser extensions during its install.  It makes you close all explorer instances before completing.  Who knows what it does under the hood to IE's configuration and/or registry entries?

    That being said I agree it's stupid to stay with wrong forum.  I have reposted to the one you suggested.  Please don't assume bad behavior when it is just a mistaken forum choice.


    Ron Mittelman

  • jeudi 29 mars 2012 15:35
     
     

    Hi Rob,

    Yes, I get that it is the wrong forum.  I get that everybody volunteers to help others.  I know I'm new to the MSDN forums (see my impressive 10 points?), but I've posted and answered to many forums over the years.  If I got the wrong one, a simple "you should post this in the xyz forum instead" would suffice.  I know getting an answer is like asking for a favor.  When you've never posted to an IE related forum, there is not that much difference between the names "Internet Explorer Web Development" and "Internet Explorer Extension Development".  I just picked the wrong one.  It's not like I was insisting on asking C# or MSOffice questions on this forum.

    I have followed the CodeProject article.  When his code stopped working post-IE6, and this problem was posted in the comments, I researched the issue and posted a detailed solution on the thread.  He never updated his code or commented on the solution.  I would have posted there about the present issue, but it didn't seem pertinent to his article.  The code works fine on any other PC I try it on, and only stopped working when Reader X was installed.  An IE-related forum seemed more appropriate to ask the question in.  My bad luck to start with the wrong one of the two.

    I certainly will post any solution I find there, and also in the IE extension forum.  BTW, thanks for the well-thought, non-condescending wording of your replies.


    Ron Mittelman

  • jeudi 29 mars 2012 22:03
     
     

    thanks for your understanding also...no-body knows everything, we all have a niche, keeping on topic to the forum helps others also. There is no on-stop shop for computing solutions.

    You have to laugh at shengs' "shouting on a busy street" analogy... I am sure he did not mean to be codescending, but was actually defending my initial reply... it is very hard to effectively communicate in forums with only the typed word, especially conveying technical issues. If you browse my posts here you will see some of my 'classics'

    we can read code better than we can minds.... asking a question about html, css or scripting in this forum without giving a link to a website or mashup is like "shouting in a busy street".... we can hear you, but we don't understand because a busy street is noisy and everyone is focused about going about with their own business....  

    ha ha... I am sure "shouting on a busy street" will stick in your mind for a while and will now make you laugh too...

    Regards.


    Rob^_^