Add Printjs to infolist action
Hi, in my app i have an infolist with a button 'print'
this action all a route that generate and show a pdf in the browser (same tab)
now i want to add printerjs in order to print it directly
i've added print js with npm
import in app.js
compiled with npm run build
and inspecting the code, the library seems to be loaded right
now
9 Replies
this is the route
Route::get('/label/{record}/download', [PdfController::class, 'downloadLabel'])->name('repair.pdf.label');
that calls the controller
how can i modify the action to call printjs instead of open the pdf?
Adding wire:click with the JS code to the extraAttributes might do it.
ok i try
I've already spent 3 hours on this.
Is what I'm trying to do feasible, or am I wasting my time?
So you’re using a livewire click handler with a js query selector,? There’s no way that’s ever going to work.
any chance to use printjs?
my app is working, but in the infolist when i print a label/invoice etc
the pdf is opened in the same tab, after printing the pdf i have to hit the browser's back button
to comback to the app.. not so friendly
You probably need to run it through alpine, then use $wire to stream it back to the browser.
Alpine will have access to the query selector.
If that makes sense.
But you’re getting a null either way on the query selector which means it can’t find the html element.
But I think that’s because of the livewire click handler.
Actions also have an ->alpineClickHandler() that will disable the livewire click handler. Maybe start there.
Thank you, tomorrow I will try