ExecWB(OLECMDID_SAVEAS, OLECMDEXECOPT_DONTPROMPTUSER, &pvaIn, &pvaOut);
It prompt user for file name. I don't want to prompt user because I
know what file to save. Microsoft said there is no way to save to a
file without prompt user.
Is there any way I can get the binary content of the PDF file so that I
can save to file my self?
Of course I can always download the file again from Internet and save.
But this is a performance waste. The browser already download the PDF
file and I don't want to download it again.
Sample codes will be greatly appreciated.
http://www.delphidabbler.com/articles.php?article=14
Although the sample code is Delphi, it may help.
Probably you'll have to use a type library and use IPersistStreamInit to
save the full HTML file.
Cristian Amarie
<ningju...@lexisnexis.com> wrote in message
news:1112286591.0...@l41g2000cwc.googlegroups.com...
HRESULT hr;
IDispatch* pHtmlDoc = NULL;
IPersistStreamInit* pPersistStreamInit = NULL;
hr = m_pIE->get_Document( &pHtmlDoc );
if ( !SUCCEEDED(hr) || pHtmlDoc == NULL ) {
throw EpactException("Failed to get Document");
}
hr = pHtmlDoc->QueryInterface( IID_IPersistStreamInit,
(void**)&pPersistStreamInit );
if ( !SUCCEEDED(hr) || pPersistStreamInit == NULL ) {
throw EpactException("Failed to get IID_IPersistStreamInit");
}
HGLOBAL hGlobal = GlobalAlloc( GPTR, 2000000 );
if (!hGlobal) {
throw EpactException("GlobalAlloc() failed");
}
LPSTREAM pStream = NULL;
hr = CreateStreamOnHGlobal( hGlobal, FALSE, &pStream );
if ( !SUCCEEDED(hr) || pStream == NULL) {
throw EpactException("Failed to create stream");
}
hr = pPersistStreamInit->Save(pStream, TRUE);
The last line (Save())return errorcode 0x80170057 if the content is
PDF.