Yii2Assets / yii2-pdfjs

Yii2 PDFJS bundle of PDF.js plugin
https://yii2assets.github.io/yii2-pdfjs
22 stars 18 forks source link

Error when used with _protected folder. #18

Open imoldovavan opened 7 years ago

imoldovavan commented 7 years ago

I am using the template from http://www.yiiframework.com/extension/yii2-improved-advanced-template/

And get this error when firing up pdf viewer on a page.

`exception 'yii\base\InvalidRouteException' with message 'Unable to resolve the request: site/pdfjs' in C:\Users\moljoh\xampp\htdocs\cloudhamlog_protected\vendor\yiisoft\yii2\base\Controller.php:127 Stack trace:

0 C:\Users\moljoh\xampp\htdocs\cloudhamlog_protected\vendor\yiisoft\yii2\base\Module.php(523): yii\base\Controller->runAction('pdfjs', Array)

1 C:\Users\moljoh\xampp\htdocs\cloudhamlog_protected\vendor\yiisoft\yii2\web\Application.php(102): yii\base\Module->runAction('site/pdfjs', Array)

2 C:\Users\moljoh\xampp\htdocs\cloudhamlog_protected\vendor\yiisoft\yii2\base\Application.php(380): yii\web\Application->handleRequest(Object(yii\web\Request))

3 C:\Users\moljoh\xampp\htdocs\cloudhamlog\index.php(12): yii\base\Application->run()

4 {main}

Next exception 'yii\web\NotFoundHttpException' with message 'Page not found.' in C:\Users\moljoh\xampp\htdocs\cloudhamlog_protected\vendor\yiisoft\yii2\web\Application.php:114 Stack trace:

0 C:\Users\moljoh\xampp\htdocs\cloudhamlog_protected\vendor\yiisoft\yii2\base\Application.php(380): yii\web\Application->handleRequest(Object(yii\web\Request))

1 C:\Users\moljoh\xampp\htdocs\cloudhamlog\index.php(12): yii\base\Application->run()

2 {main}`

I have used the module successfully before. Any help to fix this would be greatly appreciated... Thank you, John

imoldovavan commented 7 years ago

Disabling pretty url fixed the problem. Is there a way to fix this without disabling pretty url??

ludm commented 7 years ago

Hello, I had the same problem and I have replaced : $url = Url::to(['/pdfjs/','file'=>Url::to($url)]);
by $url = Url::to('/pdfjs/?file='.$url); in yii2-pdfjs/views/viewer.php

bpanatta commented 5 years ago

Hello, I had the same problem and I have replaced : $url = Url::to(['/pdfjs/','file'=>Url::to($url)]); by $url = Url::to('/pdfjs/?file='.$url); in yii2-pdfjs/views/viewer.php

This also solved my problem.