How to write huge PDF files

246 Views Asked by At

I am using FPDF.
I need to write to the disk every 10 pages or so, otherwise, memory gets exhausted.
How would I do that?
I tried calling the output method ('filename.pdf','F'); in a loop, this does not work.
Any idea how it should look like?

1

There are 1 best solutions below

0
On BEST ANSWER

You'll need to look at the source of FPDF. I'm using TFPDF which I believe is a derivate work of FPDF, but the functions should be the same.

There is one function in particular _out($s)

function _out($s)
{
        // Add a line to the document
        if($this->state==2)
                $this->pages[$this->page] .= $s."\n";
        else
                $this->buffer .= $s."\n";
}

Instead of appending to a buffer as they do in both cases... just fwrite to an open file descriptor of your choice.