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 8673675
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T19:31:09+00:00 2026-06-12T19:31:09+00:00

Is there any Zend Helper that can make PDF document with tables. i need

  • 0

Is there any Zend Helper that can make PDF document with tables.
i need to pass result of my Query and the helper will return a PDF document with data in a table.
Just like the below Csv Helper.

what i did here is that i put the given class in

Zend/Controller/Action/Helper

and than in my Action i do so

    public function getcsvAction() {
    $this->_helper->layout()->disableLayout();
    $this->_helper->viewRenderer->setNeverRender();
    try{
        $clModel = new Application_Model_DbTable_Mytable();
        $select = $clModel->clCSV());
        $this->_helper->Csv($select, "genertadfile name");
    }catch(Exception $e){
        echo 'Oops! Something went wrong.';
    }
    exit;
 }

and this the class

  <?php


// Zend_Controller_Action_Helper_Csv

class Zend_Controller_Action_Helper_Csv extends Zend_Controller_Action_Helper_Abstract{


public function direct($aryData = array(), $strName = "csv", $bolCols = true){
    $this->printExcel($aryData, $strName, $bolCols);
     }


  public function printExcel($aryData = array(), $strName = "csv", $bolCols = true){
          if (!is_array($aryData) || empty($aryData)){  exit(1); }

// header
    header('Content-Description: File Transfer');
    header('Content-Type: text/csv; charset=utf-8');
    header("Content-Disposition: attachment; filename=" . $strName . "-export.csv");
    header('Content-Transfer-Encoding: binary');
    header('Expires: 0');
    header('Cache-control: private, must-revalidate');
    header("Pragma: public");

    if ($bolCols){
      $aryCols = array_keys($aryData[0]);
      array_unshift($aryData, $aryCols);
       }
      ob_start();

    $fp = fopen("php://output", "w");
     if (is_resource($fp)){
   foreach ($aryData as $aryLine)  {
    fputcsv($fp, $aryLine, ',', '"');
        }
$strContent = ob_get_clean();

   $strContent = preg_replace('/^ID/', 'id', $strContent);
   $strContent = utf8_decode($strContent);
   $intLength = mb_strlen($strContent, 'utf-8');

header('Content-Length: ' . $intLength);
echo $strContent;
    exit(0);
}
ob_end_clean();
exit(1);
 }
   }
?>
  • 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-12T19:31:11+00:00Added an answer on June 12, 2026 at 7:31 pm

    There is a official module for pdf on zend framework 2: zendpdf

    You can install it by adding zendframework/zendpdf to your composer.json file.

    Its not finnished yet, that why you can’t find any information about it. You can find here the previous documentation… just look for zend.pdf.*.rst files.

    There is a ZF2 module for the DOMPDF library too. Find more info here. The code you can finde here. Easy installation by adding "dino/dompdf-module": "dev-master" to your composer.json file.

    ADDING:

    DOMPDF can be used like this:

    public function dompdfAction()
    {
        return new DOMPDFModule\View\Model\PdfModel\PdfModel(
            array(), // Variable assignments per Zend\View\Model\ViewModel
            array(
                'fileName' => 'monthly-report', // Optional; triggers PDF download, automatically appends ".pdf"
                'paperSize' => 'a4',
                'paperOrientation' => 'landscape'
            )
        );
    }
    

    It will generate an pdf file for the dompdfAction’s viewscript.

    ZendPdf can be used like this:

    public function pdfAction()
    {
        $pdf = new \ZendPdf\PdfDocument();
    
        $pdf->pages[] = ($page = $pdf->newPage(\ZendPdf\Page::SIZE_A4));
        $font = \ZendPdf\Font::fontWithName(\ZendPdf\Font::FONT_HELVETICA);
        $page->setFont($font, 36);
        $page->drawText('<h1>html não funciona...</h1>', 10, 536, 'utf-8');
        $page->drawText('PDF FUNCIONA', 10, 500, 'utf-8');
        $image = \ZendPdf\Image::imageWithPath('public/images/zf2-logo.png');
        $page->drawImage($image, 100, 100, 400, 300);
        $pdf->save("teste.pdf");
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any way I can set a formatter on models that will convert
i have an query in mysql zend framwork is there any other way of
Is there any way we can fetch X509 Public Cetrificates using c# from AD
is there any way to get an Action Helper from an Service Class? I
is there any way to tell the Zend Framework Router: if www.domain.com/test is called
Is there any way in Zend Framework to grab the url of the page
is there any way to Query the Index of Zend_Search_Lucene for an exact match
Is there any way to create data objects for MySQL database tables using Zend_Tool
In Zend Framework, baseUrl adds path as '/user/local/path_tyo_file' . Is there any function which
Is there any point in having both? I followed a Zend tutorial which told

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.