Php generates food and beverage order ticket images. how does the image length adapt to the content? -Php Tutorial

Source: Internet
Author: User
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.

AvailableImagettfbboxTo 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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.