How to render webp image at dompdf??
Below are my view code :
<body>
<img src="4.webp">
<br>
<img src="1.png">
</body>
Below are my controller code :
$pdf = PDF::loadView( 'admin.registrations.index' );
return $pdf->stream( 'image.pdf' );
The png image is showed, but the webp doesn't.
I try to open the page via blade view :
return view( 'admin.registrations.index' );
Both image showed..
How to enable webp at dompdf??
Dompdf does not currently (up to and including 0.7.0) support WebP. Supported image types are:
BMP
GIF
JPEG
PNG
SVG (partial, using php-svg-lib)
Recommend that you submit an enhancement request to the issue tracker: https://github.com/dompdf/dompdf/issues/new
Related
I am saving an uploaded image like this:
$profile_picture = $request->file('profile_picture');
$user->profile_picture = $profile_picture->getClientOriginalName();
Storage::disk('public')->put( $user->profile_picture, $request->file('profile_picture') );
and then I am trying to display that image in HTML with:
<img class="img-fluid" src="{{ asset('storage/'. Auth::user()->profile_picture) }}">
the image is being saved in storage/app/public, but the image is not showing in html, how do i go about this?
thank you
You may use response method on a Laravel filesystem
return Storage::disk('public')->response($user->profile_picture);
N.B: In order to do that, you need a Laravel route. The above code should be located in a controller method
hiii i want to generate pdf of an invoice . pdf is generate but it can't display an image
i use laravel/snappy for window
here is my view file
<div>
<img src="{{ asset('image/logo.png') }}" class="pl-3" width="15%" />
Download PDF
</div>
here is my controller
if($request->has('download')) {
$pdf = PDF::loadView('pdfview')-
>save(storage_path('invoices/aazsaa.pdf'));
return $pdf->download('userlist.pdf');
}
image is shown in view but when i download image is not render
yehh i got the solution of my problem
i use base64 encoder to display an image
here is my view file
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAV4AAABkCAMAAAD5Y6hXAAAArlBMVEX////rUYmIHVHwf6j2rsj60eDfw9GoWX/Hlq7sXZH+8/f38POQLF3Ppbn73Of3udDuaJnn0tz86O/v4ejyi7DvdKG4d5egSnTzl7iYO2j0osCwaIv4xdjXtMXAhqLq2OH84+y/haGdRG+FFEuSMF+zb5Dy5uzewM/e3uDHlKz0nb3NoLb0Z5nwcZ/27vLsWY7DxMb0xdemX4Pl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q6WqFqt7LCm15eR31KXX6k70WRxUSm5QBqgwyZkC7k6aYK+cjwej1ejqyF24OTiMsrReGacpe3832p0SRWo7rF+adkUBJlfRRKUduqBEcXyG7cC1dVKPb1yPaJRwyutoNrjm7uL2wrfWDEEeLjLnorZWr/DobqXQN3nIEM0bdKoawBQN2kgp1CSwmy75Hutyy9f1WB+u+x0q2oEXEBqb5WTj7FBGx4wyL6y/kNbDyY8tqVmsHarrb/YCWO7NWpbva3n86PAGx4Qmqg/wwpX9fTeEsPRab3oDB33eD+JioxEEucvkbwJJO2wqKf3cP7S1ptAdt5cVxcR4zA+a++bQL6ZsarU3uQK9vlZ59vPqMJ9aR1u7v34TjcD9yxYO38o403YFc8vi+tV/+BjIh8ovTXz3idB5vv2q7EUie/brtC8F6Io2420hJh/bHp3Ix1+S4uoyWuvRjIyMn/HQTbGTB6d3qJvoKXFsN+ZXt9MrB4DnucM75zJVkbtR6d3BGTt6TZXuh+zLdNP3Mpu9EZ7W3qjov3xsYQ3p0nQafD9Jz93CnpHGVXJhUOpa11IGXWl13Fs6Y0tHh87/PPUe/o7unmOvECmq45O74ZuzR7yBz7ZjFrnoA+k138vekk67ulnOayd92dPZKvvT+Q5CHpt8IH0ZmP6FL0VkDEN/i4fhnug9+kSTv/u9DrR8F2+PQgrOAq9bHXvE9FbDnSo2IlkKAZO6S2PeVCUQUVcvzwpKyB6UQG70FBplqkFCapmnYyBL2YEYBwmQO+f4D7s/>
i change the src of image in tag. i just put base64 string of an image instead of path, and it's work
I have an image and some text ('p' tags) inside an html tag. Using html2canvas I can convert that html element to image. But When i use an image from server , it say Access control allow origin request blocked error. I also added allowTaint:true, useCORS:true , but nothing changed. Is there any solution for this? Or any other method ?
Here is my code
component.ts
html2canvas(document.getElementById('invoice-panel'),{allowTaint:true, useCORS:true}).then(canvas => {
var imgData = canvas.toDataURL("image/png");
});
html
<ion-avatar id="invoice-panel">
<img [src]="chosenPicture" id="custom-image"/>
<p *ngFor="let field of arrTextFields" absolute-drag class="newText"><b>{{field.text}}</b></p>
</ion-avatar>
Im currently using barryvdh/laravel-snappy to convert my data to pdf format.
The code i'm using is :
public function generate_pdf($id){
$rfq = RFQ::find($id);
$data = array(
'rfq' => $rfq,
);
//return view('rfq.pdf')->with('rfq', $rfq);
$pdf = PDF::loadView('rfq.pdf',$data)->setPaper('a4')->setOption('margin-bottom', 0);
return $pdf->download($rfq->rfq_no.'-'.date_timestamp_get(date_create()).'.pdf');
}
And then, I have to add an image to the pdf file. So i have to add this line to the pdf.blade.php file.
<img src="{{ asset('img/logo.png') }}">
But then, the image isn't showing properly.
It's visible, but it's OPACITY is very low, around 0.2.
But when viewing the actual image file, and the one in the actual html template, everything's good.
I tried <img src="data:image/png;base64,{{ base64_encode(#file_get_contents(asset('img/logo.png'))) }}">
but still, it's the same.
i want to make qrcode, in there i can make it but i have something trouble when i want to change the format of qrcode to png file. but its only show symbol
here my view :
<?php echo QrCode::size(265)->generate($row->id) ?>
this qrcode i use :
"simplesoftwareio/simple-qrcode": "~1"
here my referance : https://www.simplesoftware.io/docs/simple-qrcode
can anyone help me ? or can someone give me solution ?
before i change format to png :
and this after i change it :
There are more simple example available as well.
<img src="data:image/png;base64, {!! base64_encode(QrCode::format('png')->size(100)->generate('QrCode as PNG image!')) !!} ">
If you are formatting it as png file format, you need to include it with a <img> tag.
Taken from the documentation
//Inside of a blade template.
<img src="{!!$message->embedData(QrCode::format('png')->generate('Embed me into an e-mail!'), 'QrCode.png', 'image/png')!!}">
You can also do this:
$png = QrCode::format('png')->size(512)->generate(1);
$png = base64_encode($png);
echo "<img src='data:image/png;base64," . $png . "'>";
In controller
$path = getenv('IMAGE_URL')."/img/logo.png";
$png = QrCode::format('png')->merge($path, .17, true)->size(300)->errorCorrection('H')->generate($data);
$png = base64_encode($png);
In blade file
<img src='data:image/png;base64,{{$png}}'>
I came to this page because I needed to create a PNG file to send inline in an email in laravel8.
I used the examples above in order to create the QR code as a png which worked brilliantly. I used the following code:
<img src="data:image/png;base64, {!! base64_encode(QrCode::format('png')->size(100)->generate('QrCode as PNG image!')) !!}" />
However a number of email services (including Gmail) do not display images that use inlined base64 as above. Instead, they require you to add the base64 image as an attachment to the email and then reference that attachment in the img src.
Thankfully laravel (I'm using laravel8) has a really cool function that does this for you, so my code ended up looking like this (which worked):
<?php
$qrCodeAsPng = QrCode::format('png')->size(500)->generate("my text for the QR code");
?>
<img src="{{ $message->embedData($qrCodeAsPng, 'nameForAttachment.png') }}" />
The $message variable is one that is in every blade that is being sent as an email in laravel. In my case I did not want to create an actual image on the server, but if you wanted to use an image that you had stored you would use $message->embed().