PHP Handbuch
Zurück |  | Weiter

# LIII. Haru PDF Functions

# Einführung

The PECL/haru extension provides bindings for Haru Free PDF Library - free, cross platform, opensource software library for generating PDF files.

You can find the library here: http://libharu.sourceforge.net.

Warnung
Diese Erweiterung ist EXPERIMENTELL. Das Verhalten dieser Erweiterung, einschließlich der Funktionsnamen, und alles Andere was hier dokumentiert ist, kann sich in zukünftigen PHP-Versionen ohne Ankündigung ändern. Seien Sie gewarnt und verwenden Sie diese Erweiterung auf eigenes Risiko.

# Anforderungen

You need to install libharu first to be able to use PECL/haru. PECL/haru is tested with libharu 2.0.8, older versions might or might not work for you. PECL/haru also requires PHP 5.1.3 or newer.

# Installation

Zusätzliche Informationen, wie neue Releases, Downloads Quelldateien, Maintainerinformation und ein CHANGELOG finden Sie hier: http://pecl.php.net/package/haru.

The latest PECL/haru Win32 DLL can be downloaded here: php_haru.dll.

# Laufzeit Konfiguration

Diese Erweiterung definiert keine Konfigurationseinstellungen in der `php.ini`.

# Beispiele

Beispiel 1. Basic PECL/haru example

`<?php
$doc = new HaruDoc;
$doc->setPageMode(HaruDoc::PAGE_MODE_USE_THUMBS); /* show thumbnails */
$page = $doc->addPage(); /* add page to the document */
$page->setSize(HaruPage::SIZE_A4, HaruPage::LANDSCAPE); /* set the page to use A4 landscape format */
$courier = $doc->getFont("Courier-Bold"); /* we'll use the bundled font a few lines below */
$page->setRGBStroke(0, 0, 0); /* set colors */
$page->setRGBFill(0.7, 0.8, 0.9);
$page->rectangle(150, 150, 550, 250); /* draw a rectangle */
$page->fillStroke(); /* fill and stroke it */
$page->setDash(array(3, 3), 0); /* set dash style for lines at this page */
$page->setFontAndSize($courier, 60); /* set font and size */
$page->setRGBStroke(0.5, 0.5, 0.1); /* set line color */
$page->setRGBFill(1, 1, 1); /* set filling color */
$page->setTextRenderingMode(HaruPage::FILL_THEN_STROKE); /* fill and stroke text */
/* print the text */
$page->beginText();
$page->textOut(210, 270, "Hello World!");
$page->endText();
$doc->save("/tmp/test.pdf"); /* save the document into a file */
?>`

Open the result document in your favourite PDF viewer and you should see a light-blue rectangle and white "Hello World!" on it.

# Vordefinierte Klassen

HaruException
HaruDoc
HaruPage
HaruFont
HaruImage
HaruEncoder
HaruOutline
HaruAnnotation
HaruDestination

# Builtin Fonts And Encodings

## Builtin Fonts

These Base14 fonts are built-in into PDF and all viewers can display them. Using these fonts may decrease the size of the result file and make the processing faster, avoiding loading external fonts. However the fonts support only latin1 character set and you have to load external fonts if you need to use an other character set.

The Base14 fonts:

- Courier

- Courier-Bold

- Courier-Oblique

- Courier-BoldOblique

- Helvetica

- Helvetica-Bold

- Helvetica-Oblique

- Helvetica-BoldOblique

- Times-Roman

- Times-Bold

- Times-Italic

- Times-BoldItalic

- Symbol

- ZapfDingbats

## Builtin Encodings

Tabelle 1. Single-byte character set encodings

Name | Description
--- | ---
StandardEncoding | The default encoding of PDF.
MacRomanEncoding | The standard encoding of Mac OS.
WinAnsiEncoding | The standard encoding of Windows.
FontSpecific | The font built-in encoding.
ISO8859-2 | Latin2 (East European)
ISO8859-3 | Latin3 (South European)
ISO8859-4 | Latin4 (North European)
ISO8859-5 | Cyrillic
ISO8859-6 | Arabic
ISO8859-7 | Greek
ISO8859-8 | Hebrew
ISO8859-9 | Latin5 (Turkish)
ISO8859-10 | Latin6 (Nordic)
ISO8859-11 | Thai
ISO8859-13 | Latin7 (Baltic Rim)
ISO8859-14 | Latin8 (Celtic)
ISO8859-15 | Latin9
ISO8859-16 | Latin10
CP1250 | MS Windows Codepage 1250.
CP1251 | MS Windows Codepage 1251.
CP1252 | MS Windows Codepage 1252.
CP1253 | MS Windows Codepage 1253.
CP1254 | MS Windows Codepage 1254.
CP1255 | MS Windows Codepage 1255.
CP1256 | MS Windows Codepage 1256.
CP1257 | MS Windows Codepage 1257.
CP1258 | MS Windows Codepage 1258.
KOI8-R | Cyrillic character set.

Tabelle 2. Multi-byte character set encodings

Name | Description
--- | ---
GB-EUC-H | EUC-CN encoding.
GB-EUC-V | Vertical writing version of GB-EUC-H.
GBK-EUC-H | Microsoft Code Page 936 (lfCharSet 0x86) GBK encoding.
GBK-EUC-V | Vertical writing version of GBK-EUC-H.
ETen-B5-H | Microsoft Code Page 950 (lfCharSet 0x88) Big Five character set with ETen extensions.
ETen-B5-V | Vertical writing version of ETen-B5-H.
90ms-RKSJ-H | Microsoft Code Page 932, JIS X 0208 character.
90ms-RKSJ-V | Vertical writing version of 90ms-RKSJ-V.
90msp-RKSJ-H | Microsoft Code Page 932, JIS X 0208 character (proportional).
EUC-H | JIS X 0208 character set, EUC-JP encoding.
EUC-V | Vertical writing version of EUC-H.
KSC-EUC-H | KS X 1001:1992 character set, EUC-KR encoding.
KSC-EUC-V | Vertical writing version of KSC-EUC-V.
KSCms-UHC-H | Microsoft Code Page 949 (lfCharSet 0x81), KS X 1001:1992 character set plus 8822 additional hangul, Unified Hangul Code (UHC) encoding (proportional).
KSCms-UHC-HW-H | Microsoft Code Page 949 (lfCharSet 0x81), KS X 1001:1992 character set plus 8822 additional hangul, Unified Hangul Code (UHC) encoding (fixed width).
KSCms-UHC-HW-V | Vertical writing version of KSCms-UHC-HW-H.

Zurück | Zum Anfang | Weiter
gopher_parsedir | Nach oben | HaruException