Question : ASP.NET client side printing.

I have a situation where I may have one or many images I will need the users to print on the client side of an asp.net program. What's the best way to achieve this?

The images will need to go to a specific printer, and the images will need to be sized to fit the media exactly, also. The image I am producing should be the exact right size though.

Thanks,
Matthew

Answer : ASP.NET client side printing.

I wanted to do the same thing.  I found the following code a while back, it still works.  It assumes your browser object is m_wndBrowser.  Source:http://www.fruitfruit.com/vc/ie/iehtml.cpp

HTH
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
HRESULT hr = S_OK;
LPDISPATCH pDispatch = m_wndBrowser.get_Document();
if( pDispatch != NULL )
{
	IHTMLDocument2* pHtmlDoc=NULL;
	hr = pDispatch->QueryInterface( __uuidof( IHTMLDocument2 ),(void**)&pHtmlDoc );
	IHTMLWindow2*  pWindow;
	if(pHtmlDoc!=NULL)
	{
		hr = pHtmlDoc->get_parentWindow(&pWindow);
		pHtmlDoc->Release();
	}

	ASSERT( SUCCEEDED( hr ) );
	long docheight=0;
	IHTMLElement* pe=NULL;
	pHtmlDoc->get_body(&pe);
	IHTMLTextContainer* pe2=NULL;
	if(pe!=NULL)
	{
		pe->QueryInterface(&pe2);
		pe->Release();
	}
	if(pe2!=NULL)
	{
		pe2->get_scrollHeight(&docheight);
		pe2->Release();
	}
	if(pWindow!=NULL&&docheight>0)
	{
		pWindow->scrollTo(0,docheight);
		pWindow->Release();
	}
	pDispatch->Release();
}
Random Solutions  
 
programming4us programming4us