Giter Club home page Giter Club logo

Comments (3)

Lucas-C avatar Lucas-C commented on July 18, 2024

@gmischler: this seems related to the text regions / paragraph rendering logic: would you like to have a look at this? 🙂

from fpdf2.

gmischler avatar gmischler commented on July 18, 2024

@gmischler: this seems related to the text regions / paragraph rendering logic: would you like to have a look at this? 🙂

I think it has always behaved like this. Of course, that's no reason to keep it that way...

There are several possible solutions to this:

  • Create a dedicatet ListParagraph() subclass to Paragraph() with a new_item(bullet="\u25cf"). The bullet could be any unicode character, a number, or a string (eg. "22.7(5)"), or the int type for automatic numbering. That last feature would be the advantage of this approach. The disadvantage is the higher complexity of both the implementation and the API. It gets even more hairy if we want automatic hierarchical numbering.

  • Add a indent argument to Paragraph(). We probably need that anyway for other purposes. If we combine that with a bullet argument (like above minus the automatic counting), then we already have the building blocks to create all kinds of lists. The disadvantage here is that the client code needs to handle the item numbering of ordered lists. The big advantage is the simplicity and flexibility. It might actually be possible to build an automatic numbering system on top of this later.

I'm currently still busy with other stuff, but I don't think this should be very hard if anyone wants to try.

from fpdf2.

dmail00 avatar dmail00 commented on July 18, 2024

There must be a reason, however I am not aware and maybe either of you could enlighten me.

<ol>, <ul> and <blockquote> all create paragraphs and pdf has an l_margin. Why not keep a stack of l_margins and push onto it each time you see one of these tags and call pdf.set_left_margin with pdf.l_margin + (indent * modifier). Each time you see the end tag, pop the l_margin off the stack and again call pdf.set_left_margin with this value,

This solves all of these issues and I have been using this code without encountering any issues* so far, however as I said maybe there is something I am not aware off that makes this a bad idea.

*It does require modification of li elements so that it continues to use the current indent method when not inside a list.

from fpdf2.

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.