1

Setting header and footer works for print using the following command where I add header and footer as parameters.

ExecWB(OLECMDID_PRINT, OLECMDEXECOPT_DODEFAULT, &parameters, NULL);

But I don't know how to do it for print preview and I don't seem to find relevant document about that. It seems header and footer can be set manually via OLECMDID_PAGESETUP, but first I don't want to bring up the UI during runtime (and OLECMDEXECOPT_DONTPROMPTUSER doesn't work somehow), and second I don't know how to set the parameters when calling OLECMDID_PAGESETUP.

Someone also suggests to set print template (https://groups.google.com/forum/#!topic/microsoft.public.windows.inetexplorer.ie5.programming.components.webbrowser_ctl/54f5-aQsk6A) without any detail and the reference link is broken.

user180574
  • 5,681
  • 13
  • 53
  • 94
  • Have you seen [Print Preview Architecture](https://learn.microsoft.com/en-us/cpp/mfc/print-preview-architecture?view=vs-2019)? – Strive Sun Feb 27 '20 at 02:20
  • @StriveSun-MSFT I don’t think the MFC print mechanism is related to html browser automation. – Andrew Truckle Feb 28 '20 at 07:56
  • It seems my question is closest to this one: https://stackoverflow.com/questions/19098571/webbrowser-print-settings, however most of the links of reference are no longer available. :( – user180574 Feb 28 '20 at 19:09
  • According to this one https://stackoverflow.com/questions/18926793/add-support-to-print-preview-html-in-a-dialog-based-mfc-app/18943374#18943374, it might be possible to set up certain callback with OLECMDID_PRINTPREVIEW2? I would be very appreciated if someone can share his experience on that. – user180574 Feb 28 '20 at 19:52

0 Answers0