I have created a pdf for a billing application using python's reportlab library. It create a 58mm width pdf of dynamic height as the content changes. When i try to view the pdf it shows me the size accordingly. no extra white spacing is show. But when i try to print it using a 58mm thermal printer I'm not able to print it according to the size of the pdf. It creates more whitespaces which consumes the thermal paper a lot. When i checked for the printer properties it shows size of paper preference as 58 x 210, 58 x 297 and 58 x 3276 only. Can i print this pdf without wasting more paper as it takes dynamic height ? Is there something I'm missing out?
I tried printing but it is consuming more spaces and not getting dynamic height. I tried portrait and landscapes, also i tried size as fit, scale , etc.. but no use.
The thing i was doing was i'll get some list of products from database then i will find how much height it will consume for the products data (it incluse product name, price, qty, amount and also sl no in front). The header and the footer's i have already made it and it will be static so i will have the height of both of them with me. So now the total height of the pdf will be -> Header (static) + Product Data (Dynamic) + Footer (Static). So if the total height lets say 60mm for display all the 3 things then the output pdf i generate will have 58mm x 60mm.
But the problem was when i try to print it, the printing screen (which shows all the stuff like printer, portrait or landscape, scale, pages) which has my printer page preferences as i mentioned above 58 x 210, 58 x 297 and 58 x 3276 mm are only available, lots of whitespace is shown above and below the content. I tried to print it then i got a lot of whitespace above but not below. So i searched a bit and i found that even if there is lot of whitespace below the content the printer will print only till the content + bottom margin so it won't print 210 or 270 or 3276 mm but only till the content and bottom margin.
After all this research finally i created a pdf in reportlab python set the page as c.setPageSize((58.00, 270)). So the output will be a 270mm height of pdf with content starting from above and lots of whitespace till the end (no whitespace above the content). When i print it it printed only till the content + bottom margin. It didn't took the full height. So guys the printer will stop when it reaches the content + bottom margin height not the full height of PDF file. (This is on Thermal Printer)
This was my first ever stack overflow question and I'm the one to answer my own question :), and i got 2 comments on it, so i thank both the people and guys Happy Coding :)