Questions and discussion about developing processes and programming in PHP, JavaScript, web services & REST API.
Forum rules: Please search to see if a question has already asked before creating a new topic. Please don't post the same question in multiple forums.
By azalea45
#812922
Dear All,
We have more than ten processes and they all write to the default locations.
The situation that we have is that we either need to print one document in one processes directly to a printer on document creation
OR
save the output document to a specific folder on the network.

We do not want to change the default location for printing as it would affect all the other processes and output documents in this process.

Any ideas?

Thanks
Aza
#812933
You can try using the printer extension in PHP to send the PDF Output Document directly to a printer. See:
https://stackoverflow.com/questions/233 ... to-printer
http://windows.php.net/downloads/pecl/s ... 0.1.0-dev/

If you have Acrobat Reader installed on your PM Server, you can also send a system command in a trigger to print:
exec("AcroRd32.exe /t <filename.pdf> <printername> <drivername> <portname>");
on a Linux server with CUPS, you can use:
exec("lp -d <printer-name> <filename.pdf>");
To see the list of printer names, use the command lpstat -a or use this address in a web browser:
http://<ip-or-domain>:631/printers

If you want to copy an Output Document file to a specified directory, you can use this trigger code:
Code: Select all
//set to the Unique ID of the Output Document:
$outDocId = '233815488585c62af61e2a6077136729';

//if needing to generate the output document file,  because no Output Document step in task:
PMFGenerateOutputDocument($outDocId); 

//retrieve info from the database about the generated output document file
$caseId = @@APPLICATION;
$query = "SELECT APP_DOC_UID, DOC_VERSION FROM APP_DOCUMENT
   WHERE APP_UID='$caseId' AND DOC_UID='$outDocId' AND
   APP_DOC_STATUS='ACTIVE' ORDER BY APP_DOC_CREATE_DATE DESC";
$result = executeQuery($query);
if (!is_array($result) or count($result) == 0) {
   throw new Exception("Unable to find generated Output Document in database.");
}
//get the filename of the uploaded document:
$d = new AppDocument();
$aFile = $d->Load($result[1]['APP_DOC_UID'], $result[1]['DOC_VERSION']);
$originalFilename = $aFile['APP_DOC_FILENAME'].'_'.$aFile['DOC_VERSION'];
$filename = $result[1]['APP_DOC_UID'].'_'.$result[1]['DOC_VERSION'];

$g = new G();
$path = PATH_DOCUMENT. $g->getPathFromUID($caseId) .PATH_SEP. "outdocs" .PATH_SEP. $filename .'.pdf';
//change "/my/path/" for your server:
$newPath = '/my/path/' . $originalFilename . '.pdf';
copy($path, $newPath);
This code will automatically generate the output document file or you can remove the PMFGenerateOutputDocument() function call and set this trigger to fire after an Output Document step.
What's SAP FICO?

Embarking on a dissertation can be one of the most[…]

Hello. For rental housing, there are software solu[…]

Experience heightened pleasure with Cenforce 100 M[…]

Get an instant solution to move emails to MBOX for[…]