laravel-printing
laravel-printing copied to clipboard
content() and url() methods not working
Laravel Printing Version
v3.0.0
Laravel Version
v9.19
Bug description
file methods works fine when we try to print but
Printing::newPrintTask() ->printer($printerId) ->content('hello world') ->send();
and
Printing::newPrintTask() ->printer($printerId) ->url('https://www.google.com') ->send();
functions not working when we try to print. Inside PrintNode application, on logs section we can see PrintJob id and done message but nothing comes out from our printer. And no error shows up in our project.
Steps to reproduce
No response
Relevant log output
No response
When using content() method you can specify the content type with the 2nd parameter. Depending on your used driver you can find the available content types in Printing/Drivers/
Example hardcoded:
Printing::newPrintTask()
->printer($printerId)
->content($text, 'text/plain')
->send();
or in my case loading with a different name:
use Rawilk\Printing\Drivers\Cups\ContentType as PrintingCUPSContentType;
Printing::newPrintTask()
->printer($printerId)
->content($text, PrintingCUPSContentType::TEXT)
->send();
Personally I generate a pdf and send it using the file()
method, however you should be able to send a plain string to the content()
method since it defaults to raw_base64
by default as the content type, and I'm base64_encode(...)
your content automatically for you.
If it's getting to PrintNode, then the request was successful, however there was an issue with PrintNode sending the job to your printer. I'm not really sure exactly what the issue could be, but for me personally I've noticed that sometimes it won't print if the paper size doesn't match up on the tray I'm printing to.
Also, this seems to be a duplicate of #34
This issue is stale because it has been open 21 days with no activity. Remove stale label or comment or this will be closed in 7 days.
`$bill = Bill::find(8); $data = [ 'name' => 'Humayun', 'address' => 'test', 'account_number' => '22000001', 'billing_period' => $bill->billing_period, 'uc_no' => 'uc', 'issue_date' => $bill->issue_date, 'ncr_no' => '33/006', 'old_ncr_no' => '', 'due_date' => $bill->due_date, 'tarrif' => 'DM 01', 'water_charges' => $bill->water_charges, 'sewerage_charges' => $bill->sewerage_charges, 'electricity_adjustment' => $bill->electricity_adjustment, 'service_charges' => $bill->service_charges, 'current_bill' => $bill->current_bill, 'minimum_payment_due' => $bill->minimum_payment_due, 'arrears' => $bill->arrears, 'payable_within_due_date' => $bill->payable_within_due_date, 'surcharge' => $bill->surcharge, 'payable_after_due_date' => $bill->payable_after_due_date, 'distinct_sewerage_charges' => $bill->distinct_sewerage_charges ];
$page = (string)view('test', $data);
$printerJob = Printing::newPrintTask()
->printer("ipp://localhost:631/printers/HL_L5200DW_series")
->content($page, PrintingCUPSContentType::HTML)
->send();
echo $printerJob->state();`
it is printing as string not html in my view file. any thoughts?
This issue is stale because it has been open 21 days with no activity. Remove stale label or comment or this will be closed in 7 days.