Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WriteHTML issue when using it on Footer function #626

Open
shawe opened this issue Jun 5, 2023 · 5 comments
Open

WriteHTML issue when using it on Footer function #626

shawe opened this issue Jun 5, 2023 · 5 comments

Comments

@shawe
Copy link

shawe commented Jun 5, 2023

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
Copy link
Contributor

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
Copy link
Author

shawe commented Jun 27, 2023

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
Copy link
Contributor

williamdes commented Jun 27, 2023

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
Copy link
Author

shawe commented Jun 27, 2023

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:

  • All pages (header and footer)
  • Only on first page (header)
  • Only on last page (footer)
    Based on this I have 4 posible sizes, that was working well without problems using cells without HTML. But when you require HTML code, all problem starts.

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
Copy link

drajar commented Jun 1, 2024

see this: tecnickcom/tcexam#425 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants