Forum und email

Haru PDF Functions

Introductie

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: » https://libharu.sourceforge.net.

Warning

Deze module is EXPERIMENTEEL. Dat betekent, dat het gedrag van deze functies, deze functienamen, in concreto ALLES dat hier gedocumenteerd is in een toekomstige uitgave van PHP ZONDER WAARSCHUWING kan veranderen. Wees gewaarschuwd, en gebruik deze module op eigen risico.

Afhankelijkheden

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.

Installatie

Information for installing this PECL extension may be found in the manual chapter titled Installation of PECL extensions. Additional information such as new releases, downloads, source files, maintainer information, and a CHANGELOG, can be located here: » https://pecl.php.net/package/haru.

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

Configuratie tijdens scriptuitvoer

Deze extensie gebruikt geen configuratie regels.

Voorbeelden

Example#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_A4HaruPage::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(000); /* set colors */
$page->setRGBFill(0.70.80.9);
$page->rectangle(150150550250); /* draw a rectangle */

$page->fillStroke(); /* fill and stroke it */

$page->setDash(array(33), 0); /* set dash style for lines at this page */
$page->setFontAndSize($courier60); /* set font and size */

$page->setRGBStroke(0.50.50.1); /* set line color */
$page->setRGBFill(111); /* set filling color */

$page->setTextRenderingMode(HaruPage::FILL_THEN_STROKE); /* fill and stroke text */

/* print the text */
$page->beginText();
$page->textOut(210270"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.

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

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.
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.

Table of Contents