PHP Print to Network Printer



PHP Snippet 1:

$ftp = ftp_connect('192.168.0.10');
if(ftp_login($ftp,'username','password')){
    if(ftp_put($ftp,'filetype=PDF','yourfile.pdf',FTP_BINARY)){
        echo 'success';
    }
}

PHP Snippet 2:

ftp> put file1 filetype=postscript,tray=tray1,copies=3,resolution=600

PHP Snippet 3:

STOR filetype=postscript,tray=tray1,copies=3,resolution=600

PHP Snippet 4:

ftp_put($ftp,'filetype=postscript,tray=tray1,copies=3,resolution=600','file1',FTP_BINARY);

PHP Snippet 5:

$ftp = ftp_connect('192.168.0.10');
if(ftp_login($ftp,'username','password')){
    if(ftp_put($ftp,'filetype=postscript,tray=tray1,copies=3,resolution=600','file1',FTP_BINARY)){
        echo 'success';
    }
}

PHP Snippet 6:

//This is the final output from fpdf
$pdf -> Output('tmp/lbl.pdf', 'F');

if (($conp = fsockopen("10.0.0.100", 9100, $errno, $errstr)) === false)
    echo 'Connection Failed' . $errno . $errstr;
else {
    fputs($conp, file_get_contents('tmp/lbl.pdf'));
    fclose($conp);
}

PHP Snippet 7:

    shell_exec("\"c:\\program files (x86)\\gs\\gs9.56.1\\bin\\gswin32c\" -sDEVICE=tiffg4 -dNOPAUSE -dQUIET -dBATCH -sOutputFile=tmp\\lbl.tiff tmp\\lbl.pdf");
    fputs($conp, file_get_contents('tmp/lbl.tiff'));

PHP Snippet 8:

shell_exec("\"c:\\program files\\gs\\gs9.56.1\\bin\\gswin64c\" -q -dNOPAUSE -sDEVICE=tiffg4 -sOutputFile=tmp\\lbl.tiff tmp\\lbl.pdf -c quit");

PHP Snippet 9:

$command = escapeshellcmd('PDFtoPrinter YOURFILE.PDF "\\\YOURSERVERNAME\YOURPRINTERNAME"');
$output = shell_exec($command);
echo $output;