[^_]+)_" . "(?[^_]+)_" . "(?\-?[0-9]{1,3}(\.[0-9]{1,4})?)_" . "(?[ct])\.jpg/i"; if (preg_match ($NamePattern, $Image, $Matches)) { $Name = $Matches ["name"]; } else { rename ($Image, $Upload . "\\Error\\" . $Image); exit (-2); } /* Check whether the corresponding document is already present */ if (! file_exists ($Name . ".pcl")) { rename ($Image, $Upload . "\\NoDocument\\" . $Image); exit (-6); } if ($Matches ["type"] == "c") { $Macro = $RightMacro; } else { $Macro = $LeftMacro; } /* Filter and convert the just received image, result is a pcl-macro */ $cmdSign = "\"" . $Script . "\\p2fSign.exe\"" . " -i" . $Image . " -g" . $Matches ["color"] . /* color filter treshold */ " -m" . $Macro . /* macro identifier */ " -c294" . /* barcode size is 14 pixel x 21 modules */ " -r" . $Matches ["angle"] . " -k" . $Key; system ($cmdSign, $Result); /* image filtering and conversion to pcl macro */ if ($Result != 0) { /* p2fSign.exe failed, save file for analysis */ rename ($Image, $Upload . "\\Error\\" . $Image); exit (-3); /* image can't be converted */ } unlink ($Image); /* image file no longer needed */ /* Check whether the corresponding signature was already received */ if ($Matches ["type"] == "c") { /* right (customer) signature received */ if (! file_exists ($Name . "_" . $LeftMacro . ".pcl")) { exit (0); } /* left macro still missing */ } else { /* left (technician) signature received */ if (! file_exists ($Name . "_" . $RightMacro . ".pcl")) { exit (0); } /* right macro still missing */ } /* Combine the document pcl-file with the two signature macros */ $Combine = fopen("Combine.txt", "w"); fwrite ($Combine, "UEL\n" . "PJL = ENTER LANGUAGE = PCL\n" . "PAS = " . $Name . "_" . $LeftMacro . ".pcl\n" . "PAS = " . $Name . "_" . $RightMacro . ".pcl\n" . "INC = " . $Name . ".pcl\n" . "UEL\n"); fclose ($Combine); $cmdCombine = "\"" . $Script . "\\p2fCombine.exe\"" . " -fCombine.txt " . " -o" . $Name . "_tmp.pcl" . " -k" . $Key; system ($cmdCombine, $Result); if ($Result != 0) { exit (-4); } /* Convert the pcl-file with the signatures to a pdf-file */ $cmdGhostPCL = "\"" . $Script . "\\gpcl6win32.exe\"" . " -dNOPAUSE" . " -sDEVICE=pdfwrite" . " -dPDFA=1" . " \"-sOutputFile=" . $Name . ".pdf\"" . " \"" . $Name . "_tmp.pcl\""; system ($cmdGhostPCL, $Result); if ($Result != 0) { exit (-5); } /* Move just generated pdf-file to it's target directory */ rename ($Name . ".pdf", $Target . "\\" . $Name . ".pdf"); unlink ($Name . "_" . $RightMacro . ".pcl"); unlink ($Name . "_" . $LeftMacro . ".pcl"); unlink ($Name . "_tmp.pcl"); unlink ($Name . ".pcl"); exit (0); ?>