function nvpdf_WrapString($my_pdf,$string,$width,$width_in_chars = "") {
// known problem: can only be called after the pdf document has been
// started, font size set, etc as it relies on the pdf being in the
// page scope to use pdf_stringwidth (see PDFLib manual p.83).
// returns an array: 1st level column
// 2nd level data string broken up into lines that fit the column
$string = str_replace('\n', "\n", $string);
$inlines = explode("\n",$string);
$outlines = array();
$font_size = PDF_get_option($my_pdf, "fontsize", "");
$font_name = pdf_get_parameter($my_pdf, "fontname", 0);
$font_id = PDF_load_font($my_pdf, $font_name, "host","");
我收到了来自php的反对警告,说我应该使用pdf_get_option()而不是pdf_get_parameter()。但是如何将这个pdf_get_parameter()转换为pdf_get_option()呢?
我需要一个方法,将返回我的字体名称的$mypdf。
发布于 2022-11-06 06:30:01
找到解决办法了。pdf_get_option()不会给我字体名。我所要做的就是使用pdf_info_font(),然后使用pdf_get_string()来获取fontname。
发布于 2022-11-07 07:34:05
很高兴你能自己找到解决方案。
另一个简短的注意事项是:如果您已经为PDFlib函数找到了一个不推荐的警告,那么建议您替换它,即使该功能在您正在使用的版本中仍然有效。这是因为在更新时,不推荐的函数可能不再可用。
当前的PDFlib 9和10包包括一个PDFlib迁移指南,其中详细描述了所有必要的更改。
您还可以在PDFlib 网站pdflib.com上找到最新的网站pdflib.com。
对于这一特定问题,你可以在第2.1章表2.3中找到解释:
deprecated parameter:
ascender, ascenderfaked, capheight, capheightfaked, descende,
descenderfaked, fontencoding, fontname,fontmaxcode, xheight, xheightfaked
deprecated since:
PDFlib 7
replacement method and option:
PDF_info_font( ) with same-named keywords; for the numerical
values fontsize=1 must be supplied;
parameter fontencoding: use keyword encoding
PDFlib烹饪书信息“中也提供了一个示例用法。
/* Get the font name: use "api" to get the font name used by PDFlib.
* (use "acrobat" for the Acrobat font name or use "full" for
* retrieving the full font name)
*/
$p->fit_textline("fontname (api):", $x, $y-=$yoffset, "");
$info = $p->info_font($font, "fontname", "api");
if ($info > -1) {
$fontname = $p->get_string($info, "");
$p->fit_textline($fontname, $xindent, $y, "");
}
https://stackoverflow.com/questions/74333500
复制相似问题