tecnickcom / TCPDF

Official clone of PHP library to generate PDF documents and barcodes
https://tcpdf.org
Other
4.18k stars 1.51k forks source link

WriteHTML issue when using it on Footer function #626

Open shawe opened 1 year ago

shawe commented 1 year ago

When you have a body of a document long enough to occupy several pages, if you want the Footer function to be dynamic in height showing one content or another (for example, the totals of an invoice), if the last page requires a line break it does, but when writing the footer with the totals in a HTML table, the portion that page break returns to the previous one.

If you use a Cell instead of WriteHTML to representen a cell with the same block size, this problem doesn't happens.

image

image

I try to found more exactly what is happening, and seems to be a problem related on how WriteHTML works, and seems to not be in mind to be used on Footer.

Maybe and additional function to be used on Footer, or maybe a WriteHTML with an extra param to avoid page break may work.

I get this working, but only using Cell function with a specific text blocks on footer, and replacing the totals of the invoice to the final page. But I want to have it with a user option to be used on any page or only last page and I can't do that.

williamdes commented 1 year ago

I think it's best to ask on websites like StackOverflow, here is not a support forum :) But let us know about your findings, you can also post here the link to the StackOverflow post

shawe commented 1 year ago

I think it's best to ask on websites like StackOverflow, here is not a support forum :) But let us know about your findings, you can also post here the link to the StackOverflow post

Are you sure the code is not wrong with that? Because I can confirm that it is.

WriteHTML can't be used in footer, and is not documented anywhere, then it can be used. If you would to use dynamic footer height per page because WriteHTML causes new page if you use it on footer with a never ending problem.

The issues goes here not in stackoverflow.

Search in writeHTML function, and look for the breakpage that affects to use it on footer.

williamdes commented 1 year ago

I think it's best to ask on websites like StackOverflow, here is not a support forum :) But let us know about your findings, you can also post here the link to the StackOverflow post

Are you sure the code is not wrong with that? Because I can confirm that it is.

WriteHTML can't be used in footer, and is not documented anywhere, then it can be used. If you would to use dynamic footer height per page because WriteHTML causes new page if you use it on footer with a never ending problem.

The issues goes here not in stackoverflow.

Search in writeHTML function, and look for the breakpage that affects to use it on footer.

Well, sorry for my misdiagnosis then I am not enough skilled to correctly reply on this code base, clear code crashes are easier to fix Most probably @nicolaasuni could but I doubt he has time The best would be that you debug this issue in the tcpdf code and let us know what you find and maybe propose a bug fix

I am not affiliated with tcpdf, but prefer to reply on new issues because you most probably will have no other reply The project is not dead but is in very low maintenance mode and there is nobody assigned to support So I try my best with the time I have to reply on issues :)

I hope my reply helps you understand

shawe commented 1 year ago

I think it's best to ask on websites like StackOverflow, here is not a support forum :) But let us know about your findings, you can also post here the link to the StackOverflow post

Are you sure the code is not wrong with that? Because I can confirm that it is. WriteHTML can't be used in footer, and is not documented anywhere, then it can be used. If you would to use dynamic footer height per page because WriteHTML causes new page if you use it on footer with a never ending problem. The issues goes here not in stackoverflow. Search in writeHTML function, and look for the breakpage that affects to use it on footer.

Well, sorry for my misdiagnosis then I am not enough skilled to correctly reply on this code base, clear code crashes are easier to fix Most probably @nicolaasuni could but I doubt he has time The best would be that you debug this issue in the tcpdf code and let us know what you find and maybe propose a bug fix

I am not affiliated with tcpdf, but prefer to reply on new issues because you most probably will have no other reply The project is not dead but is in very low maintenance mode and there is nobody assigned to support So I try my best with the time I have to reply on issues :)

I hope my reply helps you understand

My alternative option was don't put this information in the footer, because the problem is on WriteHTML and the automatic page break.

I change this little table to outside the footer zone and all works without problems on the body zone. It's the expected solution? No, but at least, it's working.

Seems that by design, header and footer are not expected to use WriteHTML. This way is used in all the samples provided.

My footer and header were changing it's height based on user configuration. Both parts seems that are working good (maybe requires some improvements, but it is reasonable).

I add a function to check if I'm in first or last page. The users can enable 2 sub-section on the header, and 2 sub-section in the footer based on:

WriteHTML is always trying to verify that the table is inside the body, not in the header and not in the footer, but table it's in the footer.

Why I want this table on the footer? Because its the total of an invoice, an seems the best place for all common templates. Now I'm positioning the Y to the similar expected coordinate before the table.

But this is a workaround for a limitation in TCPDF. For this reason I don't want to go to StackOverflow. I know how to avoid this problem, but still it's a problem.

I have not found any other easy way to get around this problem, other than restating the solution in another way that involves not using the footer.

For me the solution applied is working, but I still think that this is needed to have more control on what you want to use.

drajar commented 4 months ago

see this: https://github.com/tecnickcom/tcexam/issues/425#issuecomment-2143490823