-
Notifications
You must be signed in to change notification settings - Fork 61
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
add PdfImageAsset #79
add PdfImageAsset #79
Conversation
Thanks for your work on this PR. I like the functionality, but I think it could be make easier to use. Instead of letting users call It could work like this in a Blade view
This way, the controller doesn't have to know that images should be inlined. Could you make this change? Thanks! |
@freekmurze appreciated for the suggestion @ArielMejiaDev welcoming to do it and waiting for the push |
I am on it! thanks |
Eagerly waiting @ArielMejiaDev |
Hi @freekmurze there is a commit, if you can check this loom (I try to make it short & fun, sorry the audio) you would see the behavior now with a directive (looks lot more cleaner). Demohttps://www.loom.com/share/e3a5fc63f7894b779371e4c5d13a6a0d?sid=80074810-3d33-4ac6-9293-9d7061afc2b4 I was not able to run all Pest tests that uses expect()->extend('toContainText', function (string|array $expectedText) {
$binPath = PHP_OS === 'Linux'
? '/usr/bin/pdftotext'
: '/opt/homebrew/bin/pdftotext'; |
@freekmurze waiting for you |
@freekmurze waiting please |
@RVP04 Thanks for your enthusiasm but please refrain from posting reminders here and on other social channels. That won't make me working faster. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ArielMejiaDev Thanks for your work on this!
docs/basic-usage/formatting-pdfs.md
Outdated
@@ -48,6 +48,16 @@ Inside the footer, you can use the following Blade directives: | |||
- `@pageNumber`: The current page number | |||
- `@totalPages`: The total number of pages | |||
|
|||
### Display Images in Headers and Footers | |||
|
|||
You can add an image using the blade directive `@inlidedImage` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be renamed to inlinedImage
everywhere in this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @freekmurze , the directive name has been fixed, hopefully it helps and thanks for your efforts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ArielMejiaDev thanks
Because I am eagerly waiting for you |
Thanks! |
How I can use PdfImageAsset with the pdf. because it's not found? |
You can set images using the directive: @imageInlined('your-image.png') |
@ArielMejiaDev But when I used these lines of code: the pages will not responding and show me This site can’t be reached and I have to stop the serve and re run it by Please help me if you have any idea. |
You have to use @imageInlined('your-image.png') Check yours it is wrong @inlinedImage() |
Hi @Professor93M as @RVP04 says sorry the correct directive is @imageInlined('images/logo.png') or using an object property @imageInlined($model->image) |
Do you mean like that:
I tried that but it show only the text like that: @imageInlined('images/logo.png') |
@Professor93M please check first that the file exists in your public directory, then you can follow this example https://github.com/ArielMejiaDev/laravel-pdf-demo/blob/main/resources/views/components/header.blade.php you can check the whole app to see controllers, public directory, resources/views to check blade files etc. |
First check in view whether file is loading or not. Share your actual code controller and view properly to troubleshoot Also try to clear cache, config and view |
This my code: Controller
pdf.blade.php (View)
header.blade.php
I run same problem |
Any comment gents? |
Try to trouble shoot with views first it is getting loaded or not then you we decide for the solution
Get Outlook for iOS<https://aka.ms/o0ukef>
…________________________________
From: Mohammed K. Jumaah ***@***.***>
Sent: Thursday, April 11, 2024 12:14:35 PM
To: spatie/laravel-pdf ***@***.***>
Cc: VP ***@***.***>; Mention ***@***.***>
Subject: Re: [spatie/laravel-pdf] add PdfImageAsset (PR #79)
Any comment gents?
Please need help
—
Reply to this email directly, view it on GitHub<#79 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AB6ONJ25DMT3U6KNE5PCEF3Y4ZA6XAVCNFSM6AAAAABDAND2FSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANBZGE3DKNBVGE>.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
What makes the PR
It adds a new class helper that encodes as base 64 images, no matter if the image path is relative or an absolute path, and also adds some prefix required for image assets in headers and footers to display images successfully by puppeteer.
The code would look like this
It would solve a lot of discussions and issues about how to add images to headers and footers.
like:
I add it as a support class as its concern is simple, I doubt adding the functionality as a trait to the PdfBuilder class but just makes more sense to handle it as a static helper.
Testing
It also adds its test `PdfImageAssetTest.
Docs
It also adds some suggested text for docs in headers and footers.
Demo about the issue
It solves the issue talked about in discussion #71
https://www.loom.com/share/8912fba845214a1d93aefc99fcf93b93?sid=c0389007-fcdf-4110-bee1-82317fc53c91