سؤال

The below lines of code are used to open a PDF file at a particular page in C#. the code works absolutely fine for all the adobe version other than the latest, which is 11.

System.Diagnostics.Process myProcess = new System.Diagnostics.Process();
myProcess.StartInfo.FileName = "AcroRd32.exe";
myProcess.StartInfo.Arguments = "/A \"page=2=OpenActions\" C:\\Jack and Jill.pdf";
myProcess.Start();

Can some one please help me out and let know what is special with adobe reader 11. Any help will be greatly appreciated.

The error is "There was an error opening this document. The file cannot be found." (THE FILE DOES EXIST)

P.S: I have uninstalled adobe 11 and installed adobe reader 10 and the code works absolutely fine then.

also the arguments when given from command line when Acrobat Reader 11 is installed works fine and opens PDF.

هل كانت مفيدة؟

المحلول

Make sure u dont have spaces in the name of the file. it works if it has spaces in all other adobe readers but adobe reader 11 dosent support that.

Hope this helps

نصائح أخرى

According to the Parameters for Opening PDF Files, your arguments line should look like this:

myProcess.StartInfo.Arguments = "/A \"page=2\" C:\\example.pdf";

Make sure that file C:\example.pdf exist. This error occurs when there is no file.

string pdfPath = @"C:\example.pdf";

if (System.IO.File.Exists(pdfPath))
{
     System.Diagnostics.Process myProcess = new System.Diagnostics.Process();
     myProcess.StartInfo.FileName = "AcroRd32.exe";
     myProcess.StartInfo.Arguments = string.Format("/A \"page=2=OpenActions\" \"{0}\"", pdfPath);
     myProcess.Start();
}

Open Parameters for Reader 11 have changed or been removed. Use Reader 10. I have asked Adobe for information on Open parameters for reader 11 but had no response.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top