I’m printing text using essentially the “Microsoft Print to PDF” printer. This works fine, there are no issues with the generated PDF file whatsoever.
However I’d like to get the full path of the PDF file the user has chosen and I have no idea how.
The user clicks on OK and the file chooser is shown:
Ths user chooses a PDF filename/path and the PDF file is created correctly.
Now the only problem I have is I have no idea where the PDF is created as the user can choose any folder he wants.
Questions:
- Is it possible to get the full path of the file the user has chosen/created?
- Nice to have: is it possible to set the initial folder that is shown to the user? By default it is the user’s “Documents” folder.
This are the essential parts of the code.
...
CPrintDialog printDlg(FALSE, PD_ALLPAGES | PD_USEDEVMODECOPIES | PD_NOPAGENUMS | PD_NOSELECTION);
// ask the user to select a printer
if (printDlg.DoModal() == IDCANCEL)
return FALSE;
CDC m_dc;
// Attach a printer DC
if (!m_dc.Attach(printDlg.GetPrinterDC()))
return FALSE;
...
m_dc.StartPage();
...
m_pDC->DrawText(...
...
m_dc.EndDoc();