mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Support downloading PDF through the API
This commit is contained in:
parent
1760d0e0e4
commit
e08e8c1962
@ -358,4 +358,17 @@ class InvoiceApiController extends BaseAPIController
|
|||||||
return $this->itemResponse($invoice);
|
return $this->itemResponse($invoice);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function download(InvoiceRequest $request)
|
||||||
|
{
|
||||||
|
$invoice = $request->entity();
|
||||||
|
$pdfString = $invoice->getPDFString();
|
||||||
|
|
||||||
|
header('Content-Type: application/pdf');
|
||||||
|
header('Content-Length: ' . strlen($pdfString));
|
||||||
|
header('Content-disposition: attachment; filename="' . $invoice->getFileName() . '"');
|
||||||
|
header('Cache-Control: public, must-revalidate, max-age=0');
|
||||||
|
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
|
||||||
|
|
||||||
|
return $pdfString;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -255,6 +255,7 @@ Route::group(['middleware' => 'api', 'prefix' => 'api/v1'], function()
|
|||||||
//Route::get('quotes', 'QuoteApiController@index');
|
//Route::get('quotes', 'QuoteApiController@index');
|
||||||
//Route::resource('quotes', 'QuoteApiController');
|
//Route::resource('quotes', 'QuoteApiController');
|
||||||
Route::get('invoices', 'InvoiceApiController@index');
|
Route::get('invoices', 'InvoiceApiController@index');
|
||||||
|
Route::get('download/{invoice_id}', 'InvoiceApiController@download');
|
||||||
Route::resource('invoices', 'InvoiceApiController');
|
Route::resource('invoices', 'InvoiceApiController');
|
||||||
Route::get('payments', 'PaymentApiController@index');
|
Route::get('payments', 'PaymentApiController@index');
|
||||||
Route::resource('payments', 'PaymentApiController');
|
Route::resource('payments', 'PaymentApiController');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user