Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8741745
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T11:22:14+00:00 2026-06-13T11:22:14+00:00

I have a page that is supposed to render as a pdf with the

  • 0

I have a page that is supposed to render as a pdf with the help of WKHTMLTOPDF engine. When I click the link to load the page, I get this error:

WKHTMLTOPDF didn't return any data
Error: An Internal Error Has Occurred.

The stack trace is as follows:

APP\Plugin\CakePdf\Pdf\CakePdf.php line 234 → WkHtmlToPdfEngine->output()

    }
}

$output = $Engine->output();

APP\Plugin\CakePdf\View\PdfView.php line 97 → CakePdf->output(string)

prints this

$this->response->download($this->getFilename());
}

$this->Blocks->set('content', $this->renderer()->output($content));

return $this->Blocks->get('content');

then prints out the page exactly how i want it too

CORE\Cake\Controller\Controller.php line 956 → PdfView->render(null, null)

null
null

CORE\Cake\Routing\Dispatcher.php line 193 → Controller->render()

 }

        if ($render && $controller->autoRender) {
            $response = $controller->render();

        } elseif ($response->body() === null) {

CORE\Cake\Routing\Dispatcher.php line 161 → Dispatcher->_invoke(InvoicesController, CakeRequest, CakeResponse)

object(InvoicesController) {
    helpers => array(
        [maximum depth reached]
    )
    uses => array(
        [maximum depth reached]
    )
    paginate => array(
        [maximum depth reached]
    )
    components => array(
        [maximum depth reached]
    )
    name => 'Invoices'
    request => object(CakeRequest) {}
    response => object(CakeResponse) {}
    viewPath => 'Invoices'
    layoutPath => 'pdf'
    viewVars => array(
        [maximum depth reached]
    )
    view => 'view'
    layout => 'adminpdf'
    autoRender => false
    autoLayout => true
    Components => object(ComponentCollection) {}
    viewClass => 'Pdf'
    View => object(PdfView) {}
    ext => '.ctp'
    plugin => null
    cacheAction => false
    passedArgs => array(
        [maximum depth reached]
    )
    scaffold => false
    methods => array(
        [maximum depth reached]
    )
    modelClass => 'Invoice'
    modelKey => 'invoice'
    validationErrors => null
    Toolbar => object(ToolbarComponent) {}
    Session => object(SessionComponent) {}
    Auth => object(AuthComponent) {}
    RequestHandler => object(RequestHandlerComponent) {}
    pdfConfig => array(
        [maximum depth reached]
    )
    Invoice => object(Invoice) {}
    FieldsInvoice => object(FieldsInvoice) {}
    InvoicesItem => object(InvoicesItem) {}
}
object(CakeRequest) {
    params => array(
        [maximum depth reached]
    )
    data => array([maximum depth reached])
    query => array([maximum depth reached])
    url => 'Invoices/view/1.pdf'
    base => '/pra'
    webroot => '/pra/'
    here => '/pra/Invoices/view/1.pdf'
}
object(CakeResponse) {

}

APP\webroot\index.php line 92 → Dispatcher->dispatch(CakeRequest, CakeResponse)

object(CakeRequest) {
    params => array(
        [maximum depth reached]
    )
    data => array([maximum depth reached])
    query => array([maximum depth reached])
    url => 'Invoices/view/1.pdf'
    base => '/pra'
    webroot => '/pra/'
    here => '/pra/Invoices/view/1.pdf'
}
object(CakeResponse) {

}

here is my bootstrap.php

<?php
    CakePlugin::loadAll();  
    CakePlugin::load('DebugKit');
     CakePlugin::load('CakePdf', array('bootstrap' => true, 'routes' => true));
     Configure::write('CakePdf', array(
        'engine' => 'CakePdf.WkHtmlToPdf',
        'download'=>true,
        'binary'=>'C:\\Program Files (x86)\\wkhtmltopdf\\wkhtmltopdf.exe'));

    // Enable the Dispatcher filters for plugin assets, and
    // CacheHelper.
    Configure::write('Dispatcher.filters', array(
    'AssetDispatcher',
    'CacheDispatcher'
    ));

    // Add logging configuration.
    CakeLog::config('debug', array(
    'engine' => 'FileLog',
    'types' => array('notice', 'info', 'debug'),
    'file' => 'debug',
    ));
    CakeLog::config('error', array(
    'engine' => 'FileLog',
    'types' => array('warning', 'error', 'critical', 'alert', 'emergency'),
    'file' => 'error',
    ));

the view in my controller

public function view($id = null) {
    $this->set('title_for_layout', 'Invoices');
    $this->set('stylesheet_used', 'homestyle');
    $this->set('image_used', 'eBOXLogoHome.png');
    $this->layout='adminpdf';


    $this->pdfConfig = array('engine' => 'CakePdf.WkHtmlToPdf');

            $this->Invoice->id = $id;
            if (!$this->Invoice->exists()) {
                throw new NotFoundException(__('Invalid invoice'));
            }
            $this->pdfConfig = array(
                'engine'=>'CakePdf.WkHtmlToPdf',
                'orientation' => 'potrait',
                'filename' => 'Invoice_' . $id
            );

            $this->set('invoice', $this->Invoice->read(null, $id));
        //Retrieve Account Id of current User       
        $accountid=$this->Auth->user('account_id');




        //Find all Invoices where $conditions are satisfied
        $invoicedetails=$this->Invoice->find('first', array(
        'conditions' => array('Invoice.id'=>$id)));

        //prints fieldsInvoice details, including invoice and field information
        $invoices=$this->FieldsInvoice->find('all',array(
        'conditions'=>array(
        'invoice_id'=>$id)));

        $itemInvoice=$this->InvoicesItem->find('all',array('conditions'=>array('invoice_id'=>$id)));

        //Set variables
        $this->set('invoicedetails', $invoicedetails);  
        $this->set('invoice', $invoices);   
        $this->set('accountid', $accountid);
        $this->set('itemInvoice', $itemInvoice);

    }



//End of Controller


    }

my app controller

class AppController extends Controller {

    public $components = array(
        'DebugKit.Toolbar',
        'Session', 
        'Auth'=>array(
            'loginRedirect'=>array('controller'=>'users', 'action'=>'login'),
            'logoutRedirect'=>array('controller'=>'users', 'action'=>'login'),
            'invoiceRedirect'=>array('controller'=>'invoices', 'action'=>'viewinvoice'),
            'authError'=>"You can't access this page",
            'authorize'=>array('Controller')
        ),
        'RequestHandler'
    );

routes.php

 */
    CakePlugin::routes();
    Router::mapResources(array('Invoices'));
    Router::connect('/', array('controller' => 'pages', 'action' => 'display', 'home'));
/**

here is the view i want rendered as a pdf

<div id = "content">
<h2>View Invoice</h2>
                <table id="data">


    <?php

        if($invoicedetails['Invoice']['scheduled']==1)
        {
            $status = 'Scheduled';  
            $fcol = 'Black';
            $bgcol = '#EBD8E8';
            $pay = NULL;
            $dispute = NULL;
        }
        else if($invoicedetails['Invoice']['paid']==1)
        {
            $status = 'Paid';
            $fcol = 'Black';
            $bgcol = '#B9FAEA';
            $pay = NULL;
            $dispute = NULL;
        }
        else if($invoicedetails['Invoice']['sender_id']==$accountid)
        {
            $status = 'Sent';
            $fcol = 'Black';
            $bgcol = '#F8FAC0';
            $pay = NULL;
            $dispute = NULL;
        }
        else if($invoicedetails['Invoice']['receiver_id']==$accountid)
        {
            $status = 'Received';
            $fcol = 'Black';
            $bgcol = '#FAB9B9';
            $pay = $this->Html->link('Pay', array('controller' => 'Invoices','action'=>'pay_admin',$invoicedetails['Invoice']['id'] )) ;
            $dispute = $this->Html->link('Dispute', array('controller' => 'Disputes','action'=>'add_admin',$invoicedetails['Invoice']['id'] ));
        }



    ?>                      
                <tr>
                <th>Sender: </th>
                <td><?php echo $invoicedetails['SenderAccount']['account_name'];?> </td>
                </tr>

                <tr>
                <th>Receiver: </th>
                <td><?php echo $invoicedetails['ReceiverAccount']['account_name'];?> </td>
                </tr>

                <tr>
                <th>Invoice ID: </th>
                <td><?php echo $invoicedetails['Invoice']['id'];?> </td>
                </tr>

                <tr>
                <th>Invoice Date: </th>
                <td><?php echo date('d.m.Y', strtotime($invoicedetails['Invoice']['created'])); ?></td>
                </tr>

                <tr>
                <th>Due Date: </th>
                <td><?php echo date('d.m.Y', strtotime($invoicedetails['Invoice']['expiry_date'])); ?></td>
                </tr>

                <tr>
                <th>Status: </th>
                <td bgcolor='<?php echo $bgcol ?>'><?php echo $status ;?> </td>
                </tr>

                <tr>
                <th>Actions: </th>
                <td><?php echo $pay ?> <?php echo  $dispute ?></td>
                </tr>               


                </table>
                <br>
                <table id="data">
                <tr>
                    <th>Item Name</th>
                    <th>Description</th>
                    <th>Price Per Unit</th>
                    <th>Quantity</th>
                </tr>
                <?php foreach($itemInvoice as $itemInvoices):?>
                <tr>
                <td><?php echo $itemInvoices['Item']['name']; ?></td>
                <td><?php echo $itemInvoices['Item']['description']; ?></td>
                <td>$<?php echo number_format($itemInvoices['Item']['price'], 2, '.', ','); ?></td>
                <td><?php echo $itemInvoices['InvoicesItem']['quantity']; ?></td>
                </tr>
    <?php endforeach; ?>
                </table>

                <br>

                <table id="data">
                <tr>
                    <th>Field Name</th>
                    <th>Entered Value</th>
                </tr>


        <?php foreach($invoice as $invoices):?>
<tr>
<td><?php echo $invoices['Field']['name']; ?> :</td>
<td><?php echo $invoices['FieldsInvoice']['entered_value']; ?></td>
</tr>
    <?php endforeach; ?>



            </table>
            <br><br>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T11:22:15+00:00Added an answer on June 13, 2026 at 11:22 am

    there was two issues with this code that needed resolving

    1. was the binary in the bootstrap.php
      Original:

      Configure::write(‘CakePdf’, array(
      ‘engine’ => ‘CakePdf.WkHtmlToPdf’,
      ‘download’=>true,
      ‘binary’=>’C:\Program Files (x86)\wkhtmltopdf\wkhtmltopdf.exe’));

    new

     Configure::write('CakePdf', array(
        'engine' => 'CakePdf.WkHtmlToPdf',
        'download'=>false,
        'binary'=>'C:\\wkhtmltopdf\\wkhtmltopdf.exe',
        'orientation'=>'portrait'));
    
    1. in my invoices controller I had a spelling mistake with the word portrait.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a button on an aspx page that is supposed to send an
I have a page that looks like this: <div class=post> <h1>Foo Bar</h1> </div> I
I have a page that works perfectly when it's rendered upon page load. (My
I have a page that builds out a table. Nothing else on that page
I have a page that lets the user edit the content of the page
I have a page that uses the Telerik RadListView control and a Telerik RadDataPager
I have a page that I want to update non stop, every few seconds.
I have a page that consists of a header div for navigation, a content
I have a page that I am using an Ajax Accordion and when I
I have a page that has no vertical scroll, rather, everything is displayed horizontally.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.