Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am trying to convert an html file to image. When it is run in a windows 2008 server the image is created if it is run as administrator. I want to run the program as System. But there is no image created when the program run as system.
the code is below

C++
HBITMAP m_hBmp;
CImage img;
width = bodyWidth;
height = rootHeight > bodyHeight ? rootHeight : bodyHeight;

if(width > 2000)
    width = 2000;
if(height > 2000)
    height = 2000;

MoveWindow(0,0,width,height,TRUE);
::MoveWindow(m_hwndWebBrowser,0,0,width,height,TRUE);

if(FAILED(m_pBrowser->QueryInterface(IID_IViewObject2,(void**)&pViewObject)))
    return FALSE;

CDC *cdcMain = GetDC();
HDC hdcMain = *cdcMain;
HDC hdcMem = CreateCompatibleDC(hdcMain);
m_hBmp = CreateCompatibleBitmap(hdcMain,width,height);

SelectObject(hdcMem,m_hBmp);
RECTL rcBounds = { 0, 0, width, height };
hr = pViewObject->Draw(DVASPECT_CONTENT, -1, NULL, NULL,hdcMain,hdcMem, &rcBounds, NULL, NULL, 0);

img.Attach(m_hBmp);

if(!hr ==img.Save(szDestFilename))
    return FALSE;




How can I create image when the program run as system.
Posted
Updated 5-Jul-11 7:05am
v2

While probably non-trivial, you could try using Gecko[^], Gecko_(layout_engine)[^] - it's possible to set it up so that it renders directly to a bitmap, or pdf for that matter.

WebKit[^] is also an option

It's been done by others:Skyfire[^]

Cairo[^] is used by both engines to render output.

Best regards
Espen Harlinn
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 7-Jul-11 13:40pm    
Interesting idea to use engines themselves, I did not even think about it. I think it's feasible, too.
My 5.
--SA
Espen Harlinn 7-Jul-11 13:49pm    
Thanks Sergey, opera also had - I'm not sure it's in use anymore - something like this that provided "advanced" features for mobile devices.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900