0

I have a PDF that is protected.

If you open this PDF, open the print dialog and choose "Print to PDF" but if in that moment you save in your PC it will be saved as unprotected.

I want to do that in C#. I have this code:

Process proc = new Process();
proc.StartInfo.FileName = @"C:\Program Files (x86)\Adobe\Acrobat Reader DC\Reader\AcroRd32.exe";
proc.StartInfo.Arguments = String.Format(@"/o /p /h C:\Users\itsvan.moreno\Desktop\1.pdf", @"C:\Users\itsvan.moreno\Desktop\");
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.CreateNoWindow = false;
proc.EnableRaisingEvents = true;
proc.Start();
if (proc.HasExited == false)
{
    proc.WaitForExit(10000);
}
proc.Close();

All the process is correct but a popup window is displayed to put the name at the new pdf file.

Save Print Output dialog

How can I save as without a popup?

Daniel A. White
  • 187,200
  • 47
  • 362
  • 445
  • 1
    Please don't delete and duplicate [your question](https://stackoverflow.com/questions/57151816/how-to-print-a-pdf-with-an-already-existing-pdf?noredirect=1#comment100819237_57151816). Your other question was closed because it was unclear. Do you think duplicating the question without adding new information is going to have a different result? –  Jul 23 '19 at 19:17
  • Instead, **edit your question** to provide additional information in response to the feedback in the comments, and the question will be reopened. –  Jul 23 '19 at 19:20
  • it isnt the same question amy and i know that my previus question was a dirty try. thanks Gabriel Luci – Itsvan Moreno Jul 23 '19 at 19:28
  • It's the exact same. The only thing you changed was the addition of a screenshot. In the future, edit your existing question. –  Jul 23 '19 at 19:39

1 Answers1

0

Your code doesn't really unprotect it "in C#". You're unprotecting it with Acrobat Reader.

Your code opens Acrobat Reader and tells it (with the /o /p /h paramters) to open a file and go directly to the print dialog. If you can't get further than that, it is a limitation of Acrobat Reader.

You might be able to experiment with the /t option. See here. But I suspect it just doesn't give you a way to feed a filename to the Print to PDF driver. If not, then you just can't do it this way.

You can look into a PDF library for .NET so that you are, actually, modifying the PDF in .NET, but the good ones aren't free. Aspose.PDF is one, for example.

Gabriel Luci
  • 38,328
  • 4
  • 55
  • 84