1. Go to this page and download the library: Download trianity/laravel-pdf-viewer 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/ */
use Trianity\LaravelPdfViewer\Contracts\PdfDocumentResolver;
use Trianity\LaravelPdfViewer\Data\PdfDocument;
$this->app->bind(PdfDocumentResolver::class, function () {
return new class implements PdfDocumentResolver {
public function resolve(string $documentId): ?PdfDocument
{
// Look up the document in your own database.
return new PdfDocument(
disk: 'private',
path: 'documents/example.pdf',
filename: 'example.pdf',
mime: 'application/pdf',
);
}
};
});