Landscape PDF Odd Behaviour

Hi All,

I am currently producing a pdf report for my module to allow a list of items and information about them. This works fine when the pdf is in portrait, however when I set the pdf parameters for landscape, I get a random line or lines (sometimes 2 or 3 out of 24 lines) that prints each column on a new page.

I thought I would see what happens with the core docs, and so I changed the standard expense report template to landscape and the same thing happens.

Does anyone have any idea what is going on with this?

Thanks in Advance,

Matt

Hi Matt,

Your problem is that you have a page overflow, which TCPDF overcomes by adding a page. If you have a series of writes (like in pdf_writelinedesc) it will be adding a page after each write call. That 's why you need to check properly for these overflows and rollback where necessary.

Regards,
Marc

Hi Marc,

Thank you for the response. I understand that the transaction has to be rolled back, but the problem is that you can only have one column as it stands to get the height from, so for example if you check the height of columns a but column b is longer and spills to a second line, you get the unexpected results.

I have previously tried storing the y value of each column in an array and returning the max number as the $posyafter variable, but for some reason this doesnt work.

I will try and write a separate function writing each column and rolling back individually today and let you know how I get on and leave a copy of the code here.

Many thanks,

Matt

Hi Marc,

Thank you for the response. I understand that the transaction has to be rolled back, but the problem is that you can only have one column as it stands to get the height from, so for example if you check the height of columns a but column b is longer and spills
to a second line, you get the unexpected results.

I have previously tried storing the y value of each column in an array and returning the max number as the $posyafter variable, but for some reason this doesnt work.

I will try and write a separate function writing each column and rolling back individually today and let you know how I get on and leave a copy of the code here.

Many thanks,

Matt

Kind regards,

Matthew Sidnell

Director

Mobile: +44 (0) 7876 570 569

Phone: +44 (0) 1225 413 125

Email: matt@pstructures.com

www.pstructures.com

The information in this email is confidential and solely for the use of the intended recipient(s). If you receive this email in error, please notify the sender and delete the email from your system immediately. In such circumstances, you must not make any use
of the email or its contents. Views expressed by an individual in this email do not necessarily reflect the views of Professional Structures Limited. Computer viruses may be transmitted by email. Professional Structures Limited accepts no liability for any
damage caused by any virus transmitted by this email. E-mail transmission cannot be guaranteed to be secure or error-free. It is possible that information may be intercepted, corrupted, lost, destroyed, arrive late or incomplete, or contain viruses. The sender
does not accept liability for any errors or omissions in the contents of this message, which arise as a result of e-mail transmission

Hi @simicar,

I have today tried to add a function to calculate the Y position of the highest cell in the row, but cannot for the life of me make it work. I have attached a copy of the pdf and the code which is hosted on pastebin.

I understand the problem that it is writing each cell to a new page as per the loop, but I cannot figure out for the life of me how to rectify it. Could you please help me get this sorted as it is the last thing I need to do for the module.

Code Link: https://pastebin.com/5rmML0mJ Page Images.zip (484.0 KB)

Many thanks,

Matt

Hi Matt,
I am willing to help you but won’t be available this afternoon. Is that ok for early next week ?
Your approach to compute the height is good of course, but you could spare that part. The point here is that we go down till we reach the bottom minus space for totals, then we continue till the real bottom. That’s where the checking, and thus roll back, is not performed correctly. If that makes sense to you and make you find the solution, great and let me know, otherwise I will look at your code as soon as I have spare time.
Regards,
Marc

Hi Marc,

That is great, thank you so much. I kind of ended up going down a rabbit hole with it all really. The crazy thing is I do understand the problem, but can’t seem to find a solution for it. I have spent days and days on it and have not really gotten any further with it.

Next week is great, anytime you can help really, and if there is anything I can do for you, please let me know.

Matt