laravel-printing icon indicating copy to clipboard operation
laravel-printing copied to clipboard

content() and url() methods not working

Open TahaYasin61 opened this issue 2 years ago • 1 comments

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

TahaYasin61 avatar Aug 10 '22 09:08 TahaYasin61

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//ContentType.php PS: Default contentType goes to PDF.

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();

AlexPodaru avatar Sep 22 '22 14:09 AlexPodaru

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.

rawilk avatar Oct 31 '22 12:10 rawilk

Also, this seems to be a duplicate of #34

rawilk avatar Oct 31 '22 12:10 rawilk

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.

github-actions[bot] avatar Nov 22 '22 12:11 github-actions[bot]

`$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?

humayunjavaid avatar Nov 29 '22 11:11 humayunjavaid

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.

github-actions[bot] avatar Dec 21 '22 12:12 github-actions[bot]