#233 Split TCPDF class into manageable file sizes/subclasses

Kat R.

Request 2082188 was opened four years ago with a similar request. In that time, the class has tripled in size to 30,000 lines and a single file over 1M.

The sheer size of the file, combined with the number of class properties, methods, and constants, poses problems even for the newest IDEs, and it's proven that large files are difficult for even the best programmers to maintain a handle on.

I have only begun to use TCPDF in a project, however my suggestion for splitting would be along the configuration/generation line. These are two distinctly different pieces of code that are currently intermixed, which makes it difficult for end-users to easily understand which pieces they should be using and which they (ostensibly) shouldn't (without a good deal of back-end knowledge).


  • keith

    keith - 2012-05-15

    Yes, I'm just trying to decipher and make some changes after upgrading and the IDE is very slow and the Code Explorer function list is not working. This makes it very much more difficult to code. Thanks.

  • Lallement Thomas


    I would like add that when the file size exceeds 1M, apc don't cache the opcode (with the default configuration), so there is a lost of benefit of the memory management.

    For example, when APC is enabled:

    1. with TCPDF 5.9.132 (1,047,680 bytes = 0.99 Mb):
      -> BEFORE including TCPDF: 1.7 Mb
      -> AFTER including TCPDF: 3.6 Mb

    2. with TCPDF 5.9.173 (1,070,970 bytes = 1.02 Mb):
      -> BEFORE including TCPDF: 1.7 Mb
      -> AFTER including TCPDF: 14.6 Mb

    It comes from the fact that apc.max_file_size = 1M by default (see http://php.net/manual/fr/book.apc.php)

    So it would be cool to find a way to avoid to exceed this limit. As I know the library is very used in combinaison with APC (with the default configuration).


  • Lallement Thomas

    It would be interesting to externalize the management of SVG or others things just to lighten the weight of the master TCPDF.php source file, like the management of barcode for example.

  • Nicola Asuni

    Nicola Asuni - 2012-07-25

    I understand the problem but I do not have the time to do so.
    Any volunteer?

  • Lallement Thomas

    It would be easier to externalise the management of which part, according to you ?

  • Nicola Asuni

    Nicola Asuni - 2013-03-17

    On the new TCPDF 6 version some methods were converted to static and moved on separate classes. The main TCPDF class is still large and a huge effort is required in order to refactor the entire class.

  • Nicola Asuni

    Nicola Asuni - 2013-03-17
    • status: open --> pending

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks