Solved

Save file without displaying the save dialog/prompt

Posted on 2008-10-29
2
491 Views
Last Modified: 2013-11-26
Hello,
I am printing a file in pdf format using printdlg function but i want to save the file at the specified location without dispalying the save dialog / prompt. In the doc info structure it is taking only the name not the path even though i am specifying the path.It is a win32 appliccation.
di.lpszDocName = "C:\\Printing.pdf";
Thanks.
0
Comment
Question by:Sohela
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 500 total points
ID: 22842365
As the docs state:

PD_PRINTTOFILE

If this flag is set, the Print to File check box is selected.
If this flag is set when the PrintDlg function returns, the offset indicated by the wOutputOffset member of the DEVNAMES structure contains the string "FILE:". When you call theStartDoc function to start the printing operation, specify this "FILE:" string in the lpszOutput member of the DOCINFO structure. Specifying this string causes the print subsystem to query the user for the name of the output file.

So, that should be

di.lpszOutput = "C:\\Printing.pdf";

instead.
 
0
 

Author Comment

by:Sohela
ID: 22847534
Hi,
This is my printdlg structure
         PRINTDLG pd = {0};                        //  Reset on declare
        pd.lStructSize = sizeof (pd);
       pd.Flags = PD_RETURNDEFAULT | PD_PRINTTOFILE | PD_RETURNDC;

       DOCINFO di = {0};
       di.cbSize = sizeof (di);
       di.lpszDocName = "C:\\Printing.pdf";
       StartDoc (pd.hDC, &di);
        StartPage (pd.hDC);

As you mentioned i used it but it is giving another prompt/dialog and if i give path name or file it is not getting saved.I dont want any prompt/dialog it should directly print at the required path is there any function for that. I attaching the file like when the prompt is displayed.
output.JPG
0

Featured Post

Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question