I use MFC and understand how to skip configuration menu (set pInfo->m_bDirect
to false). But I want to set the folder and filename programmatically, without a special dialog. If it is impossible, can you advise me about a PDF printer with this functionality (may be changing configuration file for this goal)?

- 49,934
- 160
- 51
- 83

- 99
- 1
- 8
-
what are you printing? It might be easier to just generate a PDF directly rather than going through a PDF printer? – jwezorek Sep 13 '21 at 21:33
-
It is so hard, because the whole application is done – Dmitry Bogomaz Sep 14 '21 at 05:51
-
It depends if it is MFC doc/view or some other style, example https://stackoverflow.com/a/53552092/4603670 – Barmak Shemirani Sep 14 '21 at 12:11
-
No, it doesn't help. It depends of microsoft pdf printer without normal settings – Dmitry Bogomaz Sep 16 '21 at 06:30
1 Answers
One question at a time, has limitations so here goes.
Q.) I want set folder and filename programmatically without special dialog.
A.) If you look at the output port of a recent windows installation of Microsoft Print To PDF
You may note it is set to PORTPROMPT: and that is exactly what causes the request for a filename.
You might note lower down, I have several ports set to a filename, and the fourth one down is called "My Print to PDF"
So very last century methodology; when I print with a *duplicate printer but give it a different name I can use different page ratios etc., without altering the built in standard one. The output for a file will naturally be built:-
Exactly in one repeatable location, that I can file monitor and rename it, based on the source calling the print sequence, such that if it is my current default printer I can right click files to print to a known \folder\file.pdf
Your next question will be how to change the target location and that is done behind the scenes when using apps such as WordPad Command Line printing where we can specify the port name on the command line.
Some users will use a Port Redirection Monitor (Do NOT use RedMon as unsupported in Win 10, consider Multi Port Redirector)
Other Users will interact with the duplicate named printer directly via PrintUI where you can alter output port, rotation or paper format etc.
And for your usage you could try one of these for hints, with your newly defined PDF printer:-
Microsoft Web Browser ActiveX control - printing to a specified (non default) printer
Programmatically set filename and path in Microsoft Print to PDF printer

- 8,045
- 3
- 14
- 36
-
It helps me. https://stackoverflow.com/questions/863991/using-c-to-edit-the-registry - changing port with c++ – Dmitry Bogomaz Sep 21 '21 at 11:43