When using Magento, PDF cuts off after first page

IUlak

Using Magento with Zend_Pdf and a couple of custom classes that allow for the printing/downloading of PDFs with certain header/table specifications. The problem is that it cuts off after the first page and doesn't create a new page when the items list is more than about 20 items.

This code:

public function getOutput()
{

$this->pages[] = $this->page;

return $this->render();

}

And this code:

$pdf = new PrintPdf();
$pdf->generate($sourceData);
$output = $pdf->getOutput();

echo $output;

Are where I believe the error is happening in. If I change the "return" in the first code to "echo" it will output the correct data to the browser, but when I then try and pass it through the second code, it only puts out one page of data.

Any advice would be appreciated as I have been working on this for about 2 weeks.

UPDATE:

I was told this piece of code:

private function drawLineItems($tableData)
    {
        $this->drawHeading($this->__('Line Items'));

        // Draw table
        $this->decOffset(35);
        $this->colorLine(cBLUE);
        $this->page->setLineWidth(0.5);
        $this->page->drawLine($this->pMargin, $this->yOffset, $this->pWidth - $this->pMargin, $this->yOffset);

        $this->fontSize(FONT_SMALL);
        $this->colorFill(cBLUE);

        $this->decOffset(15);

        $sum = ($this->pMargin + 10);
        for($idx = 0; $idx < sizeof($tableData['heading']); $idx++) {
            $pos = $sum;
            $this->page->drawText($tableData['heading'][$idx], $sum, $this->yOffset);
            $sum += ($tableData['width'][$idx] + 10);
            $tableData['width'][$idx] = $pos;
        }

        $this->decOffset(10);
        $this->page->drawLine($this->pMargin, $this->yOffset, $this->pWidth - $this->pMargin, $this->yOffset);

        $this->fontSize(8);
        $this->colorFill(cLIGHT);
        $this->colorLine(cBORDER);

        foreach($tableData['rows'] as $row) {
            $this->decOffset(15);

            $yOffset = $this->yOffset;

            for($idx = 0; $idx < sizeof($row); $idx++) {
                if ($tableData['heading'][$idx] == 'Description') {
                    $lines = $this->_breakTextToLines($row[$idx], $tableData['width'][$idx + 1] - $tableData['width'][$idx]);
                    foreach ($lines as $line) {
                        $this->page->drawText($line, $tableData['width'][$idx], $yOffset);
                        $yOffset -= 10;
                    }
                } else {
                    $this->page->drawText($row[$idx], $tableData['width'][$idx], $this->yOffset);
                }
            }
            $this->decOffset($this->yOffset - $yOffset);
            $this->page->drawLine($this->pMargin, $this->yOffset, $this->pWidth - $this->pMargin, $this->yOffset);
        }

        $this->decOffset(20);
        $this->fontSize(FONT_NORMAL);
        $this->colorFill(cDARK);
        $this->page->drawText($this->__('Grand Total') . ': ' . $tableData['total'], $this->pWidth - 125, $this->yOffset);
    }

is probably where the problem is as it doesn't form a new page after a certain number of items. My problem now lies in accomplishing this task. Help would still be appreciated.

IUlak

I found that adding this code:

if( $this->yOffset < 25){
                $this->yOffset = $this->pHeight - 25;
                $yOffset = $this->yOffset;
                $this->pages[] = $this->page;
                $this->page = $this->newPage(Zend_Pdf_Page::SIZE_A4);
                $this->fontSize(8);
                $this->colorFill(cLIGHT);
                $this->colorLine(cBORDER);
            }

after

$yOffest = $this->yOffset 

in the third part of the code in the question, fixed the problem!

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

jQuery DataTables export pdf cuts off columns

From Dev

File Input cuts off first word

From Dev

Firefox Print HTML page cuts off content

From Dev

CURL cuts off URL after 74 characters

From Dev

StringBuilder cuts off after ~1500 Characters

From Dev

Javascript value cuts off after '&' character

From Dev

AES-256-CFB cuts off message when using `random_iv`

From Dev

AES-256-CFB cuts off message when using `random_iv`

From Dev

Pasting to vim from clipboard cuts off first few lines

From Java

Continuous text in text-area cuts the PDF overflowing the text when using Itext 7.1.7

From Dev

Continuous text in text-area cuts the PDF overflowing the text when using Itext 7.1.7

From Dev

JavaScript output to innerHTML cuts off background image down page

From Dev

When converting first page of a PDF into an image using Ghostscript, sometimes I get "extra" space. Why?

From Dev

Background Image cuts off top of image when scaling

From Dev

Background Image cuts off top of image when scaling

From Dev

ggplot2 cuts off parts of my figure when zooming in

From Dev

SQL CONCAT cuts off last digits when connecting char with float

From Dev

How to redirect to Sign In page after log off while using IdentityServices

From Dev

EditText cuts off text

From Dev

StackPanel cuts off elements

From Dev

Opacity cuts off text

From Dev

EditText cuts off text

From Dev

PDF is blank page when using CGPDFContextCreateWithURL

From Dev

Algolia Magento Extension: Rendering Twice Due to Off-Canvas Menu, Not Using Algolia Results Page

From Dev

Receiving invalid filename error when converting first page of pdf to jpg

From Dev

How to get the first page of a PDF as an image using Carrierwave in rails?

From Dev

Trigger an event when a page loads for the first time and no other time after that

From Dev

SSH session through OpenVPN cuts off / locks up after a few lines

From Dev

UIWebView cuts off bottom of content

Related Related

  1. 1

    jQuery DataTables export pdf cuts off columns

  2. 2

    File Input cuts off first word

  3. 3

    Firefox Print HTML page cuts off content

  4. 4

    CURL cuts off URL after 74 characters

  5. 5

    StringBuilder cuts off after ~1500 Characters

  6. 6

    Javascript value cuts off after '&' character

  7. 7

    AES-256-CFB cuts off message when using `random_iv`

  8. 8

    AES-256-CFB cuts off message when using `random_iv`

  9. 9

    Pasting to vim from clipboard cuts off first few lines

  10. 10

    Continuous text in text-area cuts the PDF overflowing the text when using Itext 7.1.7

  11. 11

    Continuous text in text-area cuts the PDF overflowing the text when using Itext 7.1.7

  12. 12

    JavaScript output to innerHTML cuts off background image down page

  13. 13

    When converting first page of a PDF into an image using Ghostscript, sometimes I get "extra" space. Why?

  14. 14

    Background Image cuts off top of image when scaling

  15. 15

    Background Image cuts off top of image when scaling

  16. 16

    ggplot2 cuts off parts of my figure when zooming in

  17. 17

    SQL CONCAT cuts off last digits when connecting char with float

  18. 18

    How to redirect to Sign In page after log off while using IdentityServices

  19. 19

    EditText cuts off text

  20. 20

    StackPanel cuts off elements

  21. 21

    Opacity cuts off text

  22. 22

    EditText cuts off text

  23. 23

    PDF is blank page when using CGPDFContextCreateWithURL

  24. 24

    Algolia Magento Extension: Rendering Twice Due to Off-Canvas Menu, Not Using Algolia Results Page

  25. 25

    Receiving invalid filename error when converting first page of pdf to jpg

  26. 26

    How to get the first page of a PDF as an image using Carrierwave in rails?

  27. 27

    Trigger an event when a page loads for the first time and no other time after that

  28. 28

    SSH session through OpenVPN cuts off / locks up after a few lines

  29. 29

    UIWebView cuts off bottom of content

HotTag

Archive