GithubHelp home page GithubHelp logo

DocumentLayoutException: 'Composed layout generates infinite document.' is thrown when number of invoice detail items is 4967 or over in 'example-invoice' repository about questpdf HOT 4 CLOSED

questpdf avatar questpdf commented on May 8, 2024
DocumentLayoutException: 'Composed layout generates infinite document.' is thrown when number of invoice detail items is 4967 or over in 'example-invoice' repository

from questpdf.

Comments (4)

MarcinZiabek avatar MarcinZiabek commented on May 8, 2024

Hello :) There are two reasons possible behind the DocumentLayoutException.

  1. Some elements in the document structure cannot be successfully rendered because of size constraints. This is sometimes very challenging to detect. In such cases, the results document will have infinite length. There is a special breaker that detects too long documents and throws an exception. Please take a look at the metadata settings and the DocumentLayoutExceptionThreshold parameter.
  2. The second case is when you generate a lot of content and hit the threshold described above. I bet it is what happened in your case. Increasing the threshold will surely help :)

In one of the experimental branches, I am already working on the improvements regarding this exception. When it is thrown, you will get a full elements trace (similar to stack trace) describing all size constraints, rendering types, etc. Such trace will point you where specifically the problem happens. Super useful, yet still requires some work!

from questpdf.

preiius avatar preiius commented on May 8, 2024

You're right, it's DocumentLayoutExceptionThreshold .

I'm surprised it's set so low, but I guess whatever you set it to, someone is going to complain eventually!

As to why exception is thrown intermittently when count is 4967, random comment field at the end sometimes push number of pages to 250.

from questpdf.

MarcinZiabek avatar MarcinZiabek commented on May 8, 2024

This is tricky to decide. I expect/suppose that most users will generate relatively short documents. When this exception happens, the library literally needs to generate so many pages, using processor and memory resources. Therefore, if I set this value really high (let's say 10000 pages), it will be just wasteful.

What about adding a more sophisticated exception message? That describes both cases and let the developer know how to deal with them? E.g. to increase the threshold?

from questpdf.

preiius avatar preiius commented on May 8, 2024

Yes, I thought of that, but I didn't want to take up any more of your free time.

from questpdf.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.