我正在使用jspdf将图像转换为PDF.
我已使用base64encode将图像转换为URI.但问题是控制台中没有显示错误或警告.
生成带有文本Hello World的PDF但不添加任何图像.
这是我的代码.
function convert(){
var doc = new jsPDF();
var imgData = 'data:image/jpeg;base64,'+ Base64.encode('Koala.jpeg');
console.log(imgData);
doc.setFontSize(40);
doc.text(30, 20, 'Hello world!');
doc.output('datauri');
doc.addImage(imgData, 'JPEG', 15, 40, 180, 160);
}
Run Code Online (Sandbox Code Playgroud) 我正在成功登录系统,但我希望角色为"管理员"的用户只能访问所有路由,而具有"管理员"角色的用户可以转到"主页"和"GetDocumentDetails",否则其他登录用户将被限制在主页和访客登录页面.我的路由和过滤文件如下:
路线:
Route::post('/login', function()
{
$user = array(
'username' => Input::get('username'),
'password' => Input::get('password'));
// verify user credentials
if (Auth::attempt($user,true))
{
$role= Auth::user()->userrole;
return Redirect::route('home');
}
}
// Route for getting document details using get method
Route::get('GetDocumentDetailsById',array('as'=>'GetDocumentDetailsById','uses'=>'DocumentController@GetDocumentDetailsById'));
// Route for guest user
Route::filter('guest', function()
{
if (Auth::check())
return Redirect::route('home')->with('flash_notice', 'You are already logged in!');
// Redirect Log-in user to his home page
});
Run Code Online (Sandbox Code Playgroud)
过滤器:
/* Filter to redirect guest user to login page */
Route::filter('auth', function()
{
$role=Auth::user();
if (Auth::guest()) …
Run Code Online (Sandbox Code Playgroud) 这里,下面是我使用mpdf将图像转换为pdf的代码.$ html contains upload/tulips.jpg
但是,当函数执行创建的pdf文件时,图像图标显示该位置upload/tulips.pdf
.请告诉我为什么会这样,因为没有错误来临.
private function ConvertImageToPdf($inputPath,$outputPath)
{
$mpdf=new mPDF();
$html='<img src='.$inputPath.'/>';
$mpdf->WriteHTML($html);
$mpdf->Output($outputPath.".pdf",'F');
$mpdf->debug = true;
}
Run Code Online (Sandbox Code Playgroud)