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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T20:15:11+00:00 2026-05-26T20:15:11+00:00

I am having an issue with generating pdf documents. My tabulator characters are not

  • 0

I am having an issue with generating pdf documents. My tabulator characters are not displayed properly. I already tried different fonts, or encodings (UTF-8, Windows1552).
With some fonts the character is completely hidden. With some I get a square symbol displayed instead of my tab “\t”.

Here is my code.

The question is “How to display tabs using Zend_PDF?”

public function generate()
{
    $pdf        = new Zend_Pdf();
    $page       = new Zend_Pdf_Page( Zend_Pdf_Page::SIZE_A4 );

    //render basic template
    $template   = Zend_Pdf_Image::imageWithPath( APPLICATION_PATH . '/resources/pdf/template.png' );
    $page->drawImage( $template, 0 ,0, 595, 842 );

    //render document title     
    $font = Zend_Pdf_Font::fontWithPath( APPLICATION_PATH . '/resources/pdf/arial-bold.ttf' );
    $page   ->setFont($font, 14)                
            ->drawText( 'Rechnung', 390, 700, 'utf-8' );

    //render reciever adress
    $font = Zend_Pdf_Font::fontWithPath( APPLICATION_PATH . '/resources/pdf/arial.ttf' );



    $adressText = array( 
        'Kundennummer' . "\t" . $this->_user->getUserIdString(),
        'Belegnummer' . "\t" . $this->_payin->getPayinIdString(),
        'Datum' . "\t\t\t" . $this->_payin->getDateCreated()->format( 'd.m.Y' ),
        'Seite' . "\t\t\t" . '1/1'
    );

    $page   ->setFont($font, 12);
    $adressY  =  680;

    foreach( $adressText as $line )
    {
        $page->drawText( $line, 390, $adressY , 'utf-8' );
        $adressY -= 12;
    }


    //add page to pdf document
    $pdf->pages[] = $page;

    //save pdf
    $pdf->save( $this->getOption( 'path' ) );   
}
  • 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-05-26T20:15:12+00:00Added an answer on May 26, 2026 at 8:15 pm

    It could be that the pdf doesn’t understand \t.


    Try replacing it with ‘chr(9)’ which is the ascii value of the tab character. For example:-

    $tab = chr(9);
    $adressText = array(
    ‘Kundennummer’ . $tab . $this->_user->getUserIdString(),
    ‘Belegnummer’ . $tab . $this->_payin->getPayinIdString(),
    // etc..
    );

    Correction:
    As you have to supply the x,y coordinates to Zend_Pdf_Page::drawText() things like tabs, line feeds, etc will not work.
    You will have to set fixed coordinates for your tab stops.

    For example:-

    $tabs = array(5, 20, 30, 50);
    $page->drawText("At 1st tab", $tabs[0], 10);
    $page->drawText("At 2nd Tab", $tabs[1], 10);
    $page->drawText("At 3rd Tab", $tabs[2], 10);
    

    Hopefully you get the idea.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having an issue with my ASHX handler that is generating PDF. When
Having an issue here that I have tried everything I can think of but
I'm having an issue with a Flash/Flex erroring in Firefox but not IE. I
having an issue generating random numbers in a loop. Can get around it by
I am generating dynamic PDF reports in PHP and having some issues with links
I'm having an issue when trying to programmatically update a DateTime field that already
Im having an issue with areas and generating links from them. Here's the rough
I am having an issue with MVC-3 generating outgoing routes for me. This is
i'm having a issue with the T4 templates for generating code. I'm wondering if
I am having a formatting issue with PDF generation with TCPDF in CakePHP. It

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.