Git Product home page Git Product logo

onegeno-itext-pdf's Issues

请教个关于获取页面已渲染高度的问题

我需要判断上方的内容,如果没有超过一页,那么就要计算补全多少个换行符,才能使右下角的内容在页面最底部显示
image

搜索了很多计算内容渲染高度的方法,但是计算出来与实际不符

就算铺满整页,高度还是返回795.084,但我的页面是A4高度842-20(上下边距)-1(边框宽度)=821
image

private static float getCellHeight(Document doc, Cell cell) {
        Table table = new Table(4);

        table.addCell(cell);

        IRenderer tableRenderer = table.createRendererSubTree().setParent(doc.getRenderer());
        LayoutResult tableLayoutResult = tableRenderer.layout(new LayoutContext(
                new LayoutArea(1, new Rectangle(0, 0,
                                                PageSize.A4.getWidth(),
                                                1e4f
                ))));

        log.info("cell height {}", tableLayoutResult.getOccupiedArea().getBBox().getHeight());
        return tableLayoutResult.getOccupiedArea().getBBox().getHeight();
    }

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.