Override PaymentModule::validateOrder
<?php
public function validateOrder($function_arguments_here) {
$ret = parent::validateOrder($function_arguments_here);
//call AdminPdfController as if you clicked the PDF icon
//you may need to copy-paste here the code and pass a different parameter to $pdf->render()
//to prevent downloading the PDF. Cant test now
if ($this->currentOrder) {
$_GET['id_order'] = $this->currentOrder->id;
AdminPdfController::processGenerateInvoicePdf();
}
return $ret;
}
/tools/tcpdf/tcpdf.php:
<?php
protected function sendOutputData($data, $length) {
if (!isset($_SERVER['HTTP_ACCEPT_ENCODING']) OR empty($_SERVER['HTTP_ACCEPT_ENCODING'])) {
// the content length may vary if the server is using compression
header('Content-Length: '.$length);
}
//save to disk if it is a PDF about an order
$id_order = Tools::getValue('id_order');
if ($id_order)
file_put_contents(_PS_ROOT_DIR_."your/path/to/pdfs/order-{$id_order}.pdf", $data);
echo $data;
}