public function importPdf($filename, $onlyPreImported = false)
    {
        $pages = $this->setSourceFile($filename);
        if ($onlyPreImported) {
            if (! ($filename instanceof Pdf)) {
                return;
            }
            
            foreach ($filename->_importedPages as $k => $tplId) {
                // Recycling $filename's Tpls
                $tpl = $filename->_tpls[$tplId];
                $this->tpl++;
                $this->_tpls[$this->tpl] = $tpl;
                $this->_importedPages[$k] = $this->tpl;
                //use the imported page and place it at point 0,0; calculate width and height
                //automaticallay and ajust the page size to the size of the imported page 
                $this->addPage();
                $this->useTemplate($this->tpl, null, null, 0, 0, true); 
            }
            return;
        }
        for ($i = 1; $i <= $pages; $i++) {
            $this->addPage();
            //use the imported page and place it at point 0,0; calculate width and height
            //automaticallay and ajust the page size to the size of the imported page 
            $this->useTemplate($this->importPage($i), null, null, 0, 0, true); 
        }
    }