Haru PDF

目录

简介

Haru PDF Exception Class.

类摘要

HaruException

class HaruException extends Exception {

/* Inherits */

final public string Exception::getMessage ( void )

final public Throwable Exception::getPrevious ( void )

final public int Exception::getCode ( void )

final public string Exception::getFile ( void )

final public int Exception::getLine ( void )

final public array Exception::getTrace ( void )

final public string Exception::getTraceAsString ( void )

public string Exception::__toString ( void )

final private void Exception::__clone ( void )

}

简介

Haru PDF Document Class.

类摘要

HaruDoc

class HaruDoc {

/* 方法 */

object addPage ( void )

bool addPageLabel ( int $first_page , int $style , int $first_num [, string $prefix = "" ] )

__construct ( void )

object createOutline ( string $title [, object $parent_outline [, object $encoder ]] )

object getCurrentEncoder ( void )

object getCurrentPage ( void )

object getEncoder ( string $encoding )

object getFont ( string $fontname [, string $encoding ] )

string getInfoAttr ( int $type )

int getPageLayout ( void )

int getPageMode ( void )

int getStreamSize ( void )

object insertPage ( object $page )

object loadJPEG ( string $filename )

object loadPNG ( string $filename [, bool $deferred = FALSE ] )

object loadRaw ( string $filename , int $width , int $height , int $color_space )

string loadTTC ( string $fontfile , int $index [, bool $embed = FALSE ] )

string loadTTF ( string $fontfile [, bool $embed = FALSE ] )

string loadType1 ( string $afmfile [, string $pfmfile ] )

bool output ( void )

string readFromStream ( int $bytes )

bool resetError ( void )

bool resetStream ( void )

bool save ( string $file )

bool saveToStream ( void )

bool setCompressionMode ( int $mode )

bool setCurrentEncoder ( string $encoding )

bool setEncryptionMode ( int $mode [, int $key_len = 5 ] )

bool setInfoAttr ( int $type , string $info )

bool setInfoDateAttr ( int $type , int $year , int $month , int $day , int $hour , int $min , int $sec , string $ind , int $off_hour , int $off_min )

bool setOpenAction ( object $destination )

bool setPageLayout ( int $layout )

bool setPageMode ( int $mode )

bool setPagesConfiguration ( int $page_per_pages )

bool setPassword ( string $owner_password , string $user_password )

bool setPermission ( int $permission )

bool useCNSEncodings ( void )

bool useCNSFonts ( void )

bool useCNTEncodings ( void )

bool useCNTFonts ( void )

bool useJPEncodings ( void )

bool useJPFonts ( void )

bool useKREncodings ( void )

bool useKRFonts ( void )

}

预定义常量

TypeNameDescription
intHaruDoc::CS_DEVICE_GRAY 
intHaruDoc::CS_DEVICE_RGB 
intHaruDoc::CS_DEVICE_CMYK 
intHaruDoc::CS_CAL_GRAY 
intHaruDoc::CS_CAL_RGB 
intHaruDoc::CS_LAB 
intHaruDoc::CS_ICC_BASED 
intHaruDoc::CS_SEPARATION 
intHaruDoc::CS_DEVICE_N 
intHaruDoc::CS_INDEXED 
intHaruDoc::CS_PATTERN 
intHaruDoc::ENABLE_READ 
intHaruDoc::ENABLE_PRINT 
intHaruDoc::ENABLE_EDIT_ALL 
intHaruDoc::ENABLE_COPY 
intHaruDoc::ENABLE_EDIT 
intHaruDoc::ENCRYPT_R2 
intHaruDoc::ENCRYPT_R3 
intHaruDoc::INFO_AUTHOR 
intHaruDoc::INFO_CREATOR 
intHaruDoc::INFO_TITLE 
intHaruDoc::INFO_SUBJECT 
intHaruDoc::INFO_KEYWORDS 
intHaruDoc::INFO_CREATION_DATE 
intHaruDoc::INFO_MOD_DATE 
intHaruDoc::COMP_NONE 
intHaruDoc::COMP_TEXT 
intHaruDoc::COMP_IMAGE 
intHaruDoc::COMP_METADATA 
intHaruDoc::COMP_ALL 
intHaruDoc::PAGE_LAYOUT_SINGLE 
intHaruDoc::PAGE_LAYOUT_ONE_COLUMN 
intHaruDoc::PAGE_LAYOUT_TWO_COLUMN_LEFT 
intHaruDoc::PAGE_LAYOUT_TWO_COLUMN_RIGHT 
intHaruDoc::PAGE_MODE_USE_NONE 
intHaruDoc::PAGE_MODE_USE_OUTLINE 
intHaruDoc::PAGE_MODE_USE_THUMBS 
intHaruDoc::PAGE_MODE_FULL_SCREEN 

HaruDoc::addPage

Add new page to the document

说明

object HaruDoc::addPage ( void )

Adds a new page to the document.

参数

此函数没有参数。

返回值

Returns a new HaruPage instance.

错误/异常

发生错误时抛出 HaruException 异常。

参见

  • HaruDoc::insertPage

HaruDoc::addPageLabel

Set the numbering style for the specified range of pages

说明

bool HaruDoc::addPageLabel ( int $first_page , int $style , int $first_num [, string $prefix = "" ] )

Set the numbering style for the specified range of pages.

参数

first_page
The first page included into the labeling range.

style
The numbering style. The following values are allowed:

  • HaruPage::NUM_STYLE_DECIMAL - page label is displayed using decimal numerals.
  • HaruPage::NUM_STYLE_UPPER_ROMAN - page label is displayed using uppercase Roman numerals.
  • HaruPage::NUM_STYLE_LOWER_ROMAN - page label is displayed using lowercase Roman numerals.
  • HaruPage::NUM_STYLE_UPPER_LETTER - page label is displayed using uppercase letters (from A to Z).
  • HaruPage::NUM_STYLE_LOWER_LETTERS - page label is displayed using lowercase letters (from a to z).

first_num
The first page number in this range.

prefix
The prefix for the page label.

返回值

Returns TRUE on success.

错误/异常

发生错误时抛出 HaruException 异常。

HaruDoc::__construct

Construct new HaruDoc instance

说明

HaruDoc::__construct ( void )

Constructs new HaruDoc instance.

参数

此函数没有参数。

返回值

没有返回值。

错误/异常

发生错误时抛出 HaruException 异常。

HaruDoc::createOutline

Create a HaruOutline instance

说明

object HaruDoc::createOutline ( string $title [, object $parent_outline [, object $encoder ]] )

Create a HaruOutline instance.

参数

title
The caption of new outline object.

parent_outline
A valid HaruOutline instance or NULL.

encoder
A valid HaruEncoder instance or NULL.

返回值

Returns a new HaruOutline instance.

错误/异常

发生错误时抛出 HaruException 异常。

HaruDoc::getCurrentEncoder

Get HaruEncoder currently used in the document

说明

object HaruDoc::getCurrentEncoder ( void )

Get the HaruEncoder currently used in the document.

参数

此函数没有参数。

返回值

Returns HaruEncoder currently used in the document or FALSE if encoder is not set.

错误/异常

发生错误时抛出 HaruException 异常。

参见

  • HaruDoc::setCurrentEncoder

HaruDoc::getCurrentPage

Return current page of the document

说明

object HaruDoc::getCurrentPage ( void )

Get current page of the document.

参数

此函数没有参数。

返回值

Returns HaruPage instance on success or FALSE if there is no current page at the moment.

错误/异常

发生错误时抛出 HaruException 异常。

HaruDoc::getEncoder

Get HaruEncoder instance for the specified encoding

说明

object HaruDoc::getEncoder ( string $encoding )

Get the HaruEncoder instance for the specified encoding.

参数

encoding
The encoding name. See Builtin Encodings for the list of allowed values.

返回值

Returns a HaruEncoder instance for the specified encoding.

错误/异常

发生错误时抛出 HaruException 异常。

参见

  • HaruDoc::setCurrentEncoder
  • HaruDoc::getCurrentEncoder

HaruDoc::getFont

Get HaruFont instance

说明

object HaruDoc::getFont ( string $fontname [, string $encoding ] )

Get a HaruFont instance.

参数

fontname
The name of the font. See Builtin Fonts for the list of builtin fonts. You can also use the name of a font loaded via HaruDoc::loadTTF, HaruDoc::loadTTC and HaruDoc::loadType1.

encoding
The encoding to use. See Builtin Encodings for the list of supported encodings.

返回值

Returns a HaruFont instance with the specified fontname and encoding.

错误/异常

发生错误时抛出 HaruException 异常。

参见

  • HaruPage::setFontAndSize
  • HaruPage::setCurrentFont

HaruDoc::getInfoAttr

Get current value of the specified document attribute

说明

string HaruDoc::getInfoAttr ( int $type )

Get the current value of the specified document attribute.

参数

type
The type of the attribute. The following values are available:

  • HaruDoc::INFO_AUTHOR
  • HaruDoc::INFO_CREATOR
  • HaruDoc::INFO_TITLE
  • HaruDoc::INFO_SUBJECT
  • HaruDoc::INFO_KEYWORDS
  • HaruDoc::INFO_CREATION_DATE
  • HaruDoc::INFO_MOD_DATE

返回值

Returns the string value of the specified document attribute.

错误/异常

发生错误时抛出 HaruException 异常。

参见

  • HaruDoc::setInfoAttr
  • HaruDoc::setInfoDateAttr

HaruDoc::getPageLayout

Get current page layout

说明

int HaruDoc::getPageLayout ( void )

Get the current page layout. See HaruDoc::setPageLayout for the list of possible values.

参数

此函数没有参数。

返回值

Returns the page layout currently set in the document or FALSE if page layout was not set. See HaruDoc::setPageLayout for the list of possible values.

错误/异常

发生错误时抛出 HaruException 异常。

参见

  • HaruDoc::setPageLayout

HaruDoc::getPageMode

Get current page mode

说明

int HaruDoc::getPageMode ( void )

Get the current page mode. See HaruDoc::setPageMode for the list of possible values.

参数

此函数没有参数。

返回值

Returns the page mode currently set in the document. See HaruDoc::setPageMode for the list of possible values.

错误/异常

发生错误时抛出 HaruException 异常。

参见

  • HaruDoc::setPageMode

HaruDoc::getStreamSize

Get the size of the temporary stream

说明

int HaruDoc::getStreamSize ( void )

Get the size of the temporary stream.

参数

此函数没有参数。

返回值

Returns the size of the data in the temporary stream of the document. The size is zero if the document was not saved to the temporary stream.

错误/异常

发生错误时抛出 HaruException 异常。

参见

  • HaruDoc::saveToStream
  • HaruDoc::resetStream
  • HaruDoc::readFromStream

HaruDoc::insertPage

Insert new page just before the specified page

说明

object HaruDoc::insertPage ( object $page )

Creates a new page and inserts just before the specified page.

参数

page
A valid HaruPage instance.

返回值

Returns a new HaruPage instance.

错误/异常

发生错误时抛出 HaruException 异常。

参见

  • HaruDoc::addPage

HaruDoc::loadJPEG

Load a JPEG image

说明

object HaruDoc::loadJPEG ( string $filename )

Loads the specified JPEG image.

参数

filename
A valid JPEG image file.

返回值

Returns a new HaruImage instance.

错误/异常

发生错误时抛出 HaruException 异常。

参见

  • HaruDoc::loadPNG
  • HaruDoc::loadRAW

HaruDoc::loadPNG

Load PNG image and return HaruImage instance

说明

object HaruDoc::loadPNG ( string $filename [, bool $deferred = FALSE ] )

Loads a PNG image.

Libharu might be built without libpng support, in this case each call to this function would result in exception.

参数

filename
The name of a PNG image file.

deferred
Do not load data immediately. You can set deferred parameter to TRUE for deferred data loading, in this case only size and color are loaded immediately.

返回值

Returns a HaruImage instance.

错误/异常

发生错误时抛出 HaruException 异常。

参见

  • HaruDoc::loadJPEG
  • HaruDoc::loadRAW

HaruDoc::loadRaw

Load a RAW image

说明

object HaruDoc::loadRaw ( string $filename , int $width , int $height , int $color_space )

Loads a RAW image.

参数

filename
The name of a RAW image file.

width
The width of the image.

height
The height of the image.

color_space
The color space of the image. Can be one of the following values:

  • HaruDoc::CS_DEVICE_GRAY
  • HaruDoc::CS_DEVICE_RGB
  • HaruDoc::CS_DEVICE_CMYK

返回值

Returns a HaruImage instance.

错误/异常

发生错误时抛出 HaruException 异常。

参见

  • HaruDoc::loadJPEG
  • HaruDoc::loadPNG

HaruDoc::loadTTC

Load the font with the specified index from TTC file

说明

string HaruDoc::loadTTC ( string $fontfile , int $index [, bool $embed = FALSE ] )

Loads the TrueType font with the specified index from a TrueType collection file.

参数

fontfile
The TrueType collection file.

index
The index of the font in the collection file.

embed
When set to TRUE, the glyph data of the font is embedded into the PDF file, otherwise only the matrix data is included.

返回值

Returns the name of the loaded font on success.

错误/异常

发生错误时抛出 HaruException 异常。

参见

  • HaruDoc::loadTTF
  • HaruDoc::loadType1

HaruDoc::loadTTF

Load TTF font file

说明

string HaruDoc::loadTTF ( string $fontfile [, bool $embed = FALSE ] )

Loads the given TTF file and (optionally) embed its data into the document.

参数

fontfile
The TTF file to load.

embed
When set to TRUE, the glyph data of the font is embedded into the PDF file, otherwise only the matrix data is included.

返回值

Returns the name of the loaded font on success.

错误/异常

发生错误时抛出 HaruException 异常。

参见

  • HaruDoc::loadTTC
  • HaruDoc::loadType1

HaruDoc::loadType1

Load Type1 font

说明

string HaruDoc::loadType1 ( string $afmfile [, string $pfmfile ] )

Loads Type1 font from the given file and registers it in the PDF document.

参数

afmfile
Path to an AFM file.

pfmfile
Path to a PFA/PFB file, optional. If it's not set only the glyph data of the font is embedded into the PDF document.

返回值

Returns the name of the loaded font on success.

错误/异常

发生错误时抛出 HaruException 异常。

参见

  • HaruDoc::loadTTC
  • HaruDoc::loadTTF

HaruDoc::output

Write the document data to the output buffer

说明

bool HaruDoc::output ( void )

Writes the document data into standard output.

参数

此函数没有参数。

返回值

Returns TRUE on success.

错误/异常

发生错误时抛出 HaruException 异常。

参见

  • HaruDoc::save

HaruDoc::readFromStream

Read data from the temporary stream

说明

string HaruDoc::readFromStream ( int $bytes )

Read data from the temporary stream.

参数

bytes
The bytes parameter specifies how many bytes to read, though the stream may contain less bytes than requested.

返回值

Returns data from the temporary stream.

错误/异常

发生错误时抛出 HaruException 异常。

参见

  • HaruDoc::saveToStream
  • HaruDoc::resetStream
  • HaruDoc::getStreamSize

HaruDoc::resetError

Reset error state of the document handle

说明

bool HaruDoc::resetError ( void )

Once an error code is set, most of the operations, including I/O processing functions cannot be performed. In case if you want to continue after the cause of the error has been fixed, you have to invoke this function in order to reset the document error state.

参数

此函数没有参数。

返回值

Always succeeds and returns TRUE.

HaruDoc::resetStream

Rewind the temporary stream

说明

bool HaruDoc::resetStream ( void )

Rewinds the temporary stream of the document.

参数

此函数没有参数。

返回值

Returns TRUE on success.

错误/异常

发生错误时抛出 HaruException 异常。

参见

  • HaruDoc::saveToStream
  • HaruDoc::getStreamSize
  • HaruDoc::readFromStream

HaruDoc::save

Save the document into the specified file

说明

bool HaruDoc::save ( string $file )

Saves the document into the specified file.

参数

file
The file to save the document to.

返回值

Returns TRUE on success.

错误/异常

发生错误时抛出 HaruException 异常。

参见

  • HaruDoc::output

HaruDoc::saveToStream

Save the document into a temporary stream

说明

bool HaruDoc::saveToStream ( void )

Saves the document data into a temporary stream.

参数

此函数没有参数。

返回值

Returns TRUE on success.

错误/异常

发生错误时抛出 HaruException 异常。

参见

  • HaruDoc::resetStream
  • HaruDoc::getStreamSize
  • HaruDoc::readFromStream

HaruDoc::setCompressionMode

Set compression mode for the document

说明

bool HaruDoc::setCompressionMode ( int $mode )

Defines compression mode for the document. In case when libharu was compiled without Zlib support this function will always throw HaruException.

参数

mode
The compression mode to use. The value is a combination of the following flags:

  • HaruDoc::COMP_NONE - all contents is not compressed.
  • HaruDoc::COMP_TEXT - compress the text data.
  • HaruDoc::COMP_IMAGE - compress the image data.
  • HaruDoc::COMP_METADATA - compress other data (fonts, cmaps).
  • HaruDoc::COMP_ALL - compress all data.

返回值

Returns TRUE on success.

错误/异常

发生错误时抛出 HaruException 异常。

HaruDoc::setCurrentEncoder

Set the current encoder for the document

说明

bool HaruDoc::setCurrentEncoder ( string $encoding )

Defines the encoder currently used in the document.

参数

encoding
The name of the encoding to use. See Builtin Encodings for the list of allowed values.

返回值

Returns TRUE on success.

错误/异常

发生错误时抛出 HaruException 异常。

HaruDoc::setEncryptionMode

Set encryption mode for the document

说明

bool HaruDoc::setEncryptionMode ( int $mode [, int $key_len = 5 ] )

Defines encryption mode for the document. The encryption mode cannot be set before setting the password.

参数

mode
The encryption mode to use. Can be one of the following:

  • HaruDoc::ENCRYPT_R2 - use "revision2" algorithm.
  • HaruDoc::ENCRYPT_R3 - use "revision3" algorithm. Using this value bumps the version of PDF to 1.4.

key_len
The encryption key length in bytes. This parameter is optional and used only when mode is HaruDoc::ENCRYPT_R3. The default value is 5 (40bit).

返回值

Returns TRUE on success.

错误/异常

发生错误时抛出 HaruException 异常。

参见

  • HaruDoc::setPassword
  • HaruDoc::setPermission

HaruDoc::setInfoAttr

Set the info attribute of the document

说明

bool HaruDoc::setInfoAttr ( int $type , string $info )

Defines an info attribute. Uses the current encoding of the document.

参数

type
The type of the attribute. Can be one of the following:

  • HaruDoc::INFO_AUTHOR
  • HaruDoc::INFO_CREATOR
  • HaruDoc::INFO_TITLE
  • HaruDoc::INFO_SUBJECT
  • HaruDoc::INFO_KEYWORDS

info
The value of the attribute.

返回值

Returns TRUE on success.

错误/异常

发生错误时抛出 HaruException 异常。

参见

  • HaruDoc::setInfoDateAttr

HaruDoc::setInfoDateAttr

Set the datetime info attributes of the document

说明

bool HaruDoc::setInfoDateAttr ( int $type , int $year , int $month , int $day , int $hour , int $min , int $sec , string $ind , int $off_hour , int $off_min )

Sets the datetime info attributes of the document.

参数

type
The type of the attribute. Can be one of the following:

  • HaruDoc::INFO_CREATION_DATE
  • HaruDoc::INFO_MOD_DATE

year

month
Between 1 and 12.

day
Between 1 and 31, 30, 29 or 28 (different for each month).

hour
Between 0 and 23.

min
Between 0 and 59.

sec
Between 0 and 59.

ind
The timezone relation to UTC, can be "", " ", "+", "-" and "Z".

off_hour
If ind is not " " or "", values between 0 and 23 are valid. Otherwise, this parameter is ignored.

off_min
If ind is not " " or "", values between 0 and 59 are valid. Otherwise, this parameter is ignored.

返回值

Returns TRUE on success.

错误/异常

发生错误时抛出 HaruException 异常。

参见

  • HaruDoc::setInfoAttr

HaruDoc::setOpenAction

Define which page is shown when the document is opened

说明

bool HaruDoc::setOpenAction ( object $destination )

Defines which page should be shown when the document is opened.

参数

destination
A valid HaruDestination instance.

返回值

Returns TRUE on success.

错误/异常

发生错误时抛出 HaruException 异常。

HaruDoc::setPageLayout

Set how pages should be displayed

说明

bool HaruDoc::setPageLayout ( int $layout )

Defines how pages should be displayed.

参数

layout
The following values are accepted:

  • HaruDoc::PAGE_LAYOUT_SINGLE - only one page is displayed.
  • HaruDoc::PAGE_LAYOUT_ONE_COLUMN - display the pages in one column.
  • HaruDoc::PAGE_LAYOUT_TWO_COLUMN_LEFT - display pages in two columns, first page left.
  • HaruDoc::PAGE_LAYOUT_TWO_COLUMN_RIGHT - display pages in two columns, first page right.

返回值

Returns TRUE on success.

错误/异常

发生错误时抛出 HaruException 异常。

参见

  • HaruDoc::getPageLayout

HaruDoc::setPageMode

Set how the document should be displayed

说明

bool HaruDoc::setPageMode ( int $mode )

Defines how the document should be displayed.

参数

mode
The following values are accepted:

  • HaruDoc::PAGE_MODE_USE_NONE - display the document with neither outline nor thumbnail.
  • HaruDoc::PAGE_MODE_USE_OUTLINE - display the document with outline pane.
  • HaruDoc::PAGE_MODE_USE_THUMBS - display the document with thumbnail pane.
  • HaruDoc::PAGE_MODE_FULL_SCREEN - display the document with full screen mode.

返回值

Returns TRUE on success.

错误/异常

发生错误时抛出 HaruException 异常。

参见

  • HaruDoc::getPageMode

HaruDoc::setPagesConfiguration

Set the number of pages per set of pages

说明

bool HaruDoc::setPagesConfiguration ( int $page_per_pages )

By default the document has one pages object as a root for all pages. All page objects are create as branches of this object. One pages object can contain only 8191, therefore the maximum number of pages per document is 8191. But you can change that fact by setting page_per_pages parameter, so that the root pages object contains 8191 more pages (not page) objects, which in turn contain 8191 pages each. So the maximum number of pages in the document becomes 8191*page_per_pages.

参数

page_per_pages
The numbers of pages that a pages object can contain.

返回值

Returns TRUE on success.

错误/异常

发生错误时抛出 HaruException 异常。

HaruDoc::setPassword

Set owner and user passwords for the document

说明

bool HaruDoc::setPassword ( string $owner_password , string $user_password )

Defines owner and user passwords for the document. Setting the passwords makes the document contents encrypted.

参数

owner_password
The password of the owner, which can change permissions of the document. Empty password is not accepted. Owner's password cannot be the same as the user's password.

user_password
The password of the user. Can be empty.

返回值

Returns TRUE on success.

错误/异常

发生错误时抛出 HaruException 异常。

参见

  • HaruDoc::setEncryptionMode
  • HaruDoc::setPermission

HaruDoc::setPermission

Set permissions for the document

说明

bool HaruDoc::setPermission ( int $permission )

Defines permissions for the document.

参数

permission
The values is a combination of these flags:

  • HaruDoc::ENABLE_READ - user can read the document.
  • HaruDoc::ENABLE_PRINT - user can print the document.
  • HaruDoc::ENABLE_EDIT_ALL - user can edit the contents of the document other than annotations and form fields.
  • HaruDoc::ENABLE_COPY - user can copy the text and the graphics of the document.
  • HaruDoc::ENABLE_EDIT - user can add or modify the annotations and form fields of the document.

返回值

Returns TRUE on success.

错误/异常

发生错误时抛出 HaruException 异常。

参见

  • HaruDoc::setPassword
  • HaruDoc::setEncryptionMode

HaruDoc::useCNSEncodings

Enable Chinese simplified encodings

说明

bool HaruDoc::useCNSEncodings ( void )

Enables Chinese simplified encodings.

参数

此函数没有参数。

返回值

Returns TRUE on success.

错误/异常

发生错误时抛出 HaruException 异常。

参见

  • HaruDoc::useCNSFonts

HaruDoc::useCNSFonts

Enable builtin Chinese simplified fonts

说明

bool HaruDoc::useCNSFonts ( void )

Enables builtin Chinese simplified fonts.

参数

此函数没有参数。

返回值

Returns TRUE on success.

错误/异常

发生错误时抛出 HaruException 异常。

参见

  • HaruDoc::useCNSEncodings

HaruDoc::useCNTEncodings

Enable Chinese traditional encodings

说明

bool HaruDoc::useCNTEncodings ( void )

Enables Chinese traditional encodings.

参数

此函数没有参数。

返回值

Returns TRUE on success.

错误/异常

发生错误时抛出 HaruException 异常。

参见

  • HaruDoc::useCNTFonts

HaruDoc::useCNTFonts

Enable builtin Chinese traditional fonts

说明

bool HaruDoc::useCNTFonts ( void )

Enables builtin Chinese traditional fonts.

参数

此函数没有参数。

返回值

Returns TRUE on success.

错误/异常

发生错误时抛出 HaruException 异常。

参见

  • HaruDoc::useCNTEncodings

HaruDoc::useJPEncodings

Enable Japanese encodings

说明

bool HaruDoc::useJPEncodings ( void )

Enables Japanese encodings.

参数

此函数没有参数。

返回值

Returns TRUE on success.

错误/异常

发生错误时抛出 HaruException 异常。

参见

  • HaruDoc::useJPFonts

HaruDoc::useJPFonts

Enable builtin Japanese fonts

说明

bool HaruDoc::useJPFonts ( void )

Enables builtin Japanese fonts.

参数

此函数没有参数。

返回值

Returns TRUE on success.

错误/异常

发生错误时抛出 HaruException 异常。

参见

  • HaruDoc::useJPEncodings

HaruDoc::useKREncodings

Enable Korean encodings

说明

bool HaruDoc::useKREncodings ( void )

Enables Korean encodings.

参数

此函数没有参数。

返回值

Returns TRUE on success.

错误/异常

发生错误时抛出 HaruException 异常。

参见

  • HaruDoc::useKRFonts

HaruDoc::useKRFonts

Enable builtin Korean fonts

说明

bool HaruDoc::useKRFonts ( void )

Enables builtin Korean fonts.

参数

此函数没有参数。

返回值

Returns TRUE on success.

错误/异常

发生错误时抛出 HaruException 异常。

参见

  • HaruDoc::useKREncodings

简介

Haru PDF Page Class.

类摘要

HaruPage

class HaruPage {

/* 方法 */

bool arc ( float $x , float $y , float $ray , float $ang1 , float $ang2 )

bool beginText ( void )

bool circle ( float $x , float $y , float $ray )

bool closePath ( void )

bool concat ( float $a , float $b , float $c , float $d , float $x , float $y )

object createDestination ( void )

object createLinkAnnotation ( array $rectangle , object $destination )

object createTextAnnotation ( array $rectangle , string $text [, object $encoder ] )

object createURLAnnotation ( array $rectangle , string $url )

bool curveTo2 ( float $x2 , float $y2 , float $x3 , float $y3 )

bool curveTo3 ( float $x1 , float $y1 , float $x3 , float $y3 )

bool curveTo ( float $x1 , float $y1 , float $x2 , float $y2 , float $x3 , float $y3 )

bool drawImage ( object $image , float $x , float $y , float $width , float $height )

bool ellipse ( float $x , float $y , float $xray , float $yray )

bool endPath ( void )

bool endText ( void )

bool eofill ( void )

bool eoFillStroke ([ bool $close_path = FALSE ] )

bool fill ( void )

bool fillStroke ([ bool $close_path = FALSE ] )

float getCharSpace ( void )

array getCMYKFill ( void )

array getCMYKStroke ( void )

object getCurrentFont ( void )

float getCurrentFontSize ( void )

array getCurrentPos ( void )

array getCurrentTextPos ( void )

array getDash ( void )

int getFillingColorSpace ( void )

float getFlatness ( void )

int getGMode ( void )

float getGrayFill ( void )

float getGrayStroke ( void )

float getHeight ( void )

float getHorizontalScaling ( void )

int getLineCap ( void )

int getLineJoin ( void )

float getLineWidth ( void )

float getMiterLimit ( void )

array getRGBFill ( void )

array getRGBStroke ( void )

int getStrokingColorSpace ( void )

float getTextLeading ( void )

array getTextMatrix ( void )

int getTextRenderingMode ( void )

float getTextRise ( void )

float getTextWidth ( string $text )

array getTransMatrix ( void )

float getWidth ( void )

float getWordSpace ( void )

bool lineTo ( float $x , float $y )

int measureText ( string $text , float $width [, bool $wordwrap = FALSE ] )

bool moveTextPos ( float $x , float $y [, bool $set_leading = FALSE ] )

bool moveTo ( float $x , float $y )

bool moveToNextLine ( void )

bool rectangle ( float $x , float $y , float $width , float $height )

bool setCharSpace ( float $char_space )

bool setCMYKFill ( float $c , float $m , float $y , float $k )

bool setCMYKStroke ( float $c , float $m , float $y , float $k )

bool setDash ( array $pattern , int $phase )

bool setFlatness ( float $flatness )

bool setFontAndSize ( object $font , float $size )

bool setGrayFill ( float $value )

bool setGrayStroke ( float $value )

bool setHeight ( float $height )

bool setHorizontalScaling ( float $scaling )

bool setLineCap ( int $cap )

bool setLineJoin ( int $join )

bool setLineWidth ( float $width )

bool setMiterLimit ( float $limit )

bool setRGBFill ( float $r , float $g , float $b )

bool setRGBStroke ( float $r , float $g , float $b )

bool setRotate ( int $angle )

bool setSize ( int $size , int $direction )

bool setSlideShow ( int $type , float $disp_time , float $trans_time )

bool setTextLeading ( float $text_leading )

bool setTextMatrix ( float $a , float $b , float $c , float $d , float $x , float $y )

bool setTextRenderingMode ( int $mode )

bool setTextRise ( float $rise )

bool setWidth ( float $width )

bool setWordSpace ( float $word_space )

bool showText ( string $text )

bool showTextNextLine ( string $text [, float $word_space = 0 [, float $char_space = 0 ]] )

bool stroke ([ bool $close_path = FALSE ] )

bool textOut ( float $x , float $y , string $text )

bool textRect ( float $left , float $top , float $right , float $bottom , string $text [, int $align = HaruPage::TALIGN_LEFT ] )

}

预定义常量

TypeNameDescription
intHaruPage::GMODE_PAGE_DESCRIPTION 
intHaruPage::GMODE_TEXT_OBJECT 
intHaruPage::GMODE_PATH_OBJECT 
intHaruPage::GMODE_CLIPPING_PATH 
intHaruPage::GMODE_SHADING 
intHaruPage::GMODE_INLINE_IMAGE 
intHaruPage::GMODE_EXTERNAL_OBJECT 
intHaruPage::BUTT_END 
intHaruPage::ROUND_END 
intHaruPage::PROJECTING_SCUARE_END 
intHaruPage::MITER_JOIN 
intHaruPage::ROUND_JOIN 
intHaruPage::BEVEL_JOIN 
intHaruPage::FILL 
intHaruPage::STROKE 
intHaruPage::FILL_THEN_STROKE 
intHaruPage::INVISIBLE 
intHaruPage::FILL_CLIPPING 
intHaruPage::STROKE_CLIPPING 
intHaruPage::FILL_STROKE_CLIPPING 
intHaruPage::CLIPPING 
intHaruPage::TALIGN_LEFT 
intHaruPage::TALIGN_RIGHT 
intHaruPage::TALIGN_CENTER 
intHaruPage::TALIGN_JUSTIFY 
intHaruPage::SIZE_LETTER 
intHaruPage::SIZE_LEGAL 
intHaruPage::SIZE_A3 
intHaruPage::SIZE_A4 
intHaruPage::SIZE_A5 
intHaruPage::SIZE_B4 
intHaruPage::SIZE_B5 
intHaruPage::SIZE_EXECUTIVE 
intHaruPage::SIZE_US4x6 
intHaruPage::SIZE_US4x8 
intHaruPage::SIZE_US5x7 
intHaruPage::SIZE_COMM10 
intHaruPage::PORTRAIT 
intHaruPage::LANDSCAPE 
intHaruPage::TS_WIPE_LIGHT 
intHaruPage::TS_WIPE_UP 
intHaruPage::TS_WIPE_LEFT 
intHaruPage::TS_WIPE_DOWN 
intHaruPage::TS_BARN_DOORS_HORIZONTAL_OUT 
intHaruPage::TS_BARN_DOORS_HORIZONTAL_IN 
intHaruPage::TS_BARN_DOORS_VERTICAL_OUT 
intHaruPage::TS_BARN_DOORS_VERTICAL_IN 
intHaruPage::TS_BOX_OUT 
intHaruPage::TS_BOX_IN 
intHaruPage::TS_BLINDS_HORIZONTAL 
intHaruPage::TS_BLINDS_VERTICAL 
intHaruPage::TS_DISSOLVE 
intHaruPage::TS_GLITTER_RIGHT 
intHaruPage::TS_GLITTER_DOWN 
intHaruPage::TS_GLITTER_TOP_LEFT_TO_BOTTOM_RIGHT 
intHaruPage::TS_REPLACE 
intHaruPage::NUM_STYLE_DECIMAL 
intHaruPage::NUM_STYLE_UPPER_ROMAN 
intHaruPage::NUM_STYLE_LOWER_ROMAN 
intHaruPage::NUM_STYLE_UPPER_LETTERS 
intHaruPage::NUM_STYLE_LOWER_LETTERS 

HaruPage::arc

Append an arc to the current path

说明

bool HaruPage::arc ( float $x , float $y , float $ray , float $ang1 , float $ang2 )

Appends an arc to the current path.

参数

x
Horizontal coordinate of the center.

y
Vertical coordinate of the center.

ray
The ray of the arc.

ang1
The angle of the beginning.

ang2
The angle of the end. Must be greater than ang1.

返回值

Returns TRUE on success.

错误/异常

发生错误时抛出 HaruException 异常。

HaruPage::beginText

Begin a text object and set the current text position to (0,0)

说明

bool HaruPage::beginText ( void )

Begins new text object and sets the current text position to (0,0).

参数

此函数没有参数。

返回值

Returns TRUE on success.

错误/异常

发生错误时抛出 HaruException 异常。

HaruPage::circle

Append a circle to the current path

说明

bool HaruPage::circle ( float $x , float $y , float $ray )

Appends a circle to the current path.

参数

x
Horizontal coordinate of the center point.

y
Vertical coordinate of the center point.

ray
The ray of the circle.

返回值

Returns TRUE on success.

错误/异常

发生错误时抛出 HaruException 异常。

HaruPage::closePath

Append a straight line from the current point to the start point of the path

说明

bool HaruPage::closePath ( void )

Appends a straight line from the current point to the start point of the path.

参数

此函数没有参数。

返回值

Returns TRUE on success.

错误/异常

发生错误时抛出 HaruException 异常。

HaruPage::concat

Concatenate current transformation matrix of the page and the specified matrix

说明

bool HaruPage::concat ( float $a , float $b , float $c , float $d , float $x , float $y )

Concatenates current transformation matrix of the page and the specified matrix.

参数

a

b

c

d

x

y

返回值

Returns TRUE on success.

错误/异常

发生错误时抛出 HaruException 异常。

HaruPage::createDestination

Create new HaruDestination instance

说明

object HaruPage::createDestination ( void )

Create a new HaruDestination instance.

参数

此函数没有参数。

返回值

Returns a new HaruDestination instance.

错误/异常

发生错误时抛出 HaruException 异常。

HaruPage::createLinkAnnotation

Create new HaruAnnotation instance

说明

object HaruPage::createLinkAnnotation ( array $rectangle , object $destination )

Creates a new HaruAnnotation instance.

参数

rectangle
An array with 4 coordinates of the clickable area.

destination
Valid HaruDestination instance.

返回值

Returns a new HaruAnnotation instance.

错误/异常

发生错误时抛出 HaruException 异常。

HaruPage::createTextAnnotation

Create new HaruAnnotation instance

说明

object HaruPage::createTextAnnotation ( array $rectangle , string $text [, object $encoder ] )

Creates a new HaruAnnotation instance.

参数

rectangle
An array with 4 coordinates of the annotation area.

text
The text to be displayed.

encoder
Optional HaruEncoder instance.

返回值

Returns a new HaruAnnotation instance.

错误/异常

发生错误时抛出 HaruException 异常。

HaruPage::createURLAnnotation

Create and return new HaruAnnotation instance

说明

object HaruPage::createURLAnnotation ( array $rectangle , string $url )

Creates a new HaruAnnotation instance.

参数

rectangle
An array with 4 coordinates of the clickable area.

url
The URL to open.

返回值

Returns a new HaruAnnotation instance.

错误/异常

发生错误时抛出 HaruException 异常。

HaruPage::curveTo2

Append a Bezier curve to the current path

说明

bool HaruPage::curveTo2 ( float $x2 , float $y2 , float $x3 , float $y3 )

Appends a Bezier curve to the current path. The current point and the point (x2, y2) are used as the control points for the Bezier curve and current point is moved to the point (x3, y3).

参数

x2
A Bezier curve control point.

y2
A Bezier curve control point.

x3
The current point moves here.

x3
The current point moves here.

返回值

Returns TRUE on success.

错误/异常

发生错误时抛出 HaruException 异常。

HaruPage::curveTo3

Append a Bezier curve to the current path

说明

bool HaruPage::curveTo3 ( float $x1 , float $y1 , float $x3 , float $y3 )

Appends a Bezier curve to the current path. The point (x1, y1) and the point (x3, y3) are used as the control points for a Bezier curve and current point is moved to the point (x3, y3).

参数

x1
A Bezier curve control point.

y1
A Bezier curve control point.

x3
The current point moves here.

x3
The current point moves here.

返回值

Returns TRUE on success.

错误/异常

发生错误时抛出 HaruException 异常。

HaruPage::curveTo

Append a Bezier curve to the current path

说明

bool HaruPage::curveTo ( float $x1 , float $y1 , float $x2 , float $y2 , float $x3 , float $y3 )

Append a Bezier curve to the current path. The point (x1, y1) and the point (x2, y2) are used as the control points for a Bezier curve and current point is moved to the point (x3, y3).

参数

x1
A Bezier curve control point.

y1
A Bezier curve control point.

x2
A Bezier curve control point.

y2
A Bezier curve control point.

x3
The current point moves here.

x3
The current point moves here.

返回值

Returns TRUE on success.

错误/异常

发生错误时抛出 HaruException 异常。

HaruPage::drawImage

Show image at the page

说明

bool HaruPage::drawImage ( object $image , float $x , float $y , float $width , float $height )

Show image at the page.

参数

image
Valid HaruImage instance.

x
The left border of the area where the image is displayed.

y
The lower border of the area where the image is displayed.

width
The width of the image area.

height
The height of the image area.

返回值

Returns TRUE on success.

错误/异常

发生错误时抛出 HaruException 异常。

HaruPage::ellipse

Append an ellipse to the current path

说明

bool HaruPage::ellipse ( float $x , float $y , float $xray , float $yray )

Appends an ellipse to the current path.

参数

x
Horizontal coordinate of the center.

y
Vertical coordinate of the center.

xray
The ray of the ellipse in the x direction.

yray
The ray of the ellipse in the y direction.

返回值

Returns TRUE on success.

错误/异常

发生错误时抛出 HaruException 异常。

HaruPage::endPath

End current path object without filling and painting operations

说明

bool HaruPage::endPath ( void )

Ends current path object without performing filling and painting operations.

参数

此函数没有参数。

返回值

Returns TRUE on success.

错误/异常

发生错误时抛出 HaruException 异常。

HaruPage::endText

End current text object

说明

bool HaruPage::endText ( void )

Finalizes current text object.

参数

此函数没有参数。

返回值

Returns TRUE on success.

错误/异常

发生错误时抛出 HaruException 异常。

HaruPage::eofill

Fill current path using even-odd rule

说明

bool HaruPage::eofill ( void )

Fills current path using even-odd rule.

参数

此函数没有参数。

返回值

Returns TRUE on success.

错误/异常

发生错误时抛出 HaruException 异常。

HaruPage::eoFillStroke

Fill current path using even-odd rule, then paint the path

说明

bool HaruPage::eoFillStroke ([ bool $close_path = FALSE ] )

Fills current path using even-odd rule, then paints the path.

参数

close_path
Optional parameter. When set to TRUE, the function closes the current path. Default to FALSE.

返回值

Returns TRUE on success.

错误/异常

发生错误时抛出 HaruException 异常。

HaruPage::fill

Fill current path using nonzero winding number rule

说明

bool HaruPage::fill ( void )

Fills current path using nonzero winding number rule.

参数

此函数没有参数。

返回值

Returns TRUE on success.

错误/异常

发生错误时抛出 HaruException 异常。

HaruPage::fillStroke

Fill current path using nonzero winding number rule, then paint the path

说明

bool HaruPage::fillStroke ([ bool $close_path = FALSE ] )

Fills current path using nonzero winding number rule, then paints the path.

参数

close_path
Optional parameter. When set to TRUE, the function closes the current path. Default to FALSE.

返回值

Returns TRUE on success.

错误/异常

发生错误时抛出 HaruException 异常。

HaruPage::getCharSpace

Get the current value of character spacing

说明

float HaruPage::getCharSpace ( void )

Get the current value of character spacing.

参数

此函数没有参数。

返回值

Returns the current value of character spacing.

错误/异常

发生错误时抛出 HaruException 异常。

HaruPage::getCMYKFill

Get the current filling color

说明

array HaruPage::getCMYKFill ( void )

Returns the current filling color.

参数

此函数没有参数。

返回值

Returns the current filling color as an array with 4 elements ("c", "m", "y" and "k").

错误/异常

发生错误时抛出 HaruException 异常。

HaruPage::getCMYKStroke

Get the current stroking color

说明

array HaruPage::getCMYKStroke ( void )

Get the current stroking color.

参数

此函数没有参数。

返回值

Returns the current stroking color as an array with 4 elements ("c", "m", "y" and "k").

错误/异常

发生错误时抛出 HaruException 异常。

HaruPage::getCurrentFont

Get the currently used font

说明

object HaruPage::getCurrentFont ( void )

Get the currently used font.

参数

此函数没有参数。

返回值

Returns the currently used font as an instance of HaruFont.

错误/异常

发生错误时抛出 HaruException 异常。

HaruPage::getCurrentFontSize

Get the current font size

说明

float HaruPage::getCurrentFontSize ( void )

Get the current font size.

参数

此函数没有参数。

返回值

Returns the current font size.

错误/异常

发生错误时抛出 HaruException 异常。

HaruPage::getCurrentPos

Get the current position for path painting

说明

array HaruPage::getCurrentPos ( void )

Get the current position for path painting.

参数

此函数没有参数。

返回值

Returns the current position for path painting as an array of with two elements - "x" and "y".

错误/异常

发生错误时抛出 HaruException 异常。

HaruPage::getCurrentTextPos

Get the current position for text printing

说明

array HaruPage::getCurrentTextPos ( void )

Get the current position for text printing.

参数

此函数没有参数。

返回值

Returns the current position for text printing as an array with 2 elements - "x" and "y".

错误/异常

发生错误时抛出 HaruException 异常。

HaruPage::getDash

Get the current dash pattern

说明

array HaruPage::getDash ( void )

Get the current dash pattern. See HaruPage::setDash for more information on dash patterns.

参数

此函数没有参数。

返回值

Returns the current dash pattern as an array of two elements - "pattern" and "phase" or FALSE if dash pattern was not set.

错误/异常

发生错误时抛出 HaruException 异常。

参见

  • HaruPage::setDash

HaruPage::getFillingColorSpace

Get the current filling color space

说明

int HaruPage::getFillingColorSpace ( void )

Get the current filling color space.

参数

此函数没有参数。

返回值

Returns the current filling color space. The result value is one of the following:

  • HaruDoc::CS_DEVICE_GRAY
  • HaruDoc::CS_DEVICE_RGB
  • HaruDoc::CS_DEVICE_CMYK
  • HaruDoc::CS_CAL_GRAY
  • HaruDoc::CS_CAL_RGB
  • HaruDoc::CS_LAB
  • HaruDoc::CS_ICC_BASED
  • HaruDoc::CS_SEPARATION
  • HaruDoc::CS_DEVICE_N
  • HaruDoc::CS_INDEXED
  • HaruDoc::CS_PATTERN

错误/异常

发生错误时抛出 HaruException 异常。

HaruPage::getFlatness

Get the flatness of the page

说明

float HaruPage::getFlatness ( void )

Get the flatness of the page.

参数

此函数没有参数。

返回值

Returns the flatness of the page.

错误/异常

发生错误时抛出 HaruException 异常。

参见

  • HaruPage::setFlatness

HaruPage::getGMode

Get the current graphics mode

说明

int HaruPage::getGMode ( void )

Get the current graphics mode.

参数

此函数没有参数。

返回值

Returns the current graphics mode. The result value is one of the following:

  • HaruPage::GMODE_PAGE_DESCRIPTION
  • HaruPage::GMODE_TEXT_OBJECT
  • HaruPage::GMODE_PATH_OBJECT
  • HaruPage::GMODE_CLIPPING_PATH
  • HaruPage::GMODE_SHADING
  • HaruPage::GMODE_INLINE_IMAGE
  • HaruPage::GMODE_EXTERNAL_OBJECT

错误/异常

发生错误时抛出 HaruException 异常。

HaruPage::getGrayFill

Get the current filling color

说明

float HaruPage::getGrayFill ( void )

Get the current filling color.

参数

此函数没有参数。

返回值

Returns the current filling color.

错误/异常

发生错误时抛出 HaruException 异常。

参见

  • HaruPage::setGrayFill

HaruPage::getGrayStroke

Get the current stroking color

说明

float HaruPage::getGrayStroke ( void )

Get the current stroking color.

参数

此函数没有参数。

返回值

Returns the current stroking color.

错误/异常

发生错误时抛出 HaruException 异常。

参见

  • HaruPage::setGrayStroke

HaruPage::getHeight

Get the height of the page

说明

float HaruPage::getHeight ( void )

Get the height of the page.

参数

此函数没有参数。

返回值

Returns the height of the page.

错误/异常

发生错误时抛出 HaruException 异常。

参见

  • HaruPage::setHeight

HaruPage::getHorizontalScaling

Get the current value of horizontal scaling

说明

float HaruPage::getHorizontalScaling ( void )

Get the current value of the horizontal scaling.

参数

此函数没有参数。

返回值

Returns the current value of horizontal scaling.

错误/异常

发生错误时抛出 HaruException 异常。

参见

  • HaruPage::setHorizontalScaling

HaruPage::getLineCap

Get the current line cap style

说明

int HaruPage::getLineCap ( void )

Get the current line cap style.

参数

此函数没有参数。

返回值

Returns the current line cap style. The result value is one of the following:

  • HaruPage::BUTT_END - the line is squared off at the endpoint of the path.
  • HaruPage::ROUND_END - the end of the line becomes a semicircle with center in the end point of the path.
  • HaruPage::PROJECTING_SCUARE_END - the line continues to the point that exceeds half of the stroke width the end point.

错误/异常

发生错误时抛出 HaruException 异常。

参见

  • HaruPage::setLineCap

HaruPage::getLineJoin

Get the current line join style

说明

int HaruPage::getLineJoin ( void )

Get the current line join style.

参数

此函数没有参数。

返回值

Returns the current line join style. The result value is one of the following:

  • HaruPage::MITER_JOIN
  • HaruPage::ROUND_JOIN
  • HaruPage::BEVEL_JOIN

错误/异常

发生错误时抛出 HaruException 异常。

参见

  • HaruPage::setLineJoin

HaruPage::getLineWidth

Get the current line width

说明

float HaruPage::getLineWidth ( void )

Get the current line width.

参数

此函数没有参数。

返回值

Returns the current line width.

错误/异常

发生错误时抛出 HaruException 异常。

参见

  • HaruPage::setLineWidth

HaruPage::getMiterLimit

Get the value of miter limit

说明

float HaruPage::getMiterLimit ( void )

Get the value of the miter limit.

参数

此函数没有参数。

返回值

Returns the value of the miter limit.

错误/异常

发生错误时抛出 HaruException 异常。

参见

  • HaruPage::setMiterLimit

HaruPage::getRGBFill

Get the current filling color

说明

array HaruPage::getRGBFill ( void )

Get the current filling color.

参数

此函数没有参数。

返回值

Returns the current filling color as an array with 3 elements: "r", "g" and "b".

错误/异常

发生错误时抛出 HaruException 异常。

参见

  • HaruPage::setRGBFill

HaruPage::getRGBStroke

Get the current stroking color

说明

array HaruPage::getRGBStroke ( void )

Get the current stroking color.

参数

此函数没有参数。

返回值

Returns the current stroking color.

错误/异常

发生错误时抛出 HaruException 异常。

参见

  • HaruPage::setRGBStroke

HaruPage::getStrokingColorSpace

Get the current stroking color space

说明

int HaruPage::getStrokingColorSpace ( void )

Get the current stroking color space.

参数

此函数没有参数。

返回值

Returns the current stroking color space. The list of return values is the same as for HaruPage::getFillingColorSpace

错误/异常

发生错误时抛出 HaruException 异常。

参见

  • HaruPage::getFillingColorSpace

HaruPage::getTextLeading

Get the current value of line spacing

说明

float HaruPage::getTextLeading ( void )

Get the current value of line spacing.

参数

此函数没有参数。

返回值

Returns the current value of line spacing.

错误/异常

发生错误时抛出 HaruException 异常。

参见

  • HaruPage::setTextLeading

HaruPage::getTextMatrix

Get the current text transformation matrix of the page

说明

array HaruPage::getTextMatrix ( void )

Get the current text transformation matrix of the page.

返回值

Returns the current text transformation matrix of the page as an array of 6 elements: "a", "b", "c", "d", "x" and "y".

错误/异常

发生错误时抛出 HaruException 异常。

参见

  • HaruPage::setTextMatrix

HaruPage::getTextRenderingMode

Get the current text rendering mode

说明

int HaruPage::getTextRenderingMode ( void )

Get the current text rendering mode.

参数

此函数没有参数。

返回值

Returns the current text rendering mode. The result value is one of the following:

  • HaruPage::FILL
  • HaruPage::STROKE
  • HaruPage::FILL_THEN_STROKE
  • HaruPage::INVISIBLE
  • HaruPage::FILL_CLIPPING
  • HaruPage::STROKE_CLIPPING
  • HaruPage::FILL_STROKE_CLIPPING
  • HaruPage::CLIPPING

错误/异常

发生错误时抛出 HaruException 异常。

参见

  • HaruPage::setTextRenderingMode

HaruPage::getTextRise

Get the current value of text rising

说明

float HaruPage::getTextRise ( void )

Get the current value of text rising.

参数

此函数没有参数。

返回值

Returns the current value of text rising.

错误/异常

发生错误时抛出 HaruException 异常。

参见

  • HaruPage::setTextRise

HaruPage::getTextWidth

Get the width of the text using current fontsize, character spacing and word spacing

说明

float HaruPage::getTextWidth ( string $text )

Get the width of the text using current fontsize, character spacing and word spacing

参数

text
The text to measure.

返回值

Returns the width of the text using current fontsize, character spacing and word spacing.

错误/异常

发生错误时抛出 HaruException 异常。

参见

  • HaruPage::measureText

HaruPage::getTransMatrix

Get the current transformation matrix of the page

说明

array HaruPage::getTransMatrix ( void )

Get the current transformation matrix of the page.

参数

此函数没有参数。

返回值

Returns the current transformation matrix of the page as an array of 6 elements: "a", "b", "c", "d", "x" and "y".

错误/异常

发生错误时抛出 HaruException 异常。

参见

  • HaruPage::concat

HaruPage::getWidth

Get the width of the page

说明

float HaruPage::getWidth ( void )

Get the width of the page.

参数

此函数没有参数。

返回值

Returns the width of the page.

错误/异常

发生错误时抛出 HaruException 异常。

参见

  • HaruPage::setWidth

HaruPage::getWordSpace

Get the current value of word spacing

说明

float HaruPage::getWordSpace ( void )

Get the current value of word spacing.

参数

此函数没有参数。

返回值

Returns the current value of word spacing.

错误/异常

发生错误时抛出 HaruException 异常。

参见

  • HaruPage::setWordSpace

HaruPage::lineTo

Draw a line from the current point to the specified point

说明

bool HaruPage::lineTo ( float $x , float $y )

Draws a line from the current point to the specified point.

参数

x

y

返回值

Returns TRUE on success.

错误/异常

发生错误时抛出 HaruException 异常。

参见

  • HaruPage::curveTo
  • HaruPage::curveTo2
  • HaruPage::curveTo3

HaruPage::measureText

Calculate the byte length of characters which can be included on one line of the specified width

说明

int HaruPage::measureText ( string $text , float $width [, bool $wordwrap = FALSE ] )

Get the byte length of characters which can be included on one line of the specified width.

参数

text
The text to measure.

width
The width of the line.

wordwrap
When this parameter is set to TRUE the function "emulates" word wrapping by stopping after the last full word (delimited by whitespace) that can fit on the line.

返回值

Returns the byte length of characters which can be included within the specified width. For single-byte encodings, this is equal to the number of characters. For multi-byte encodings, this is not necessarily the case.

错误/异常

发生错误时抛出 HaruException 异常。

参见

  • HaruFont::measureText

HaruPage::moveTextPos

Move text position to the specified offset

说明

bool HaruPage::moveTextPos ( float $x , float $y [, bool $set_leading = FALSE ] )

Moves text position to the specified offset. If the start position of the current line is (x1, y1), the start of the next line is (x1 + x, y1 + y).

参数

x
The specified text position offset.

y
The specified text position offset.

set_leading
If set to TRUE, the function sets the text leading to -y.

返回值

Returns TRUE on success.

错误/异常

发生错误时抛出 HaruException 异常。

参见

  • HaruPage::moveToNextLine

HaruPage::moveTo

Set starting point for new drawing path

说明

bool HaruPage::moveTo ( float $x , float $y )

Defines starting point for new drawing path.

参数

x
A new starting point coordinate.

y
A new starting point coordinate.

返回值

Returns TRUE on success.

错误/异常

发生错误时抛出 HaruException 异常。

HaruPage::moveToNextLine

Move text position to the start of the next line

说明

bool HaruPage::moveToNextLine ( void )

Moves text position to the start of the next line.

参数

此函数没有参数。

返回值

Returns TRUE on success.

错误/异常

发生错误时抛出 HaruException 异常。

参见

  • HaruPage::moveTextPos

HaruPage::rectangle

Append a rectangle to the current path

说明

bool HaruPage::rectangle ( float $x , float $y , float $width , float $height )

Appends a rectangle to the current drawing path.

参数

x
The left border of the rectangle.

y
The lower border of the rectangle.

width
The width of the rectangle.

height
The height of the rectangle.

返回值

Returns TRUE on success.

错误/异常

发生错误时抛出 HaruException 异常。

HaruPage::setCharSpace

Set character spacing for the page

说明

bool HaruPage::setCharSpace ( float $char_space )

Defines character spacing for the page.

参数

char_space
The new character spacing for the page.

返回值

Returns TRUE on success.

错误/异常

发生错误时抛出 HaruException 异常。

参见

  • HaruPage::getCharSpace

HaruPage::setCMYKFill

Set filling color for the page

说明

bool HaruPage::setCMYKFill ( float $c , float $m , float $y , float $k )

Defines filling color for the page.

参数

c

m

y

k

返回值

Returns TRUE on success.

错误/异常

发生错误时抛出 HaruException 异常。

参见

  • HaruPage::getCMYKFill

HaruPage::setCMYKStroke

Set stroking color for the page

说明

bool HaruPage::setCMYKStroke ( float $c , float $m , float $y , float $k )

Defines stroking color for the page.

参数

c

m

y

k

返回值

Returns TRUE on success.

错误/异常

发生错误时抛出 HaruException 异常。

参见

  • HaruPage::getCMYKStroke

HaruPage::setDash

Set the dash pattern for the page

说明

bool HaruPage::setDash ( array $pattern , int $phase )

Defines the dash pattern for the page.

参数

pattern
An array (8 elements max) which contains a pattern of dashes and gaps used for lines on the page.

phase
The phase on which the pattern begins.

返回值

Returns TRUE on success.

错误/异常

发生错误时抛出 HaruException 异常。

参见

  • HaruPage::getDash

HaruPage::setFlatness

Set flatness for the page

说明

bool HaruPage::setFlatness ( float $flatness )

Defines flatness for the page.

参数

flatness
The defined flatness for the page.

返回值

Returns TRUE on success.

错误/异常

发生错误时抛出 HaruException 异常。

参见

  • HaruPage::getFlatness

HaruPage::setFontAndSize

Set font and fontsize for the page

说明

bool HaruPage::setFontAndSize ( object $font , float $size )

Defines current font and its size for the page.

参数

font
A valid HaruFont instance.

size
The size of the font.

返回值

Returns TRUE on success.

错误/异常

发生错误时抛出 HaruException 异常。

参见

  • HaruDoc::getFont

HaruPage::setGrayFill

Set filling color for the page

说明

bool HaruPage::setGrayFill ( float $value )

Defines filling color for the page.

参数

value
The value of gray level between 0 and 1.

返回值

Returns TRUE on success.

错误/异常

发生错误时抛出 HaruException 异常。

参见

  • HaruPage::getGrayFill

HaruPage::setGrayStroke

Sets stroking color for the page

说明

bool HaruPage::setGrayStroke ( float $value )

Defines stroking color for the page.

参数

value
The value of gray level between 0 and 1.

返回值

Returns TRUE on success.

错误/异常

发生错误时抛出 HaruException 异常。

参见

  • HaruPage::getGrayStroke

HaruPage::setHeight

Set height of the page

说明

bool HaruPage::setHeight ( float $height )

Defines height of the page.

参数

height
The defined height for the page.

返回值

Returns TRUE on success.

错误/异常

发生错误时抛出 HaruException 异常。

参见

  • HaruPage::getHeight

HaruPage::setHorizontalScaling

Set horizontal scaling for the page

说明

bool HaruPage::setHorizontalScaling ( float $scaling )

Set the horizontal scaling for the page.

参数

scaling
The horizontal scaling for text showing on the page. The initial value is 100.

返回值

Returns TRUE on success.

错误/异常

发生错误时抛出 HaruException 异常。

参见

  • HaruPage::getHorizontalScaling

HaruPage::setLineCap

Set the shape to be used at the ends of lines

说明

bool HaruPage::setLineCap ( int $cap )

Defines the shape to be used at the ends of lines.

参数

cap
Must be one of the following values:

  • HaruPage::BUTT_END - the line is squared off at the endpoint of the path.
  • HaruPage::ROUND_END - the end of the line becomes a semicircle with center in the end point of the path.
  • HaruPage::PROJECTING_SCUARE_END - the line continues to the point that exceeds half of the stroke width the end point.

返回值

Returns TRUE on success.

错误/异常

发生错误时抛出 HaruException 异常。

参见

  • HaruPage::getLineCap

HaruPage::setLineJoin

Set line join style for the page

说明

bool HaruPage::setLineJoin ( int $join )

Defines line join style for the page.

参数

join
Must be one of the following values:

  • HaruPage::MITER_JOIN
  • HaruPage::ROUND_JOIN
  • HaruPage::BEVEL_JOIN

返回值

Returns TRUE on success.

错误/异常

发生错误时抛出 HaruException 异常。

参见

  • HaruPage::getLineJoin

HaruPage::setLineWidth

Set line width for the page

说明

bool HaruPage::setLineWidth ( float $width )

Defines line width for the page.

参数

width
The defined line width for the page.

返回值

Returns TRUE on success.

错误/异常

发生错误时抛出 HaruException 异常。

参见

  • HaruPage::getLineWidth

HaruPage::setMiterLimit

Set the current value of the miter limit of the page

说明

bool HaruPage::setMiterLimit ( float $limit )

Set the current value of the miter limit of the page.

参数

limit
Defines the current value of the miter limit of the page.

返回值

Returns TRUE on success.

错误/异常

发生错误时抛出 HaruException 异常。

参见

  • HaruPage::getMiterLimit

HaruPage::setRGBFill

Set filling color for the page

说明

bool HaruPage::setRGBFill ( float $r , float $g , float $b )

Defines filling color for the page. All values must be between 0 and 1.

参数

r

g

b

返回值

Returns TRUE on success.

错误/异常

发生错误时抛出 HaruException 异常。

参见

  • HaruPage::getRGBFill

HaruPage::setRGBStroke

Set stroking color for the page

说明

bool HaruPage::setRGBStroke ( float $r , float $g , float $b )

Defines stroking color for the page. All values must be between 0 and 1.

参数

r

g

b

返回值

Returns TRUE on success.

错误/异常

发生错误时抛出 HaruException 异常。

参见

  • HaruPage::getRGBStroke

HaruPage::setRotate

Set rotation angle of the page

说明

bool HaruPage::setRotate ( int $angle )

Defines rotation angle of the page.

参数

angle
Must be a multiple of 90 degrees.

返回值

Returns TRUE on success.

错误/异常

发生错误时抛出 HaruException 异常。

HaruPage::setSize

Set size and direction of the page

说明

bool HaruPage::setSize ( int $size , int $direction )

Changes size and direction of the page to a predefined format.

参数

size
Must be one of the following values:

  • HaruPage::SIZE_LETTER
  • HaruPage::SIZE_LEGAL
  • HaruPage::SIZE_A3
  • HaruPage::SIZE_A4
  • HaruPage::SIZE_A5
  • HaruPage::SIZE_B4
  • HaruPage::SIZE_B5
  • HaruPage::SIZE_EXECUTIVE
  • HaruPage::SIZE_US4x6
  • HaruPage::SIZE_US4x8
  • HaruPage::SIZE_US5x7
  • HaruPage::SIZE_COMM10

direction
Must be one of the following values:

  • HaruPage::PORTRAIT
  • HaruPage::LANDSCAPE

返回值

Returns TRUE on success.

错误/异常

发生错误时抛出 HaruException 异常。

参见

  • HaruPage::setWidth
  • HaruPage::setHeight

HaruPage::setSlideShow

Set transition style for the page

说明

bool HaruPage::setSlideShow ( int $type , float $disp_time , float $trans_time )

Defines transition style for the page.

参数

type
Must be one of the following values:

  • HaruPage::TS_WIPE_RIGHT
  • HaruPage::TS_WIPE_LEFT
  • HaruPage::TS_WIPE_UP
  • HaruPage::TS_WIPE_DOWN
  • HaruPage::TS_BARN_DOORS_HORIZONTAL_OUT
  • HaruPage::TS_BARN_DOORS_HORIZONTAL_IN
  • HaruPage::TS_BARN_DOORS_VERTICAL_OUT
  • HaruPage::TS_BARN_DOORS_VERTICAL_IN
  • HaruPage::TS_BOX_OUT
  • HaruPage::TS_BOX_IN
  • HaruPage::TS_BLINDS_HORIZONTAL
  • HaruPage::TS_BLINDS_VERTICAL
  • HaruPage::TS_DISSOLVE
  • HaruPage::TS_GLITTER_RIGHT
  • HaruPage::TS_GLITTER_DOWN
  • HaruPage::TS_GLITTER_TOP_LEFT_TO_BOTTOM_RIGHT
  • HaruPage::TS_REPLACE

disp_time
The display duration of the page in seconds.

trans_time
The duration of the transition effect in seconds.

返回值

Returns TRUE on success.

错误/异常

发生错误时抛出 HaruException 异常。

HaruPage::setTextLeading

Set text leading (line spacing) for the page

说明

bool HaruPage::setTextLeading ( float $text_leading )

Set the text leading (line spacing) for the page.

参数

text_leading
Defines line spacing for the page.

返回值

Returns TRUE on success.

错误/异常

发生错误时抛出 HaruException 异常。

参见

  • HaruPage::getTextLeading

HaruPage::setTextMatrix

Set the current text transformation matrix of the page

说明

bool HaruPage::setTextMatrix ( float $a , float $b , float $c , float $d , float $x , float $y )

Defines the text transformation matrix of the page.

参数

a
Width multiplier.

b
Vertical skew in radians.

c
Horizontal skew in radians.

d
Height multiplier.

x
Horizontal position for text.

y
Vertical position for text.

返回值

Returns TRUE on success.

错误/异常

发生错误时抛出 HaruException 异常。

参见

  • HaruPage::getTextMatrix

HaruPage::setTextRenderingMode

Set text rendering mode for the page

说明

bool HaruPage::setTextRenderingMode ( int $mode )

Defines text rendering mode for the page.

参数

mode
Must be one of the following values:

  • HaruPage::FILL
  • HaruPage::STROKE
  • HaruPage::FILL_THEN_STROKE
  • HaruPage::INVISIBLE
  • HaruPage::FILL_CLIPPING
  • HaruPage::STROKE_CLIPPING
  • HaruPage::FILL_STROKE_CLIPPING
  • HaruPage::CLIPPING

返回值

Returns TRUE on success.

错误/异常

发生错误时抛出 HaruException 异常。

参见

  • HaruPage::getTextRenderingMode

HaruPage::setTextRise

Set the current value of text rising

说明

bool HaruPage::setTextRise ( float $rise )

Set the current value of text rising.

参数

rise
Defines the current value of text rising.

返回值

Returns TRUE on success.

错误/异常

发生错误时抛出 HaruException 异常。

参见

  • HaruPage::getTextRise

HaruPage::setWidth

Set width of the page

说明

bool HaruPage::setWidth ( float $width )

Set the width of the page.

参数

width
Defines width of the page.

返回值

Returns TRUE on success.

错误/异常

发生错误时抛出 HaruException 异常。

参见

  • HaruPage::getWidth

HaruPage::setWordSpace

Set word spacing for the page

说明

bool HaruPage::setWordSpace ( float $word_space )

Set the word spacing for the page.

参数

word_space
Defines word spacing for the page.

返回值

Returns TRUE on success.

错误/异常

发生错误时抛出 HaruException 异常。

参见

  • HaruPage::getWordSpace

HaruPage::showText

Print text at the current position of the page

说明

bool HaruPage::showText ( string $text )

Prints out the text at the current position of the page.

参数

text
The text to show.

返回值

Returns TRUE on success.

错误/异常

发生错误时抛出 HaruException 异常。

参见

  • HaruPage::showTextNextLine
  • HaruPage::textOut

HaruPage::showTextNextLine

Move the current position to the start of the next line and print the text

说明

bool HaruPage::showTextNextLine ( string $text [, float $word_space = 0 [, float $char_space = 0 ]] )

Moves the current position to the start of the next line and print out the text.

参数

text
The text to show.

word_space
The word spacing.

char_space
The character spacing.

返回值

Returns TRUE on success.

错误/异常

发生错误时抛出 HaruException 异常。

参见

  • HaruPage::showText
  • HaruPage::textOut

HaruPage::stroke

Paint current path

说明

bool HaruPage::stroke ([ bool $close_path = FALSE ] )

Paints the current path.

参数

close_path
Closes the current path if set to TRUE.

返回值

Returns TRUE on success.

错误/异常

发生错误时抛出 HaruException 异常。

HaruPage::textOut

Print the text on the specified position

说明

bool HaruPage::textOut ( float $x , float $y , string $text )

Prints the text on the specified position.

参数

x

y

text

返回值

Returns TRUE on success.

错误/异常

发生错误时抛出 HaruException 异常。

参见

  • HaruPage::showTextNextLine
  • HaruPage::showText

HaruPage::textRect

Print the text inside the specified region

说明

bool HaruPage::textRect ( float $left , float $top , float $right , float $bottom , string $text [, int $align = HaruPage::TALIGN_LEFT ] )

Prints the text inside the specified region.

参数

left
Left border of the text area.

top
Top border of the text area.

right
Right border of the text area.

bottom
Lower border of the text area.

text
The text to print.

align
Text alignment. Must be one of the following values:

  • HaruPage::TALIGN_LEFT
  • HaruPage::TALIGN_RIGHT
  • HaruPage::TALIGN_CENTER
  • HaruPage::TALIGN_JUSTIFY

返回值

Returns TRUE on success.

错误/异常

发生错误时抛出 HaruException 异常。

参见

  • HaruPage::showTextNextLine
  • HaruPage::showText
  • HaruPage::textOut

简介

Haru PDF Font Class.

类摘要

HaruFont

class HaruFont {

/* 方法 */

int getAscent ( void )

int getCapHeight ( void )

int getDescent ( void )

string getEncodingName ( void )

string getFontName ( void )

array getTextWidth ( string $text )

int getUnicodeWidth ( int $character )

int getXHeight ( void )

int measureText ( string $text , float $width , float $font_size , float $char_space , float $word_space [, bool $word_wrap = FALSE ] )

}

HaruFont::getAscent

Get the vertical ascent of the font

说明

int HaruFont::getAscent ( void )

Get the vertical ascent of the font.

参数

此函数没有参数。

返回值

Returns the vertical ascent of the font.

错误/异常

发生错误时抛出 HaruException 异常。

HaruFont::getCapHeight

Get the distance from the baseline of uppercase letters

说明

int HaruFont::getCapHeight ( void )

Get the distance from the baseline of uppercase letters.

参数

此函数没有参数。

返回值

Returns the distance from the baseline of uppercase letters.

错误/异常

发生错误时抛出 HaruException 异常。

HaruFont::getDescent

Get the vertical descent of the font

说明

int HaruFont::getDescent ( void )

Get the vertical descent of the font.

参数

此函数没有参数。

返回值

Return the vertical descent of the font.

错误/异常

发生错误时抛出 HaruException 异常。

HaruFont::getEncodingName

Get the name of the encoding

说明

string HaruFont::getEncodingName ( void )

Get the name of the font encoding.

参数

此函数没有参数。

返回值

Returns the name of the font encoding.

错误/异常

发生错误时抛出 HaruException 异常。

HaruFont::getFontName

Get the name of the font

说明

string HaruFont::getFontName ( void )

Get the name of the font.

参数

此函数没有参数。

返回值

Returns the name of the font.

错误/异常

发生错误时抛出 HaruException 异常。

HaruFont::getTextWidth

Get the total width of the text, number of characters, number of words and number of spaces

说明

array HaruFont::getTextWidth ( string $text )

Get the total width of the text, number of characters, number of words and number of spaces.

参数

text
The text to measure.

返回值

Returns the total width of the text, number of characters, number of words and number of spaces in the given text.

错误/异常

发生错误时抛出 HaruException 异常。

HaruFont::getUnicodeWidth

Get the width of the character in the font

说明

int HaruFont::getUnicodeWidth ( int $character )

Get the width of the character in the font.

参数

character
The code of the character.

返回值

Returns the width of the character in the font.

错误/异常

发生错误时抛出 HaruException 异常。

HaruFont::getXHeight

Get the distance from the baseline of lowercase letters

说明

int HaruFont::getXHeight ( void )

Gets the distance from the baseline of lowercase letters.

参数

此函数没有参数。

返回值

Returns the distance from the baseline of lowercase letters.

错误/异常

发生错误时抛出 HaruException 异常。

HaruFont::measureText

Calculate the number of characters which can be included within the specified width

说明

int HaruFont::measureText ( string $text , float $width , float $font_size , float $char_space , float $word_space [, bool $word_wrap = FALSE ] )

Calculate the number of characters which can be included within the specified width.

参数

text
The text to fit the width.

width
The width of the area to put the text to.

font_size
The size of the font.

char_space
The character spacing.

word_space
The word spacing.

word_wrap
When this parameter is set to TRUE the function "emulates" word wrapping and doesn't include the part of the current word if reached the end of the area.

返回值

Returns the number of characters which can be included within the specified width.

错误/异常

发生错误时抛出 HaruException 异常。

简介

Haru PDF Image Class.

类摘要

HaruImage

class HaruImage {

/* 方法 */

int getBitsPerComponent ( void )

string getColorSpace ( void )

int getHeight ( void )

array getSize ( void )

int getWidth ( void )

bool setColorMask ( int $rmin , int $rmax , int $gmin , int $gmax , int $bmin , int $bmax )

bool setMaskImage ( object $mask_image )

}

HaruImage::getBitsPerComponent

Get the number of bits used to describe each color component of the image

说明

int HaruImage::getBitsPerComponent ( void )

Gets the number of bits used to describe each color component of the image.

参数

此函数没有参数。

返回值

Returns the number of bits used to describe each color component of the image.

错误/异常

发生错误时抛出 HaruException 异常。

HaruImage::getColorSpace

Get the name of the color space

说明

string HaruImage::getColorSpace ( void )

Get the name of the color space.

参数

此函数没有参数。

返回值

Returns the name of the color space of the image. The name is one of the following values:

  • "DeviceGray"
  • "DeviceRGB"
  • "DeviceCMYK"
  • "Indexed"

错误/异常

发生错误时抛出 HaruException 异常。

HaruImage::getHeight

Get the height of the image

说明

int HaruImage::getHeight ( void )

Get the height of the image.

参数

此函数没有参数。

返回值

Returns the height of the image.

错误/异常

发生错误时抛出 HaruException 异常。

HaruImage::getSize

Get size of the image

说明

array HaruImage::getSize ( void )

Get the size of the image.

参数

此函数没有参数。

返回值

Returns an array with two elements: width and height, which contain appropriate dimensions of the image.

错误/异常

发生错误时抛出 HaruException 异常。

HaruImage::getWidth

Get the width of the image

说明

int HaruImage::getWidth ( void )

Get the width of the image.

参数

此函数没有参数。

返回值

Returns the width of the image.

错误/异常

发生错误时抛出 HaruException 异常。

HaruImage::setColorMask

Set the color mask of the image

说明

bool HaruImage::setColorMask ( int $rmin , int $rmax , int $gmin , int $gmax , int $bmin , int $bmax )

Defines the transparent color of the image using the RGB range values. The color within the range is displayed as a transparent color. The color space of the image must be RGB.

参数

rmin
The lower limit of red. Must be between 0 and 255.

rmax
The upper limit of red. Must be between 0 and 255.

gmin
The lower limit of green. Must be between 0 and 255.

gmax
The upper limit of green. Must be between 0 and 255.

bmin
The lower limit of blue. Must be between 0 and 255.

bmax
The upper limit of blue. Must be between 0 and 255.

返回值

Returns TRUE on success.

错误/异常

发生错误时抛出 HaruException 异常。

HaruImage::setMaskImage

Set the image mask

说明

bool HaruImage::setMaskImage ( object $mask_image )

Sets the image used as image-mask. It must be 1bit gray-scale color image.

参数

mask_image
A valid HaruImage instance.

返回值

Returns TRUE on success.

错误/异常

发生错误时抛出 HaruException 异常。

简介

Haru PDF Encoder Class.

类摘要

HaruEncoder

class HaruEncoder {

/* 方法 */

int getByteType ( string $text , int $index )

int getType ( void )

int getUnicode ( int $character )

int getWritingMode ( void )

}

预定义常量

TypeNameDescription
intHaruEncoder::TYPE_SINGLE_BYTE 
intHaruEncoder::TYPE_DOUBLE_BYTE 
intHaruEncoder::TYPE_UNINITIALIZED 
intHaruEncoder::UNKNOWN 
intHaruEncoder::WMODE_HORIZONTAL 
intHaruEncoder::WMODE_VERTICAL 
intHaruEncoder::BYTE_TYPE_SINGLE 
intHaruEncoder::BYTE_TYPE_LEAD 
intHaruEncoder::BYTE_TYPE_TRAIL 
intHaruEncoder::BYTE_TYPE_UNKNOWN 

HaruEncoder::getByteType

Get the type of the byte in the text

说明

int HaruEncoder::getByteType ( string $text , int $index )

Get the type of the byte in the text.

参数

text
The text.

index
The position in the text.

返回值

Returns the type of the byte in the text on the specified position. The result is one of the following values:

  • HaruEncoder::BYTE_TYPE_SINGLE - single byte character.
  • HaruEncoder::BYTE_TYPE_LEAD - lead byte of a double-byte character.
  • HaruEncoder::BYTE_TYPE_TRAIL - trailing byte of a double-byte character.
  • HaruEncoder::BYTE_TYPE_UNKNOWN - invalid encoder or cannot detect the byte type.

错误/异常

发生错误时抛出 HaruException 异常。

HaruEncoder::getType

Get the type of the encoder

说明

int HaruEncoder::getType ( void )

Get the type of the encoder.

参数

此函数没有参数。

返回值

Returns the type of the encoder. The result is one of the following values:

  • HaruEncoder::TYPE_SINGLE_BYTE - the encoder is for single byte characters.
  • HaruEncoder::TYPE_DOUBLE_BYTE - the encoder is for multibyte characters.
  • HaruEncoder::TYPE_UNINITIALIZED - the encoder is not initialized.
  • HaruEncoder::UNKNOWN - the encoder is invalid.

错误/异常

发生错误时抛出 HaruException 异常。

HaruEncoder::getUnicode

Convert the specified character to unicode

说明

int HaruEncoder::getUnicode ( int $character )

Converts the specified character to unicode.

参数

character
The character code to convert.

返回值

错误/异常

发生错误时抛出 HaruException 异常。

HaruEncoder::getWritingMode

Get the writing mode of the encoder

说明

int HaruEncoder::getWritingMode ( void )

Get the writing mode of the encoder.

参数

此函数没有参数。

返回值

Returns the writing mode of the encoder. The result value is on of the following:

  • HaruEncoder::WMODE_HORIZONTAL - horizontal writing mode.
  • HaruEncoder::WMODE_VERTICAL - vertical writing mode.

错误/异常

发生错误时抛出 HaruException 异常。

简介

Haru PDF Outline Class.

类摘要

HaruOutline

class HaruOutline {

/* 方法 */

bool setDestination ( object $destination )

bool setOpened ( bool $opened )

}

HaruOutline::setDestination

Set the destination for the outline

说明

bool HaruOutline::setDestination ( object $destination )

Sets a destination object which becomes a target to jump to when the outline is clicked.

参数

destination
A valid HaruDestination instance.

返回值

Returns TRUE on success.

错误/异常

发生错误时抛出 HaruException 异常。

HaruOutline::setOpened

Set the initial state of the outline

说明

bool HaruOutline::setOpened ( bool $opened )

Defines whether this node is opened or not when the outline is displayed for the first time.

参数

opened
TRUE means open, FALSE - closed.

返回值

Returns TRUE on success.

错误/异常

发生错误时抛出 HaruException 异常。

简介

Haru PDF Annotation Class.

类摘要

HaruAnnotation

class HaruAnnotation {

/* 方法 */

bool setBorderStyle ( float $width , int $dash_on , int $dash_off )

bool setHighlightMode ( int $mode )

bool setIcon ( int $icon )

bool setOpened ( bool $opened )

}

预定义常量

TypeNameDescription
intHaruAnnotation::NO_HIGHLIGHT 
intHaruAnnotation::INVERT_BOX 
intHaruAnnotation::INVERT_BORDER 
intHaruAnnotation::DOWN_APPEARANCE 
intHaruAnnotation::ICON_COMMENT 
intHaruAnnotation::ICON_KEY 
intHaruAnnotation::ICON_NOTE 
intHaruAnnotation::ICON_HELP 
intHaruAnnotation::ICON_NEW_PARAGRAPH 
intHaruAnnotation::ICON_PARAGRAPH 
intHaruAnnotation::ICON_INSERT 

HaruAnnotation::setBorderStyle

Set the border style of the annotation

说明

bool HaruAnnotation::setBorderStyle ( float $width , int $dash_on , int $dash_off )

Defines the style of the border of the annotation. This function may be used with link annotations only.

参数

width
The width of the border line.

dash_on
The dash style.

dash_off
The dash style.

返回值

Returns TRUE on success.

错误/异常

发生错误时抛出 HaruException 异常。

HaruAnnotation::setHighlightMode

Set the highlighting mode of the annotation

说明

bool HaruAnnotation::setHighlightMode ( int $mode )

Defines the appearance of the annotation when clicked. This function may be used with link annotations only.

参数

mode
The highlighting mode of the annotation. Can take only these values:

  • HaruAnnotation::NO_HIGHLIGHT - no highlighting.
  • HaruAnnotation::INVERT_BOX - invert the contents of the annotation.
  • HaruAnnotation::INVERT_BORDER - invert the border of the annotation.
  • HaruAnnotation::DOWN_APPEARANCE - dent the annotation.

返回值

Returns TRUE on success.

错误/异常

发生错误时抛出 HaruException 异常。

HaruAnnotation::setIcon

Set the icon style of the annotation

说明

bool HaruAnnotation::setIcon ( int $icon )

Defines the style of the annotation icon. This function may be used with text annotations only.

参数

icon
The style of the icon. Can take only these values:

  • HaruAnnotation::ICON_COMMENT
  • HaruAnnotation::ICON_KEY
  • HaruAnnotation::ICON_NOTE
  • HaruAnnotation::ICON_HELP
  • HaruAnnotation::ICON_NEW_PARAGRAPH
  • HaruAnnotation::ICON_PARAGRAPH
  • HaruAnnotation::ICON_INSERT

返回值

Returns TRUE on success.

错误/异常

发生错误时抛出 HaruException 异常。

HaruAnnotation::setOpened

Set the initial state of the annotation

说明

bool HaruAnnotation::setOpened ( bool $opened )

Defines whether the annotation is initially displayed open. This function may be used with text annotations only.

参数

opened
TRUE means the annotation is initially displayed open, FALSE

  • means it's closed.

返回值

Returns TRUE on success.

错误/异常

发生错误时抛出 HaruException 异常。

简介

Haru PDF Destination Class.

类摘要

HaruDestination

class HaruDestination {

/* 方法 */

bool setFit ( void )

bool setFitB ( void )

bool setFitBH ( float $top )

bool setFitBV ( float $left )

bool setFitH ( float $top )

bool setFitR ( float $left , float $bottom , float $right , float $top )

bool setFitV ( float $left )

bool setXYZ ( float $left , float $top , float $zoom )

}

HaruDestination::setFit

Set the appearance of the page to fit the window

说明

bool HaruDestination::setFit ( void )

Defines the appearance of the page to fit the window.

参数

此函数没有参数。

返回值

Returns TRUE on success.

错误/异常

发生错误时抛出 HaruException 异常。

HaruDestination::setFitB

Set the appearance of the page to fit the bounding box of the page within the window

说明

bool HaruDestination::setFitB ( void )

Defines the appearance of the page to fit the bounding box of the page within the window.

参数

此函数没有参数。

返回值

Returns TRUE on success.

错误/异常

发生错误时抛出 HaruException 异常。

HaruDestination::setFitBH

Set the appearance of the page to fit the width of the bounding box

说明

bool HaruDestination::setFitBH ( float $top )

Defines the appearance of the page to magnifying to fit the width of the bounding box and setting the top position of the page to the value of top.

参数

top
The top coordinates of the page.

返回值

Returns TRUE on success.

错误/异常

发生错误时抛出 HaruException 异常。

HaruDestination::setFitBV

Set the appearance of the page to fit the height of the boudning box

说明

bool HaruDestination::setFitBV ( float $left )

Defines the appearance of the page to magnifying to fit the height of the bounding box and setting the left position of the page to the value of left.

参数

left
The left coordinates of the page.

返回值

Returns TRUE on success.

错误/异常

发生错误时抛出 HaruException 异常。

HaruDestination::setFitH

Set the appearance of the page to fit the window width

说明

bool HaruDestination::setFitH ( float $top )

Defines the appearance of the page to fit the window width and sets the top position of the page to the value of top.

参数

top
The top position of the page.

返回值

Returns TRUE on success.

错误/异常

发生错误时抛出 HaruException 异常。

HaruDestination::setFitR

Set the appearance of the page to fit the specified rectangle

说明

bool HaruDestination::setFitR ( float $left , float $bottom , float $right , float $top )

Defines the appearance of the page to fit the rectangle by the parameters.

参数

left
The left coordinates of the page.

bottom
The bottom coordinates of the page.

right
The right coordinates of the page.

top
The top coordinates of the page.

返回值

Returns TRUE on success.

错误/异常

发生错误时抛出 HaruException 异常。

HaruDestination::setFitV

Set the appearance of the page to fit the window height

说明

bool HaruDestination::setFitV ( float $left )

Defines the appearance of the page to fit the window height.

参数

left
The left position of the page.

返回值

Returns TRUE on success.

错误/异常

发生错误时抛出 HaruException 异常。

HaruDestination::setXYZ

Set the appearance of the page

说明

bool HaruDestination::setXYZ ( float $left , float $top , float $zoom )

Defines the appearance of the page using three parameters: left, top and zoom.

参数

left
The left position of the page.

top
The top position of the page.

zoom
The magnification factor. The value must be between 0.08 (8%) and 32 (3200%).

返回值

Returns TRUE on success.

错误/异常

发生错误时抛出 HaruException 异常。