php教程

Basic PECL/haru example

Example #1 Fancy "Hello world"

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

User Contributed Notes

There are no user contributed notes for this page.

CopyRight © 2008-2022 verySource.Com All Rights reserved. 京ICP备17048824号-1 京公网安备:11010502034788