locked
CHtmlView "Microsoft Print to PDF" "Programmatically set filename and path for the file to print" RRS feed

  • Question

  • I currently display HTML report documents in a CHtmlView.

    In Windows 10 OS, currently I'm printring directly to the "Microsoft Print to PDF" using the following code :
    //sets the printer name of the default printer for the current user on the local computer.
    SetDefaultPrinter(_T("Microsoft Print to PDF"));
    //Print command - without prompting the user.
    m_pWndHtml->ExecWB(OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER, &parameter, NULL);
    Note that m_pWndHtml is CHtmlView object. 

    However this will prompt user for location+filename. 
    I would like to programmatically control this from C++ to not prompt for the PDF filename but save to a specific filename in some folder that I provide.
    Would it be possible to accomplish that??
    Unless it would be possible to specify the name of the file before calling m_pWndHtml->ExecWB?

    I would like for my C++ code to call an API(or a printer) that would let me automatically generate/create PDFs from my HTML documents to a specific file and location (which I will pass as a parameter to the API method) without any prompt/dialogs to the user.

    This question is a Follow-up on the following one:
    https://social.msdn.microsoft.com/Forums/en-US/70705f9d-6a1a-41f0-aeb9-aeee2e13983e/microsoft-api-that-would-let-me-automatically-generateprint-my-pdfs?forum=vcgeneral

    Thank You.

    MichelCunha

    Monday, February 15, 2016 4:04 PM

Answers

All replies