Giter Site home page Giter Site logo

Draw Straight Line about pdfme HOT 2 CLOSED

afelipesp avatar afelipesp commented on September 27, 2024
Draw Straight Line

from pdfme.

Comments (2)

aFelipeSP avatar aFelipeSP commented on September 27, 2024

Hi @sheneeb, it's great you are using the library!

For this you can use a table in the footer like this:

from random import randint

from pdfme import build_pdf

char = lambda: chr(randint(97, 122))
word = lambda low=2, high=10: ''.join(char() for _ in range(randint(low, high)))
text = lambda length, low=2, high=10: ' '.join(word(low, high) for _ in range(length))

document = {
    "style": {"text_align": "j"},
    "running_sections": {
        "footer": {
            "x": "left", "y": 800, "height": "bottom",
            "style": {"text_align": "c"},
            "content": [
                {
                    "style": {"border_width": 0, "cell_margin": 0},
                    "borders": [
                        {"pos": "h0;:", "width": 0.5}
                    ],
                    "table": [[
                        {".": ["Report Date: ", {".i": "31-Dec-21"}]},
                        {".": ["Page ", {"var": "$page"}]},
                        {".": ["Internal Audited by:"]}
                    ]]
                }
            ]
        }
    },
    "sections": [
        {
            "running_sections": ["footer"],
            "content": [{".": text(1000)}]
        }
    ]
}

with open('document.pdf', 'wb') as f:
    build_pdf(document, f)

In the table's dict I'm including a style key with a border_width of 0 to make all of the lines in the table desappear and cell_margin of 0 to reduce the margin of the cells, to make the text closer to the lines.

Later in table's borders list key I added a dict to make the top border different to the default one I set in border_width. For more information on how to override the default border and fill configuration set in table's style go to https://pdfme.readthedocs.io/en/latest/modules/table.html#pdfme.table.PDFTable .

from pdfme.

sheneeb avatar sheneeb commented on September 27, 2024

Thank you for your quick response , your active support is greatly appreciated.

from pdfme.

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.