Domanda

I am trying to use dompdf in magento for printing invoice.

So I am trying to include dompdf in magento but its not working.

I used following code in Mage.php before include_once "Varien/Autoload.php";.

include_once 'dompdf/autoload.inc.php';
spl_autoload_register('DOMPDF_autoload');

Its giving blank page.

Any help.

È stato utile?

Soluzione

I used code like

<?php
use Dompdf\Adapter\CPDF;
use Dompdf\Dompdf;
use Dompdf\Exception;

class Practice_ControllerTest_IndexController extends Mage_Core_Controller_Front_Action
{

    public function indexAction()
    {
         require_once 'dompdf/autoload.inc.php';

         $dompdf = new Dompdf();

         $dompdf->loadHtml('hello world');

         $dompdf->setPaper('A4', 'landscape');

         $dompdf->render();

         $dompdf->stream();

     }
}

It works for me

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a magento.stackexchange
scroll top