I'm facing a problem with displaying a QR code in a PDF file. When I try to display the QR code without PDF it works. The QR code is generated by https://github.com/SimpleSoftwareIO/simple-qrcode on to a pdf file generated by https://github.com/barryvdh/laravel-dompdf/tree/0.8.5
StudentController.php:
public function view_downlads($id){
$pdf = PDF::loadView('Student.markscardpdf');
return $pdf->stream();
}
Student/markscardpdf.blade.php:
{{ QrCode::size(200)->generate('hello') }}
Related
I want generate a pdf file to the customer that can edit it and then download it,
I use Laravel 8, mpdf 0.8.15, niklasravnsborg/laravel-pdf 4.1 and php 7.4
I tried this code with mpdf package in controller :
$html = file_get_contents(resource_path('views/app/pdf/inventory/inventory2.blade.php'));
$pdf = new \Mpdf\Mpdf();
$pdf = Mpdf::loadView('app.pdf.inventory.inventory2');
$pdf->useActiveForms = true;
$pdf->WriteHTML($html);
return $pdf->Output();
// return $pdf->stream('document.pdf');
The view was rendred with blade syntax {{ }} #if... , so it's not useful
also I tried niklasravnsborg/laravel-pdf that can load view not write html content, but the pdf generated was not fillable, It create the form staticly (input, buttons ...) not editale
have you an idea to get a fillable pdf ?
I am trying to generate a PDF file using DOMPDF in a Laravel project.
The image is displayed correctly when generating my Blade template. On the other hand, the image is not displayed in the generation of the PDF file (the PDF file uses the Blade template).
The controller
$pdf = domPDF::loadView($blade, compact('cv', 'user', 'cv_certifications', 'cv_skills_nom', 'experiences', 'formations','perso', 'adresse', 'region', 'region_select', 'cv_skills', 'tcontrat'));
// Viewing the PDF file in the browser viewer
return $pdf->stream(); // display
The template
<img src="{{URL::asset($perso[0]->cvp_photo_path)}}" height="auto" width="150">
What I want
I would like the image to display in the Generated PDF file
What I get
I obit no errors in the server logs nor in laravel. The image does not load into the PDF file but loads into the rendered template correctly.
Thank you in advance for your help.
i was trying to print invoice with Laravel using barryvdh/laravel-dompdf
I used the following code to convert pdf:
$pdf = \PDF::loadView('print.service_x')->setPaper('a4','portrait');
return $pdf->download('invoice.pdf');
But the style got break...some of the text overlap the table. How do i solve this problem?
Style link is OK...As when i load the page without pdf it shows me correct view:
I try to build site with collect some links and then i would like generate to each link small QR code. I use php QR Code and when i try generate basic code like this
public function testAction{
QRcode::png('PHP QR Code :)');
}
i se white site with empty QR code.
But when i disable view and render
public function testAction{
$this->_helper->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
QRcode::png('PHP QR Code :)');
}
I see my QR code but only this without my view.
How can i send this QR code to view without write this code to file ?
To elaborate on my comments above, you can create a separate php file that does nothing but generate the QR code based off of $_GET parameters you send to it in the URL.
<?php // qrcode.php
QRcode::png($_GET['parameter']);
If you view qrcode.php?parameter=Hello%20World you will get a QR code for Hello World
If you create an image sourced to qrcode.php, it will output that generated QR code:
<img src="qrcode.php?parameter=Hello%20World" />
without creating a qr code image file.
**Controller** : Test
**View where the form resides** : index.ctp
**View containing fpdf code** : pdf.ctp
I generate a pdf file using FPDF but the pdf file is not rendering properly. I have confirmed that the FPDF code is error free.
On URL
localhost/project/test
I will fill up a form and press submit. This will submit to
localhost/project/test/pdf
But here the pdf is not rendering properly. It just keeps on telling Loading.
If i submit it to some other folder/pdf.php file (same fpdf code in php file)
Everything is ok
localhost/fpdf/pdf.php
I'm answering my questions myself. Come on people HELP ME!!
The problem was that the output was not rendering as pdf. I used this controller to solve my problem.
public function pdf()
{
$this->response->type('pdf');
}