Technology Questions

Go Back   Technology Questions > Software Questions > Internet > Internet Explorer

Internet Explorer Discuss IE7 or any other IE version.

Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old 10-30-2007, 10:20 PM
bsg92618
Newsgroup Contributor
 
Posts: n/a
powerpoint saga

I work for a company that has very rigid security guidelines.

I have been given a project to convert a PowerPoint presentation into a web
site that looks exactly like the ppt. this part was easy.

Then I have to provide a button that will convert the whole web site into a
PowerPoint presentation that the user can save on his local machine. The
website is database driven. The approach that I have taken is to dynamically
create the html for each page and save it to a file on the server. Then I
load the page into an IE window and capture to web page as a jpg image. As I
load the html, file into I Explorer the page changes to allow me to create
the next image file. My IT department in their infinite wisdom sees this as
a major security breach.

I need a way turn my html files into an image file without loading it into
IE. Please I need some help. I have looked all over the internet and the
only thing I could find is someone having the same type of issue but no one
has replied to him. I will past my code below.



my work email is alvis.floyd@ngc.com

please someone help me



This is a snippet from my constructor method





using System;

using mshtml;

using System.Windows.Forms;

using System.ComponentModel;

using System.Drawing.Imaging;

using System.Diagnostics;

using System.Drawing;

using System.Security.Principal;

using System.Collections.Generic;

using System.Configuration;

using System.Data;

using System.Data.SqlClient;

using System.Text;

using SHDocVw;

using System.Runtime.InteropServices;

using System.IO;

using System.Text.RegularExpressions;

using Microsoft.Office.Core;

using Microsoft.Office.Interop;

using Oracle.DataAccess.Client;

using System.Collections.Specialized;

using PowerPoint = Microsoft.Office.Interop.PowerPoint;

//framework Dll for visweb project

using NG_Support_FrameWork;

using NG_GH_FrameWork;



SHDocVw.WebBrowser m_browser = null;
m_browser = new SHDocVw.WebBrowser();
mshtml.IHTMLDocument2 myieDoc =
(mshtml.IHTMLDocument2)m_browser.Document;
CreateImage(Number_OF_Pages, myieDoc);



The variable Number_OF_Pages is a string array that holds the path to each
html file. The html files has access to all the images and style sheets
needed to render the page the next method is where I create and save the
images



private void CreateImage(string[] PageArray, mshtml.IHTMLDocument2 myDoc)
{



try
{
for (int x = 0; x != Number_OF_Pages.Length; x++)
{
if (Number_OF_Pages[x] != null)
{
string pgum = Number_OF_Pages[x];
SHDocVw.WebBrowser m_browser = null;
m_browser = new SHDocVw.WebBrowser();
SHDocVw.ShellWindows shellWindows = new
SHDocVw.ShellWindowsClass();



//Find first availble browser window.
//Application can easily be modified to loop through and
capture all open windows.
string filename = "";



foreach (SHDocVw.WebBrowser ie in shellWindows)
{
filename =
Path.GetFileNameWithoutExtension(ie.FullName).ToLo wer();



if (filename.Equals("iexplore"))
{
m_browser = ie;
break;
}
}
//present user with a Close extra browser message
if (m_browser == null)
{
//MessageBox.Show("No Browser Open");
return;
}



//Assign Browser Document
//URL Location
// mshtml.IHTMLDocument2
myDoc = (mshtml.IHTMLDocument2)m_browser.Document;
string myLocalLink = myDoc.url;




object o = null;
//m_browser.FullScreen = true;
m_browser.Navigate(pgum, ref o, ref o, ref o, ref o);

int URLExtraHeight = 0;
int URLExtraLeft = 0;







//TrimHeight and TrimLeft trims off some captured IE graphics.
int trimHeight = 3;




//Use UrlExtra height to carry trimHeight.
URLExtraHeight = 0;
URLExtraLeft = 0;




//Set Browser Window Height
int heightsize = 3000;
int widthsize = 1500;



//Set Screen Height
int screenHeight = 3000;
int screenWidth = 3000;



//Get bitmap to hold screen fragment.
Bitmap bm = new Bitmap(3000, 3000,
System.Drawing.Imaging.PixelFormat.Format16bppRgb5 55);
//Create a target bitmap to draw into.
Bitmap bm2 = new Bitmap(widthsize + URLExtraLeft, heightsize +
URLExtraHeight - trimHeight,
System.Drawing.Imaging.PixelFormat.Format16bppRgb5 55);
Graphics g2 = Graphics.FromImage(bm2);



Graphics g = null;
IntPtr hdc;
Image screenfrag = null;
int brwTop = 0;
int brwLeft = 0;
int myPage = 0;
IntPtr myIntptr = (IntPtr)m_browser.HWND;
//Get inner browser window.
int hwndInt = myIntptr.ToInt32();
IntPtr hwnd = myIntptr;
hwnd = GetWindow(hwnd, GW_CHILD);
StringBuilder sbc = new StringBuilder(256);
//Get Browser "Document" Handle
while (hwndInt != 0)
{
hwndInt = hwnd.ToInt32();
GetClassName(hwndInt, sbc, 256);



if (sbc.ToString().IndexOf("Shell DocObject View", 0) > -1)
{
hwnd = FindWindowEx(hwnd, IntPtr.Zero, "Internet
Explorer_Server", IntPtr.Zero);
break;
}
hwnd = GetWindow(hwnd, GW_HWNDNEXT);



}



//Get Screen Height (for bottom up screen drawing)
while ((myPage * screenHeight) < heightsize)
{
myDoc.body.setAttribute("scrollTop", (screenHeight - 5) *
myPage, 0);
++myPage;
}
//Rollback the page count by one
--myPage;



int myPageWidth = 0;



while ((myPageWidth * screenWidth) < widthsize)
{
myDoc.body.setAttribute("scrollLeft", (screenWidth - 5) *
myPageWidth, 0);
brwLeft = (int)myDoc.body.getAttribute("scrollLeft", 0);
for (int I = myPage; I >= 0; --I)
{
//Shoot visible window
g = Graphics.FromImage(bm);
hdc = g.GetHdc();
myDoc.body.setAttribute("scrollTop", (screenHeight - 5)
* I, 0);
brwTop = (int)myDoc.body.getAttribute("scrollTop", 0);
PrintWindow(hwnd, hdc, 0);
g.ReleaseHdc(hdc);
g.Flush();
screenfrag = Image.FromHbitmap(bm.GetHbitmap());
g2.DrawImage(screenfrag, brwLeft + URLExtraLeft, brwTop
+ URLExtraHeight);
}
++myPageWidth;
}



ps I also get these error messages on a random basis



1.Retrieving the COM class factory for component with CLSID
{9BA05972-F6A8-11CF-A442-00A0C90A8F39} failed due to the following error:
8007000e. I get the error when I hit this line of code



shellWindows = new SHDocVw.ShellWindowsClass();



2. OUT OF MEMORY

this one is particulary confusing because when I watch my memory usage
it does not spike



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

 
Old 10-30-2007, 10:20 PM
  #2 (permalink)  
Old 10-31-2007, 09:11 AM
Jim Macklin
Newsgroup Contributor
 
Posts: n/a
Re: powerpoint saga

Why not make the original PPT file available for download?
Or use Adobe Acrobat and make it a PDF?


"bsg92618" <bsg92618@cox.net> wrote in message
news:Ob7j8S4GIHA.1324@TK2MSFTNGP06.phx.gbl...
|I work for a company that has very rigid security
guidelines.
|
| I have been given a project to convert a PowerPoint
presentation into a web
| site that looks exactly like the ppt. this part was easy.
|
| Then I have to provide a button that will convert the
whole web site into a
| PowerPoint presentation that the user can save on his
local machine. The
| website is database driven. The approach that I have taken
is to dynamically
| create the html for each page and save it to a file on the
server. Then I
| load the page into an IE window and capture to web page as
a jpg image. As I
| load the html, file into I Explorer the page changes to
allow me to create
| the next image file. My IT department in their infinite
wisdom sees this as
| a major security breach.
|
| I need a way turn my html files into an image file without
loading it into
| IE. Please I need some help. I have looked all over the
internet and the
| only thing I could find is someone having the same type of
issue but no one
| has replied to him. I will past my code below.
|
|
|
| my work email is alvis.floyd@ngc.com
|
| please someone help me
|
|
|
| This is a snippet from my constructor method
|
|
|
|
|
| using System;
|
| using mshtml;
|
| using System.Windows.Forms;
|
| using System.ComponentModel;
|
| using System.Drawing.Imaging;
|
| using System.Diagnostics;
|
| using System.Drawing;
|
| using System.Security.Principal;
|
| using System.Collections.Generic;
|
| using System.Configuration;
|
| using System.Data;
|
| using System.Data.SqlClient;
|
| using System.Text;
|
| using SHDocVw;
|
| using System.Runtime.InteropServices;
|
| using System.IO;
|
| using System.Text.RegularExpressions;
|
| using Microsoft.Office.Core;
|
| using Microsoft.Office.Interop;
|
| using Oracle.DataAccess.Client;
|
| using System.Collections.Specialized;
|
| using PowerPoint = Microsoft.Office.Interop.PowerPoint;
|
| //framework Dll for visweb project
|
| using NG_Support_FrameWork;
|
| using NG_GH_FrameWork;
|
|
|
| SHDocVw.WebBrowser m_browser = null;
| m_browser = new SHDocVw.WebBrowser();
| mshtml.IHTMLDocument2 myieDoc =
| (mshtml.IHTMLDocument2)m_browser.Document;
| CreateImage(Number_OF_Pages, myieDoc);
|
|
|
| The variable Number_OF_Pages is a string array that holds
the path to each
| html file. The html files has access to all the images and
style sheets
| needed to render the page the next method is where I
create and save the
| images
|
|
|
| private void CreateImage(string[] PageArray,
mshtml.IHTMLDocument2 myDoc)
| {
|
|
|
| try
| {
| for (int x = 0; x != Number_OF_Pages.Length; x++)
| {
| if (Number_OF_Pages[x] != null)
| {
| string pgum = Number_OF_Pages[x];
| SHDocVw.WebBrowser m_browser = null;
| m_browser = new SHDocVw.WebBrowser();
| SHDocVw.ShellWindows shellWindows = new
| SHDocVw.ShellWindowsClass();
|
|
|
| //Find first availble browser window.
| //Application can easily be modified to loop
through and
| capture all open windows.
| string filename = "";
|
|
|
| foreach (SHDocVw.WebBrowser ie in
shellWindows)
| {
| filename =
| Path.GetFileNameWithoutExtension(ie.FullName).ToLo wer();
|
|
|
| if (filename.Equals("iexplore"))
| {
| m_browser = ie;
| break;
| }
| }
| //present user with a Close extra browser
message
| if (m_browser == null)
| {
| //MessageBox.Show("No Browser Open");
| return;
| }
|
|
|
| //Assign Browser Document
| //URL Location
| // mshtml.IHTMLDocument2
| myDoc =
(mshtml.IHTMLDocument2)m_browser.Document;
| string myLocalLink = myDoc.url;
|
|
|
|
| object o = null;
| //m_browser.FullScreen = true;
| m_browser.Navigate(pgum, ref o, ref o, ref o,
ref o);
|
| int URLExtraHeight = 0;
| int URLExtraLeft = 0;
|
|
|
|
|
|
|
| //TrimHeight and TrimLeft trims off some
captured IE graphics.
| int trimHeight = 3;
|
|
|
|
| //Use UrlExtra height to carry trimHeight.
| URLExtraHeight = 0;
| URLExtraLeft = 0;
|
|
|
|
| //Set Browser Window Height
| int heightsize = 3000;
| int widthsize = 1500;
|
|
|
| //Set Screen Height
| int screenHeight = 3000;
| int screenWidth = 3000;
|
|
|
| //Get bitmap to hold screen fragment.
| Bitmap bm = new Bitmap(3000, 3000,
| System.Drawing.Imaging.PixelFormat.Format16bppRgb5 55);
| //Create a target bitmap to draw into.
| Bitmap bm2 = new Bitmap(widthsize +
URLExtraLeft, heightsize +
| URLExtraHeight - trimHeight,
| System.Drawing.Imaging.PixelFormat.Format16bppRgb5 55);
| Graphics g2 = Graphics.FromImage(bm2);
|
|
|
| Graphics g = null;
| IntPtr hdc;
| Image screenfrag = null;
| int brwTop = 0;
| int brwLeft = 0;
| int myPage = 0;
| IntPtr myIntptr = (IntPtr)m_browser.HWND;
| //Get inner browser window.
| int hwndInt = myIntptr.ToInt32();
| IntPtr hwnd = myIntptr;
| hwnd = GetWindow(hwnd, GW_CHILD);
| StringBuilder sbc = new StringBuilder(256);
| //Get Browser "Document" Handle
| while (hwndInt != 0)
| {
| hwndInt = hwnd.ToInt32();
| GetClassName(hwndInt, sbc, 256);
|
|
|
| if (sbc.ToString().IndexOf("Shell
DocObject View", 0) > -1)
| {
| hwnd = FindWindowEx(hwnd, IntPtr.Zero,
"Internet
| Explorer_Server", IntPtr.Zero);
| break;
| }
| hwnd = GetWindow(hwnd, GW_HWNDNEXT);
|
|
|
| }
|
|
|
| //Get Screen Height (for bottom up screen
drawing)
| while ((myPage * screenHeight) < heightsize)
| {
| myDoc.body.setAttribute("scrollTop",
(screenHeight - 5) *
| myPage, 0);
| ++myPage;
| }
| //Rollback the page count by one
| --myPage;
|
|
|
| int myPageWidth = 0;
|
|
|
| while ((myPageWidth * screenWidth) <
widthsize)
| {
| myDoc.body.setAttribute("scrollLeft",
(screenWidth - 5) *
| myPageWidth, 0);
| brwLeft =
(int)myDoc.body.getAttribute("scrollLeft", 0);
| for (int I = myPage; I >= 0; --I)
| {
| //Shoot visible window
| g = Graphics.FromImage(bm);
| hdc = g.GetHdc();
| myDoc.body.setAttribute("scrollTop",
(screenHeight - 5)
| * I, 0);
| brwTop =
(int)myDoc.body.getAttribute("scrollTop", 0);
| PrintWindow(hwnd, hdc, 0);
| g.ReleaseHdc(hdc);
| g.Flush();
| screenfrag =
Image.FromHbitmap(bm.GetHbitmap());
| g2.DrawImage(screenfrag, brwLeft +
URLExtraLeft, brwTop
| + URLExtraHeight);
| }
| ++myPageWidth;
| }
|
|
|
| ps I also get these error messages on a random basis
|
|
|
| 1.Retrieving the COM class factory for component with
CLSID
| {9BA05972-F6A8-11CF-A442-00A0C90A8F39} failed due to the
following error:
| 8007000e. I get the error when I hit this line of code
|
|
|
| shellWindows = new SHDocVw.ShellWindowsClass();
|
|
|
| 2. OUT OF MEMORY
|
| this one is particulary confusing because when I watch
my memory usage
| it does not spike
|
|
|


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Reply

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
X41 saga continues Howard Cross Windows XP Tablet PC Newsgroup 2 07-21-2007 10:40 AM
IE7 malware saga John Brainerd Internet Explorer 1 05-06-2007 09:35 AM
Is it saga of Adobe Reader and Vista to continue? J D Ross Windows Vista 0 02-25-2007 11:15 PM
The saga continues... X-Centric Tablet PC - Averatec 6 01-11-2005 10:24 PM
Trouble in Paradise...Saga continues Miska Tablet PC - Averatec 0 08-17-2004 01:15 AM


New To Technology Questions? Do You Need Help with Your Computer or Device? Do You Need Help with this site?

All times are GMT -8. The time now is 06:45 PM.


2003 - 2009 All Rights Reserved. Technology Questions

Search Engine Friendly URLs by vBSEO 3.3.0