Opened 12 years ago

Closed 12 years ago

#4864 closed enhancement (fixed)

pdfdataset: On Windows calling system displays a dosbox

Reported by: damiandixon Owned by: warmerdam
Priority: normal Milestone: 1.10.0
Component: GDAL_Raster Version: 1.9.1
Severity: normal Keywords: pdf poppler windows
Cc:

Description

pdfdataset: On Windows calling system displays a dosbox. Ideally the dosbox should be suppressed.

This can be achieved if CreateProcess is used instead of system.

The following code is an indication of how this could be done:

BOOL nRet = FALSE;

CPLString osCmd = CPLSPrintf("\"%s\" -r %f -f %d -l %d \"%s\" \"%s\"",

lpFilename, poGDS->dfDPI, poGDS->iPage, poGDS->iPage, poGDS->osFilename.c_str(), osTmpFilenamePrefix.c_str());

if (poGDS->osUserPwd.size() != 0) {

osCmd += " -upw \""; osCmd += poGDS->osUserPwd; osCmd += "\"";

}

CPLDebug("PDF", "Running '%s'", osCmd.c_str());

PROCESS_INFORMATION processInfo; STARTUPINFO startupInfo = {}; ZeroMemory( &processInfo, sizeof(PROCESS_INFORMATION) ); ZeroMemory( &startupInfo, sizeof(STARTUPINFO) ); startupInfo.cb = sizeof(STARTUPINFO);

char *ptr = new char[osCmd.size() + 1]; memcpy(ptr, osCmd.c_str(), osCmd.size()); ptr[osCmd.size()] = '\0';

if (CreateProcess(lpFilename,

ptr, NULL, NULL, FALSE, CREATE_NO_WINDOW|NORMAL_PRIORITY_CLASS , NULL, NULL, &startupInfo, &processInfo))

{

DWORD err = GetLastError(); CPLDebug("PDF", "Unable to start process: code = %d", err);

} else {

WaitForSingleObject( processInfo.hProcess, INFINITE );

DWORD exitCode;

Get the exit code. nRet = GetExitCodeProcess(processInfo.hProcess, &exitCode);

CloseHandle(processInfo.hProcess); CloseHandle(processInfo.hThread);

}

delete [] ptr;

lpFilename is meant to be a full path to the exe.

Change History (1)

comment:1 by Even Rouault, 12 years ago

Component: defaultGDAL_Raster
Keywords: pdf poppler windows added
Milestone: 2.0.0
Resolution: fixed
Status: newclosed

trunk r25133 "PDF: avoid launching the 'pdftoppm' process in a visible console on Windows (#4864)"

I'd appreciate if you could test if this works for you. I've tested the new helper function in a unit fashion, but not in the context of PDF/Podofo on Windows.

Note: See TracTickets for help on using tickets.