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.
Related
I am working on HTML to PDF generation, i am using laravel with DOMPDF library, I have 3 different images, i have that image through css and html, its working fine, but after when we downloading the file and opening into Photoshop its show RGB mode
I want it to show cmyk Mode.
This is the output file of my pdf
My PDF download code after rendering the html
$customPaper = array(0,0,4500,2950);
$pdf->setOptions(['dpi'=>300]);
$pdf->loadHTML($html)->setPaper($customPaper)->setWarnings(false)->save($filename.'.pdf');
return $pdf->stream();
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') }}
I am trying to create a pdf file from html in my codeigniter project. The html file contains an image but it will not load in the pdf. I am using html2pdf library and here is my code.
example.php :
<img src="<?php echo base_url()?>assets/images/logo.jpg" alt="BulkSMS">
I am pasting only the <img> tag here, because it is a large file.
and here is my controller function
public function htmlToPdf($data) {
$this->html2pdf->folder(PURCHASE_INVOICE_PATH);
$fileName = $data['invoiceNumber'].'.pdf';
$this->html2pdf->filename($fileName);
$this->html2pdf->paper('a4', 'portrait');
$content = $this->load->view('templates/example', '', true);
//Load html view
$this->html2pdf->html($content);
$this->html2pdf->create('save');
return $fileName;
}
I tried to change path of image to full path and type of image from png to jpg. But still it not showing
This issue is happening becuase of CORS. Uncomment The following line from the dompdf_config.inc.php file located in application/libraries/dompdf folder.
define("DOMPDF_ENABLE_REMOTE", true);
I need to display doc or docx or pdf kind of file in php code.Here is my code,
<iframe src="http://localhost/sample/sampl1/resource/upload/resumes/1406263145_resume sample.docx"
style="width:820px; height:700px;" frameborder="0"></iframe>
in localhost...
When i load the form,the given docx file is downloading automatically and the file is not view in a php form...So any one can help me?
To view document files (doc, docx, etc), you can use either the Zoho Viewer or Google Docs Viewer jQuery plugin.
Im using http://www.ashberg.de/php-barcode/ scripts to generate a barcode. I now need to import the barcode into a PDF from html. (Im using html2pdf_v4.03 for html -> pdf)
<div style=" display:inline;"><img id='barcode' alt='barcode' src="scripts/barcode/barcode.php?mode=jpg" /></div>
works, but when I import it to PDF it errors. So I decided to try generate the barcode and save it to a dir as an img and refrence it in the html I then convert to PDF.
So I tried
file_put_contents('scripts/barcode.jpg', file_get_contents('scripts/barcode/barcode.php?mode=jpg'));
and I get failed to open stream: error
if i try
file_put_contents('scripts/barcode.jpg', file_get_contents('scripts/barcode/barcode.php'));
It runs but the image file it creates is not readable/ broken.
Please assist?
Write full url (http://domain.com/scripts/barcode/barcode.php) instead of scripts/barcode/barcode.php. Probably its opens local php file when you use file_get_contents()