Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Printing HTML progmatically

Printing HTML progmatically

Scheduled Pinned Locked Moved C / C++ / MFC
htmlhelpquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    Darroll Walsh
    wrote on last edited by
    #1

    I wrote an app that creates a web page. Now they want to print it out. The problem comes that the settings for everyones printing is set differently, ie margins, header/footer, and if print background is selected. Is there a way to send IE the paramiters I want to print for this page? Thanks in advance. Darroll

    G 1 Reply Last reply
    0
    • D Darroll Walsh

      I wrote an app that creates a web page. Now they want to print it out. The problem comes that the settings for everyones printing is set differently, ie margins, header/footer, and if print background is selected. Is there a way to send IE the paramiters I want to print for this page? Thanks in advance. Darroll

      G Offline
      G Offline
      Gary Wheeler
      wrote on last edited by
      #2

      I've got a control derived from the browser. My printing code looks like this -

      HRESULT hr;
      
      BSTR        header\_BSTR = ::SysAllocString(L"&w&b&b&p");
      VARIANT     header\_variant;
      
      VariantInit(&header\_variant);
      V\_VT(&header\_variant)   = VT\_BSTR;
      V\_BSTR(&header\_variant) = header\_BSTR;
      
      BSTR        footer\_BSTR = ::SysAllocString(L"&d &t");
      VARIANT     footer\_variant;
      
      VariantInit(&footer\_variant);
      V\_VT(&footer\_variant)   = VT\_BSTR;
      V\_BSTR(&footer\_variant) = footer\_BSTR;
      
      long index;
      
      SAFEARRAYBOUND  parameter\_array\_bound\[1\];
      SAFEARRAY       \*parameter\_array = NULL;
      
      parameter\_array\_bound\[0\].cElements = 2;
      parameter\_array\_bound\[0\].lLbound   = 0;
      
      parameter\_array = SafeArrayCreate(VT\_VARIANT,1,parameter\_array\_bound);
      
      index = 0;
      hr = SafeArrayPutElement(parameter\_array,&index,&header\_variant);
      
      index = 1;
      hr = SafeArrayPutElement(parameter\_array,&index,&footer\_variant);
      
      VARIANT parameter;
      VariantInit(&parameter);
      V\_VT(&parameter)    = VT\_ARRAY | VT\_BYREF;
      V\_ARRAY(&parameter) = parameter\_array;
      
      hr = \_Browser->ExecWB(OLECMDID\_PRINT,OLECMDEXECOPT\_DONTPROMPTUSER,&parameter,NULL);
      
      if (!SUCCEEDED(hr)) {
          VariantClear(&header\_variant);
          VariantClear(&footer\_variant);
          if (parameter\_array != NULL) {
              SafeArrayDestroy(parameter\_array);
          }
      }
      

      This code sets the header and footer for the page and then prints it. The _Browser value points to the IWebBrowser2 interface for the control. If I remember correctly, I found this stuff in an example in the MSDN.


      Software Zen: delete this;

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups