openhtmltopdf icon indicating copy to clipboard operation
openhtmltopdf copied to clipboard

Table data out of page range

Open xu-weize opened this issue 4 years ago • 4 comments

Hi,There is a question that i want to ask .Now,I shortly describe the scene:There is a table label on my html page ,and the table column is 9 .When column data is short, the pdf export the page looks ok.But When the data long than before,the data out of page. The question is how to controller the page width and the data looks normal on the pdf page.

xu-weize avatar Nov 25 '20 02:11 xu-weize

Hi @xu-weize , could you provide a sample html page?

To be noted, you can also change the page size with: https://github.com/danfickle/openhtmltopdf/wiki/Page-features if your data don't fit your table .

syjer avatar Nov 25 '20 21:11 syjer

@syjer I guess this issue is related to #578 . Even the fix code suggested in #578 doesn't always work. If the table has very big number of columns, the getMaxWidth method doesn't return the maximum box width in the page.

private float getMaxWidth(Box box) {
    float maxWidth = 0;
    maxWidth = Math.max(maxWidth, box.getWidth());
    for (int i = 0; i < box.getChildren().size(); i++) {
        maxWidth = Math.max(maxWidth, getMaxWidth(box.getChild(i)));
    }
    return maxWidth;
}

I guess there should be a way to auto fit/scale the content inside any page size.

Another related issue #189 .

abozanona avatar Nov 26 '20 06:11 abozanona

Hi @abozanona,

Have you taken into account the page margins? Also, the cut-off page support outlined in the wiki may be an option. I'm going to start working on built-in scaling and auto-page enlargement solutions after the next release.

danfickle avatar Nov 27 '20 11:11 danfickle

Are there any updates on this?

sm3sher avatar Dec 17 '21 13:12 sm3sher