Answer the question
In order to leave comments, you need to log in
How to make Yii2Assets/yii2-pdfjs work?
Hello. Has anyone used Yii2Assets/yii2-pdfjs in the Advanced version of Yii2? How to make it work? And in general, how to use the pdfjs library on Yii2? It gives an error in the browser console that it cannot load /assets/1b17959a/yii2-pdfjs.js
I did
everything as per the dock . I installed the extension via composer, included the module in common/config/main.php and then called the widget in the view
<?= \yii2assets\pdfjs\PdfJs::widget([
'url'=> 'domain.ru/files/doc/test_pdf.pdf'
]); ?>
Answer the question
In order to leave comments, you need to log in
It throws an error in the browser console that it cannot load /assets/1b17959a/yii2-pdfjs.js
public function actionDownload()
{
$path = Yii::getAlias('@webroot') . '/pdf/'; // путь к директории web/pdf в которую загружен файл.
$file = 'download.pdf';
return Yii::$app->response->sendFile($path . $file, $file, ['inline' => true]);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question