ET
Gerar documento pdf com layout Paisagem
Alguém sabe como posso gerar este documento com layout paisagem?
Desde já agradeço a ajuda.
Desde já agradeço a ajuda.
- <?php
- /**
- * Print view
- */
- public function onPrint($param)
- {
- try
- {
- TTransaction::open('cca');
- $object = Notas::find($param['key']);
- if ($object)
- {
- $html = new AdiantiHTMLDocumentParser('app/resources/NotasDocument.html', 'A4', 'portrait');
- $html->setMaster($object);
- $object->dt_atual = date('d/m/Y \À\S H:i:s');
- $objects = NotasItem::where('notas_id', '=', $object->id)->load();
- $html->setDetail('NotasItem', $objects);
- $html->process();
- $output = $html->getContents();
- $document = 'tmp/'.uniqid().'.pdf';
- $html = AdiantiHTMLDocumentParser::newFromString($output);
- $html->saveAsPDF($document);
- parent::openFile($document);
- new TMessage('info', _t('Document successfully generated'));
- }
- TTransaction::close();
- }
- catch (Exception $e)
- {
- throw new Exception($e->getMessage());
- }
- }
- ?>
$html = new AdiantiHTMLDocumentParser('app/resources/NotasDocument.html', 'A4', 'landscape');
Landscape e portrait referen-se a orientação da impressão ( paisagem e retrato )
Já fiz a mudança de 'portrait' para 'landscape', mas continua com a orientação Retrato.
Veja a assinatura do construct da classe AdiantiHTMLDocumentParser:
Ela só recebe 1 parâmetro, correspondente ao arquivo html.
Você deve informar a orientação da página na função saveAsPdf:
Na dúvida, sempre abra a classe pra dar uma olhada...
Ok Nataniel, Fiz as alterações e deu certo. Obrigado.