New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Images not shown in PDF #57
Comments
Can you use the full path? Like http://mydomain.com/images/logo.png? Use |
works fine in last version. In old version need to update dompdf package manually |
Was this problem ever solved? Because it seems that it wasn't. dd($view->render()); everything is OK, image is displayed. but when I do $html = View::make('emails.upn.pdf-invoice', $data);
$pdfUPN = PDF::loadHTML($html)->stream();
$randomTime = time();
if (!is_dir("upn/")) {
mkdir("upn/");
}
file_put_contents('./upn/'.$CaseID.'-'.$randomTime.'.pdf',$pdfUPN);
$pdf = './upn/'.$CaseID.'-'.$randomTime.'.pdf'; PDF doesn't contain image. <html>
<head>
<meta http-equiv="Content-Type" content="charset=utf-8" />
<meta charset="UTF-8">
<title>PDF Upn</title>
<style type="text/css">
* {
font-family: "DejaVu Sans";
font-size: 8px;
}
.upn{background-image:url("https://sub.domain.com/upn.jpg"); background-repeat:no-repeat; width:700px; height:342px; position:absolute;}
</style>
</head>
<body>
<div class="upn">test</div>
</body> |
@RokSiEu |
Hi $html = View::make('emails.upn.pdf-invoice', []);
$pdfUPN = PDF::loadHTML($html)->stream();
$randomTime = time();
if (!is_dir("upn/")) {
mkdir("upn/");
}
$CaseID = '123';
file_put_contents('./upn/'.$CaseID.'-'.$randomTime.'.pdf',$pdfUPN);
$pdf = './upn/'.$CaseID.'-'.$randomTime.'.pdf'; And the emails.upn.pdf-invoice: <html>
<head>
<meta http-equiv="Content-Type" content="charset=utf-8" />
<meta charset="UTF-8">
<title>PDF Upn</title>
<style type="text/css">
* {
font-family: "DejaVu Sans";
font-size: 8px;
}
.upn {
background-image:url("{{ asset('images/test.jpg') }}");
background-repeat:no-repeat;
width:700px;
height:342px;
position:absolute;
}
</style>
</head>
<body>
<div class="upn">test</div>
</body> |
Found where is a problem! Just add the site to the hosts file, and all will works! |
What do you mean with "hosts" file? On Fri, Jul 31, 2015 at 2:30 PM, Dmitriy Galievskiy <
|
/etc/hosts file |
@xAockd +1, lost 1 day on this until i saw this. |
Can't get it to work on localhost:8000 with |
This might help someone This should do the trick.
|
Hi, I currently have a problem. Images was showing for 3 or 4 generated pdf but now no images are shown. I am using the @AMABK code:
It was working as I said for 3 or 4 generated files but now the image is not showed. I save each html on a file and such files the image is showed. Now I am trying with decoded image but is unsuccessful. I am using the version 0.4 for laravel 4.2 |
This trick works for me! 😃 Convert your Image file to Base64 format with these lines of code, and then include the
|
Thank you @hzung. Took lot of time at last found your solution & it just worked fine :) |
src="http://www.example.com/assets/images/image.png" You just need to change it to, src="assets/images/image.png" |
@AMABK thanks! it did the trick! |
HI Guys, I am still having this problem. My setup is as follows. And I am using OS
PHP Version
Composer File
Controllerpublic function downloadPDF ($id)
{
$user = UserInfo::find($id);
$pdf = PDF::setOptions([
'images' => true
])->loadView('customer.carFact', compact('user'))->setPaper('a4', 'portrait');
return $pdf->download('carfact_sheet.pdf');
} HTML :: customer/carFact.blade.php
The Image is not Showing up on the PDF. |
@xAockd Thank you very much, your solution worked perfectly. |
@andresams |
I wonder why local links with port doesn't work: |
Change path:
And I specified size of image:
|
@rdtandel thank you so much, it did the trick 💯 |
@hzung I do not know if you will read this, but I thank you, you have taken me out of a big hurry. |
I actually didn't expect this to work, but it does! How's this different from Edit: Never mind. It seems that you need to specify your local path e.g. |
Me too i struggled for the same error for 3 days. Also when i tried tricks mentioned above, none of them worked too. But when i changed the image file to .jpg file(extension) everything worked well.
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
in my local, all images are working. but in live site, some png images are working and some are not working. i am using laravel dompdf can some help me on this? |
You can fix it by adding full path of image not URL public_path('images/logo.png '); And it will be worked fine |
@andreshg112 <img src = "data: image / png; base64, 333343344343 /> for example |
In my case, i'm using external css and spend time to figure out how to render background images. This works for me: pdf.php :
pdf-css.php :
But SVG don't work... |
For png files I simply do:
for SVG files in this case this is an background image
|
I'm not sure why but when I add in images, the pdf doesn't display it. However, when I see the html on the page, it shows up normally.
This is the error that displays on the pdf
Not sure what it is, but I can see the images in the HTML that is used to generate the PDF.
The text was updated successfully, but these errors were encountered: