maBuJo/pdf-helper

此包的最新版本(1.0.4)没有可用的许可证信息。

与 ZendPdf 一起工作的实用工具

1.0.4 2015-09-24 13:40 UTC

This package is not auto-updated.

Last update: 2024-09-14 18:35:35 UTC


README

ZendPdf 一起工作的实用工具

  • 文本测量
  • 文本在最近长度或指定字符的行中换行

示例用法

<?php

use ZendPdf\PdfDocument;
use ZendPdf\Page;
use ZendPdf\Font;
use ZendPdf\Color\GrayScale;
use Ari\PdfHelper\Paragraph;

$pdf = new PdfDocument();

$page = new Page(Page::SIZE_A4);
$font = Font::fontWithName(Font::FONT_HELVETICA);
$gray = new GrayScale( 0.8 );

$page->setFont( $font, 8 );

$para = new Paragraph( $page, 2 /* line spacing */ );

$para->setDebug( true );
$para->setDebugLineColor( $gray );

$para->draw( $reallyLongTextUnicode, // default encoding assumes UTF-8
	20  /* x position */,
	780 /* y position */,
	240 /* paragraph width */ );

// You can customise the character encoding

$para->setStringFnByte( 'ISO-8859-1' );
$para->setStringFnMultiByte( 'UTF-16BE' );

// You can get the number of lines

$para->getLineCount();

// And the total height in points

$para->getHeight();

// ---

$pdf->pages[] = $page;

header('Content-Type: application/pdf');
echo $pdf->render();