web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :

Open and close PDF reader from code

PA-22040759-0 Profile Picture PA-22040759-0 6,194
Here is an example of how you can open Adobe PDF Reader (or another PDF reader) with a particular PDF document, and close the reader again.
static void pager_FindWindow(Args _args)
{
Filename pdfFileName = 'MyDocumentFile.pdf';
FilePath pdfFilePath = @'C:\XYZ\';
str adobeExe;

System.Diagnostics.Process process;
System.Diagnostics.ProcessStartInfo processStartInfo;

// Let Windows figure out the standard program and location for the PDF reader
adobeExe = WinAPI::findExecutable(pdfFilePath + pdfFileName);

// Start the reader process
new InteropPermission(InteropKind::ClrInterop).assert();

process = new System.Diagnostics.Process();

processStartInfo = new System.Diagnostics.ProcessStartInfo();
processStartInfo.set_FileName(adobeExe);
processStartInfo.set_Arguments(pdfFilePath + pdfFileName);

process.set_StartInfo(processStartInfo);

process.Start();


// Wait 5 secs. before closing the window
sleep (5000);

// Close the window
process.Kill();
}

Comments

*This post is locked for comments