Deprecated: The each() function is deprecated. This message will be suppressed on further calls in /home/zhenxiangba/zhenxiangba.com/public_html/phproxy-improved-master/index.php on line 456
PHP: PDF_stringwidth - Manual
[go: Go Back, main page]

PHP
downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | my php.net

search for in the

PDF_stroke" width="11" height="7"/> <PDF_skew
Last updated: Wed, 01 Nov 2006
view this page in

PDF_stringwidth

(PHP 3 >= 3.0.6, PHP 4, PECL)

PDF_stringwidth -- テキストの幅を返す

説明

float PDF_stringwidth ( resource p, string text, int font, float fontsize )

任意のフォントにおける text の幅を返します。



add a note add a note User Contributed Notes
PDF_stringwidth
rross at mNoOoSnPsAoMfvega dot com
10-Nov-2005 09:27
One thing I came across, and hope is useful to someone, is the following.
If you're looking to use the pdf_stringwidth() function, and expecting it to give you the proper results when trying to center or position the text, try to avoid using this line in your code:

<?
   pdf_set_parameter
($pdf, "textformat", "utf8");
?>

I discovered (after much hair-pulling of what remains of my hair) that this line of code increases the amount of space between characters by roughly 100%.  Removing this line of code made the text on my generated PDF's significantly tighter and more appealing.
smilingrasta FROM gmx dot net
20-Jul-2005 01:42
With upgrading to PHP5, i had to switch to a newer version of pdflib (v6), where some functions slightly differ from the old version(v5).

The new parameters for this function are:
<?php float PDF_stringwidth(PDF *p, const char *text, int font, float size); ?>

pdf_stringwidth() does only take 2 parameters in the old version.
Now 5 parameters are required. As they aren't listed here, i thought i could do that :>

<?php
# first, we have to find the font, we are using
$fontID = pdf_findfont($pdf, 'Courier', 'host', 0);
# then we can call pdf_stringwidth                                                 
$width = pdf_stringwidth($pdf,$string, $fontID, $fontsize));
?>

Maybe that helps someone out.
farzal at hotmail dot com
27-Jul-2001 09:51
with font COURIER and fontsize of 12, you can print 10 CPI (Characters per inch) or 1 character every 7.2 points.

This means, on an A4 page of size (595,842), with a printable area of (451,662) after leaving 1" blank on each side, one can print 451/7.2 ~= 62 characters.

If one is building tables after quering databases, this is a way to figure out if you can print all your columns in a page, or if you need to use landscape, or if you need to reduce the font size.

PDF_stroke" width="11" height="7"/> <PDF_skew
Last updated: Wed, 01 Nov 2006
 
 
show source | credits | sitemap | contact | advertising | mirror sites