public function getPDFlib($opts = array())
	{
		$this->debug->groupCollapsed(__CLASS__.'->'.__FUNCTION__);
		debug('opts', $opts);
		$optsDefault = array(
			'errorpolicy'	=> 'return',		// This means we must check return values of load_font() etc.
			'license'		=> null,
			'textformat'	=> 'utf8',
			// 'avoiddemostamp'=> true,			// throws exception when true && invalid license
			'SearchPath'	=> $_SERVER['DOCUMENT_ROOT'],
			// 'escapesequence'	=> 'true',
		);
		$opts = array_merge($optsDefault, $opts);
		if (empty($opts['license'])) {
			if (isset($this->cfg['license'])) {
				$opts['license'] = $this->cfg['license'];
			} elseif (file_exists($this->cfg['licensefile'])) {
				$this->debug->info('licensefile found', $this->cfg['licensefile']);
				$opts['license'] = trim(file_get_contents($this->cfg['licensefile']));
			}
		}
		$p = new \PDFlib();
		$this->p = $p;
		$pdflibVer = $p->get_parameter('version', 0);
		$this->debug->info('pdflib version', $pdflibVer);
		$this->debug->log('opts', $opts);
		try {
			if (version_compare($pdflibVer, '9.0.0', '>=')) {
				$opt_string = $this->stringifyOpts($opts);
				$response = $p->set_option($opt_string);
			} else {
				foreach ($opts as $k => $v) {
					$response = $p->set_parameter($k, $v);
				}
			}
		} catch ( PDFlibException $e ) {
			trigger_error('PDFlib exception ['.$e->get_errnum().'] '.$e->get_apiname().' : '.$e->get_errmsg());
		}
		$this->debug->groupEnd();
		return $p;
	}