php - TCPDF Stretch Text Vertically -


i working on project need texts stretched given sized rectangle. tried imagick there quality losses it.

for example have box sizes 203x78 (any size), , wrote text "lorem ipsum lorem" (any text). want text fit given size 203x78, no matter font-size no matter other things, quality , fit box.

i cound not find method better imagick way: firstly drawing transparent text closest font-size box (sure more little), , drawing image. after that, resizing box size. when resizing it, tried of filter in imagick. there no matter in way except little sized texts. eg. font size 20px , box size bigger draw 1-3px on side. mean, 20px drawn text size 40x18, box 41x20. resizing 41x20 blurred in effect , effect value.

so want create text tcpdf , want resize text fit given size. fitting must fit both horizontal , vertical, totally stretched. chosed pdf because text in pdf in vectoral format , there no losses while resizing size.

tcpdf has horizontal stretch not find way stretch both of sides.

additional infos: using ttf files create text required. transparent png output required. horizontal stretch must not character spacing, behaviors must same vector resizing, adobe illustrator.

illustrator resized texts, size

tries: used php gd bad quality imagick. tried install server php-cairo not it. searched inkscape this, not find way working on command line. tried imagick output > inkscape convert vector, totally fiasco. tried tcpdf output > imagick resize, quality fiacso (imagick has no vector resizing capabilty)

help!

imagemagick cannot used that, because "raster image processor". in anyway, image gonna rasterized before operation (see vector image formats).

i achieved pretty clean inkscape.

first of all, we'll need simple svg file containing text. such file can generated php or other language:

<?xml version="1.0" encoding="utf-8" standalone="no"?> <svg    xmlns:dc="http://purl.org/dc/elements/1.1/"    xmlns:cc="http://creativecommons.org/ns#"    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"    xmlns:svg="http://www.w3.org/2000/svg"    xmlns="http://www.w3.org/2000/svg"    xmlns:sodipodi="http://sodipodi.sourceforge.net/dtd/sodipodi-0.dtd"    version="1.1">   <g>     <text        xml:space="preserve"        style="font-size:40px;               font-style:normal;               font-weight:normal;               line-height:125%;               letter-spacing:0px;               word-spacing:0px;               fill:#000000;               fill-opacity:1;               stroke:none;               font-family:helvetica"        x="0"        y="0"        sodipodi:linespacing="125%"><tspan          sodipodi:role="line"          x="0"          y="0">hello world!</tspan></text>   </g> </svg> 

from there, can change text, font, color... following command line trick (by adjusting -w , -h parameters):

inkscape filename.svg --export-png=filename.png -w800 -h300 --export-area-drawing 

Comments

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -