This is an archived forum post. The information may be outdated. Contact us if you have any questions.

Cannot create PDF in zend framework

atish1302 wrote on 2016-11-11:
 public function indexAction() {
    	
    	$this->noViewRender();
    	
    	try
    	{
    		
    		
    		//$url = "http://" . $_SERVER["SERVER_NAME"] . '/training/ecourse/certificate/demo.html';
    		//echo $url;
    		//die();
    		
    		
    		// create an API client instance
    		$client = new PdfCrowd("***", "***");

    	
    		// convert a web page and store the generated PDF into a $pdf variable
    		$pdf = $client->convertURI('http://my.solidworks.com');
    		
    		header('Content-Type: application/pdf');
    		//header("Cache-Control: max-age=0");
    		//header("Accept-Ranges: none");
    		header('Content-Disposition: attachment; filename="created.pdf"');

    		readfile('created.pdf');
    		
    		//echo $pdf;
    		
    	       $this->_helper->viewRenderer->setNoRender ( true );
		$this->_helper->layout->disableLayout ();
    		// send the generated PDF
    		
    	}
    	catch(Exception $why)
    	{
    		echo "Pdfcrowd Error: " . $why;
    	}


I am not able to create PDF using the above code. Is there anything wrong. I have tried 100 times so far.
support wrote on 2016-11-15:
Hello,

Your code looks fine, are you getting any error messages?