- # Use a subshell (brackets) to aggregate stderr from both pipeline commands
- # before redirecting it to the overall stdout. This works in both Linux and Windows XP.
- $cmd = '(' . wfEscapeShellArg( $wgDjvuRenderer ) . " -format=ppm -page={$page} -size={$width}x{$height} " .
- wfEscapeShellArg( $srcPath );
- if ( $wgDjvuPostProcessor ) {
- $cmd .= " | {$wgDjvuPostProcessor}";
+ if( $params['djvutxt'] && $wgDjvuTxt ) {
+ # Extract djvu text
+ $cmd = wfEscapeShellArg( $wgDjvuTxt ) . " --page={$page} " . wfEscapeShellArg( $srcPath ) ;
+ wfProfileIn( 'djvutxt' );
+ wfDebug( __METHOD__.": $cmd\n" );
+ $err = wfShellExec( $cmd, $retval );
+ wfProfileOut( 'djvutxt' );
+ # Escape html characters
+ $txt = htmlspecialchars( $err );
+ # Write result to file
+ if($retval == 0) {
+ $f = fopen($dstPath, 'w');
+ fwrite($f, $txt);
+ fclose($f);
+ }
+ }
+ else {
+ # Use a subshell (brackets) to aggregate stderr from both pipeline commands
+ # before redirecting it to the overall stdout. This works in both Linux and Windows XP.
+ $cmd = '(' . wfEscapeShellArg( $wgDjvuRenderer ) . " -format=ppm -page={$page} -size={$width}x{$height} " .
+ wfEscapeShellArg( $srcPath );
+ if ( $wgDjvuPostProcessor ) {
+ $cmd .= " | {$wgDjvuPostProcessor}";
+ }
+ $cmd .= ' > ' . wfEscapeShellArg($dstPath) . ') 2>&1';
+ wfProfileIn( 'ddjvu' );
+ wfDebug( __METHOD__.": $cmd\n" );
+ $err = wfShellExec( $cmd, $retval );
+ wfProfileOut( 'ddjvu' );