In a catering system, use php to generate a small ticket and store it in the directory. The python script regularly detects the directory. if there is an image, it is sent to the printer for printing. The problem is that the width and height must be specified first for generating images in php, but some orders have more or less dishes, resulting in small orders... in a catering system, use php to generate a small ticket and store it in the directory. The python script regularly detects the directory. if there is an image, it is sent to the printer for printing.
The problem is that the width and height must be specified first for generating images in php, but some orders have more or fewer dishes, resulting in different order ticket content lengths, how can I generate an image for content adaptation in php? I have no clue for a long time. please help me.
Reply content:
In a catering system, use php to generate a small ticket and store it in the directory. The python script regularly detects the directory. if there is an image, it is sent to the printer for printing.
The problem is that the width and height must be specified first for generating images in php, but some orders have more or fewer dishes, resulting in different order ticket content lengths, how can I generate an image for content adaptation in php? I have no clue for a long time. please help me.
AvailableImagettfbbox
To obtain the width and height of the Border generated by the specified text in the ttf font.
It is very simple. assume that the minimum length of a blank menu image is 10 cm. if there is a dish, the image length is increased by 1 cm. Calculate how many dishes are generated.
Then the length can be adaptive.
Image length = minimum length + number of dishes * length to be added for each dish
Calculate the height before generating an image.