1. Go to this page and download the library: Download ambersive/documentviewer library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
ambersive / documentviewer example snippets
$signed = false
Route::document(
"invoices/{id}",
"invoices",
\App\Printables\Invoice::class,
[
// Middleware for getting the document
],
$signed,
\App\Printables\Invoice::class, // for file upload handling
[
// Middleware for postback / upload the document
]
);
use Illuminate\Http\Request;
use AMBERSIVE\DocumentViewer\Abstracts\DocumentAbstract;
class Invoice extends DocumentAbstract
{
public array $data = [];
// Define the blade you want to return as printable document
public String $blade = "ambersive.documentviewer::printable_default";
public bool $useValidationEndpoint = false;
public function setData(){
// Request is available in $this->request
// Save stuff in $this->data
// This function must return $this (= chainable)
// Params are provided in $this->params
return $this;
}
public function uploadDocumentHandler(Request $request) {
// Handle the file upload
// Requires a response (preferable json)
return ['status' => 200];
}
public function validateDocumentHandler(Request $request) {
// Handle the validation
// This information is a helper
// Requires a response (preferable json)
return ['status' => 200];
}
}
@extends('ambersive.documentviewer::printable')
@extends('ambersive.documentviewer::printable')
@section('styles')
<style>
body {
// Custom Page style goes here
}
</style>
@endsection
@section('document')
<div>Printable document</div>
@endsection
bash
php artisan make:printable "Invoice"
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.