holabs/printer

Printing package for Nette framework

0.1.1 2017-10-30 08:05 UTC

This package is auto-updated.

Last update: 2024-10-29 04:59:22 UTC


README

Printer package is for easy printing in Nette framework

Installation

Requirements:

composer require holabs/printer

Using

extensions:
	holabs.printer: Holabs\Printer\Bridges\Nette\PrinterExtension
	
# OPTIONAL
holabs.printer:
	auto-print: FALSE # Disable JS which call browser printing dialog
	layout: '%appDir%/presenters/template/printing/layout.latte' # Define own printing layout
	params: # Default parameters. Can be overwritten by job template options
		background: '#ffffff'
		margin: 2cm
		size: A4
		
# !!! You have to create your implementation of ITemplateStorage and IEntityStorage as service
<?php

namespace App\Presenters;

use Holabs\Printer;

class PrinterPresenter extends Presenter {

	/** @var string @persistent */
	public $id = NULL;

	/** @var Printer @inject */
	public $printer;

	/**
	 * @param int[]|array $eid Entity ids
	 */
	public function actionPrint(array $eid = []){
		$job = $this->printer->createJob($this->id, ... $eid);

		// Send to output from printer
		$this->printer->printJob($job);
		
		// Or using presenter method - Job implement IResponse
		$this->sendResponse($job);
	}

}