zafarjonovich / application-filler
此包最新版本(0.0.0.5)没有可用的许可信息。
应用程序填充图像
0.0.0.5
2024-08-26 12:19 UTC
Requires
- php: >=5.6
- intervention/image: ^2.6
README
Assalomu aleykum,这个包可以帮助您使用PHP填写应用程序
例如
您有一个类似这样的应用程序
您必须以编程方式填写它
- 始终坐标头在左上角,坐标以像素为单位进行测量
- 每个文本被分组在一起,组由可写入的行组成
- 每个组可以指定不同的字体,并合并成一个字体对象。字体对象覆盖字体的绝对位置和文本的大小
- 每一行由线条组成,而线条由起始点和结束点组成
- 每个点等于从原点计算出的垂直和水平像素数
我建议您访问以下网站来计算坐标:网站
require_once 'vendor/autoload.php'; use zafarjonovich\ApplicationFiller\element\Font; use zafarjonovich\ApplicationFiller\element\Group; use zafarjonovich\ApplicationFiller\element\Groups; use zafarjonovich\ApplicationFiller\element\Line; use zafarjonovich\ApplicationFiller\element\Lines; use zafarjonovich\ApplicationFiller\element\Point; use zafarjonovich\ApplicationFiller\element\Text; use zafarjonovich\ApplicationFiller\ApplicationFiller; try { $groups = new Groups(); $groups->add( new Group( new Text('x',new Font('ubuntu.ttf',18)), (new Lines()) ->add( new Line(new Point(493,127),new Point(510,127)) ) ) ); $groups->add( new Group( new Text('English, Russian, Uzbek',new Font('ubuntu.ttf',16)), (new Lines()) ->add( new Line(new Point(280,196),new Point(640,196)) ) ) ); $groups->add( new Group( new Text('x',new Font('ubuntu.ttf',18)), (new Lines()) ->add( new Line(new Point(548,265),new Point(650,265)) ) ) ); $groups->add( new Group( new Text('x',new Font('ubuntu.ttf',18)), (new Lines()) ->add( new Line(new Point(548,265),new Point(650,265)) ) ) ); $groups->add( new Group( new Text('x',new Font('ubuntu.ttf',18)), (new Lines()) ->add( new Line(new Point(548,335),new Point(650,335)) ) ) ); $groups->add( new Group( new Text('x',new Font('ubuntu.ttf',18)), (new Lines()) ->add( new Line(new Point(490,402),new Point(510,402)) ) ) ); $largeText = "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum."; $groups->add( new Group( new Text($largeText,new Font('ubuntu.ttf',12)), (new Lines()) ->add( new Line(new Point(120,558),new Point(650,558)) ) ->add( new Line(new Point(120,608),new Point(650,608)) ) ->add( new Line(new Point(120,665),new Point(650,665)) ) ->add( new Line(new Point(120,715),new Point(650,715)) ) ->add( new Line(new Point(120,770),new Point(650,770)) ) ->add( new Line(new Point(120,820),new Point(650,820)) ) ) ); $filler = new ApplicationFiller('application-form.jpg',$groups); $filler->draw(); $filler->image->save('temp.jpg'); } catch (Exception $exception) { echo $exception->getMessage(); }
结果
您可以更改文本对齐方式
$text = new Text("Hello world !",new Font('ubuntu.ttf',12)); $text->setAlignment(Text::ALIGNMENT_MODE_CENTER); $groups->add( new Group( $text, (new Lines()) ->add( new Line(new Point(490,402),new Point(510,402)) ) ) );