PHP Haru PDF Functions

EditRocket provides the following information on Haru PDF functions in the PHP source code builder.

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.

bool HaruAnnotation::setHighlightMode ( int $mode ) - Defines the appearance of the annotation when clicked. This function may be used with link annotations only.

bool HaruAnnotation::setIcon ( int $icon ) - Defines the style of the annotation icon. This function may be used with text annotations only.

bool HaruAnnotation::setOpened ( bool $opened ) - Defines whether the annotation is initially displayed open. This function may be used with text annotations only.

bool HaruDestination::setFit ( void ) - Defines the appearance of the page to fit the window.

bool HaruDestination::setFitB ( void ) - Defines the appearance of the page to fit the bounding box of the page within the window.

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.

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.

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.

bool HaruDestination::setFitR ( float $left , float $bottom , float $right , float $top ) - Defines the appearance of the page to fit the rectangle by the parameters.

bool HaruDestination::setFitV ( float $left ) - Defines the appearance of the page to fit the window height.

bool HaruDestination::setXYZ ( float $left , float $top , float $zoom ) - Defines the appearance of the page using three parameters: left, top and zoom.

object HaruDoc::addPage ( void ) - Adds new page to the document and returns new HaruPage instance.

bool HaruDoc::addPageLabel ( int $first_page , int $style , int $first_num [, string $prefix ] ) - Set the numbering style for the specified range of pages.

void HaruDoc::__construct ( void ) - Constructs new HaruDoc instance.

object HaruDoc::createOutline ( string $title [, object $parent_outline [, object $encoder ]] ) - Creates and returns new HaruOutline instance.

object HaruDoc::getCurrentEncoder ( void ) - Returns HaruEncoder currently used in the document or FALSE if encoder is not set.

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.

object HaruDoc::getEncoder ( string $encoding ) - Returns HaruEncoder instance for the specified encoding.

object HaruDoc::getFont ( string $fontname [, string $encoding ] ) - Creates and returns HaruFont instance with the specified fontname and encoding.

string HaruDoc::getInfoAttr ( int $type ) - Returns the string value of the specified document attribute.

int HaruDoc::getPageLayout ( void ) - Returns the page layout currently set in the document or FALSE if page layout was not set.

int HaruDoc::getPageMode ( void ) - Returns the page mode currently set in the document.

int HaruDoc::getStreamSize ( void ) - 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.

object HaruDoc::insertPage ( object $page ) - Creates new page and inserts just before the specified page. Returns new HaruPage instance.

object HaruDoc::loadJPEG ( string $filename ) - Loads the specified JPEG image and returns new HaruImage instance.

object HaruDoc::loadPNG ( string $filename [, bool $deferred ] ) - Loads PNG image and returns HaruImage instance. You can set deferred parameter to TRUE for deferred data loading, in this case only size and color are loaded immediately. Default value of deferred is FALSE.

object HaruDoc::loadRaw ( string $filename , int $width , int $height , int $color_space ) - Loads RAW image and returns new HaruImage instance.

string HaruDoc::loadTTC ( string $fontfile , int $index [, bool $embed ] ) - Loads the TrueType font with the specified index from a TrueType collection file.

string HaruDoc::loadTTF ( string $fontfile [, bool $embed ] ) - Loads the given TTF file and (optionally) embed its data into the document.

string HaruDoc::loadType1 ( string $afmfile [, string $pfmfile ] ) - Loads Type1 font from the given file and registers it in the PDF document.

bool HaruDoc::output ( void ) - Writes the document data into standard output.

string HaruDoc::readFromStream ( int $bytes ) - Returns data from the temporary stream. The bytes parameter specifies how much bytes to read, though the stream may contain less bytes than requested.

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.

bool HaruDoc::resetStream ( void ) - Rewinds the temporary stream of the document.

bool HaruDoc::save ( string $file ) - Saves the document into the specified file.

bool HaruDoc::saveToStream ( void ) - Saves the document data into a temporary stream.

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.

bool HaruDoc::setCurrentEncoder ( string $encoding ) - Defines the encoder currently used in the document.

bool HaruDoc::setEncryptionMode ( int $mode [, int $key_len ] ) - Defines encryption mode for the document. The encryption mode cannot be set before setting the password.

bool HaruDoc::setInfoAttr ( int $type , string $info ) - Defines an info attribute. Uses the current encoding 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.

bool HaruDoc::setOpenAction ( object $destination ) - Defines wich page should be shown when the document is opened.

bool HaruDoc::setPageLayout ( int $layout ) - Defines how pages should be displayed.

bool HaruDoc::setPageMode ( int $mode ) - Defines how the document should be displayed.

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.

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.

bool HaruDoc::setPermission ( int $permission ) - Defines permissions for the document.

bool HaruDoc::useCNSEncodings ( void ) - Enables Chinese simplified encodings.

bool HaruDoc::useCNSFonts ( void ) - Enableis builtin Chinese simplified fonts.

bool HaruDoc::useCNTEncodings ( void ) - Enables Chinese traditional encodings.

bool HaruDoc::useCNTFonts ( void ) - Enables builtin Chinese traditional fonts.

bool HaruDoc::useJPEncodings ( void ) - Enables Japanese encodings.

bool HaruDoc::useJPFonts ( void ) - Enables builtin Japanese fonts.

bool HaruDoc::useKREncodings ( void ) - Enables Korean encodings.

bool HaruDoc::useKRFonts ( void ) - Enables builtin Korean fonts.

int HaruEncoder::getByteType ( string $text , int $index ) - 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.

int HaruEncoder::getType ( void ) - Returns the type of the encoder. The result is one of the followin 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.

int HaruEncoder::getUnicode ( int $character ) - Converts the specified character to unicode.

int HaruEncoder::getWritingMode ( void ) - 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.

int HaruFont::getAscent ( void ) - Returns the vertical ascent of the font.

int HaruFont::getCapHeight ( void ) - Returns the distance from the baseline of uppercase letters.

int HaruFont::getDescent ( void ) - Return the vertical descent of the font.

string HaruFont::getEncodingName ( void ) - Returns the name of the font encoding.

string HaruFont::getFontName ( void ) - Returns the name of the font.

array HaruFont::getTextWidth ( string $text ) - Returns the total width of the text, number of characters, number of words and number of spaces in the given text.

int HaruFont::getUnicodeWidth ( int $character ) - Returns the width of the character in the font.

int HaruFont::getXHeight ( void ) - Returns the distance from the baseline of lowercase letters.

int HaruFont::measureText ( string $text , float $width , float $font_size , float $char_space , float $word_space [, bool $word_wrap ] ) - Returns the number of characters which can be included within the specified width.

int HaruImage::getBitsPerComponent ( void ) - Returns the number of bits used to describe each color component of the image.

string HaruImage::getColorSpace ( void ) - Returns the name of the color space of the image. The name is one of the following values: DeviceGray, DeviceRGB, DeviceCMYK, Indexed

int HaruImage::getHeight ( void ) - Returns the height of the image.

array HaruImage::getSize ( void ) - Returns an array with two elements: width and height, which contain appropriate dimensions of the image.

int HaruImage::getWidth ( void ) - Returns the width 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.

bool HaruImage::setMaskImage ( object $mask_image ) - Sets the image used as image-mask. It must be 1bit gray-scale color image.

bool HaruOutline::setDestination ( object $destination ) - Sets a destination object which becomes a target to jump to when the outline is clicked.

bool HaruOutline::setOpened ( bool $opened ) - Defines whether this node is opened or not when the outline is displayed for the first time.

bool HaruPage::arc ( float $x , float $y , float $ray , float $ang1 , float $ang2 ) - Appends an arc to the current path.

bool HaruPage::beginText ( void ) - Begins new text object and sets the current text position to (0,0).

bool HaruPage::circle ( float $x , float $y , float $ray ) - Appends a circle to the current path.

bool HaruPage::closePath ( void ) - Appends a straight line from the current point to the start point of the path.

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.

object HaruPage::createDestination ( void ) - Creates and returns new HaruDestination instance.

object HaruPage::createLinkAnnotation ( array $rectangle , object $destination ) - Creates and returns new HaruAnnotation instance.

object HaruPage::createTextAnnotation ( array $rectangle , string $text [, object $encoder ] ) - Creates and returns new HaruAnnotation instance.

object HaruPage::createURLAnnotation ( array $rectangle , string $url ) - Creates and returns new HaruAnnotation instance.

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

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

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

bool HaruPage::drawImage ( object $image , float $x , float $y , float $width , float $height ) - Show image at the page.

bool HaruPage::ellipse ( float $x , float $y , float $xray , float $yray ) - Appends an ellipse to the current path.

bool HaruPage::endPath ( void ) - Ends current path object without performing filling and painting operations.

bool HaruPage::endText ( void ) - Finalizes current text object.

bool HaruPage::eofill ( void ) - Fills current path using even-odd rule.

bool HaruPage::eoFillStroke ([ bool $close_path ] ) - Fills current path using even-odd rule, then paints the path.

bool HaruPage::fill ( void ) - Fills current path using nonzero winding number rule.

bool HaruPage::fillStroke ([ bool $close_path ] ) - Fills current path using nonzero winding number rule, then paints the path.

float HaruPage::getCharSpace ( void ) - Returns the current value of character spacing.

array HaruPage::getCMYKFill ( void ) - Returns the current filling color as an array with 4 elements (c, m, y and k).

array HaruPage::getCMYKStroke ( void ) - Returns the current stroking color as an array with 4 elements (c, m, y and k).

object HaruPage::getCurrentFont ( void ) - Returns the currently used font as an instance of HaruFont.

float HaruPage::getCurrentFontSize ( void ) - Returns the current font size.

array HaruPage::getCurrentPos ( void ) - Returns the current position for path painting as an array of with two elements - x and y.

array HaruPage::getCurrentTextPos ( void ) - Returns the current position for text printing as an array with 2 elements - x and y.

array HaruPage::getDash ( void ) - Returns the current dash pattern as an array of two elements - pattern and phase or FALSE if dash pattern was not set.

int HaruPage::getFillingColorSpace ( void ) - 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.

float HaruPage::getFlatness ( void ) - Returns the flatness of the page.

int HaruPage::getGMode ( void ) - 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.

float HaruPage::getGrayFill ( void ) - Returns the current filling color.

float HaruPage::getGrayStroke ( void ) - Returns the current stroking color.

float HaruPage::getHeight ( void ) - Returns the height of the page.

float HaruPage::getHorizontalScaling ( void ) - Returns the current value of horizontal scaling.

int HaruPage::getLineCap ( void ) - 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.

int HaruPage::getLineJoin ( void ) - Returns the current line join style. The result value is one of the following: HaruPage::MITER_JOIN. HaruPage::ROUND_JOIN. HaruPage::BEVEL_JOIN.

float HaruPage::getLineWidth ( void ) - Returns the current line width.

float HaruPage::getMiterLimit ( void ) - Returns the value of miter limit.

array HaruPage::getRGBFill ( void ) - Returns the current filling color as an array with 3 elements: r, g and b.

array HaruPage::getRGBStroke ( void ) - Returns the current stroking color.

int HaruPage::getStrokingColorSpace ( void ) - Returns the current stroking color space.

float HaruPage::getTextLeading ( void ) - Returns the current value of line spacing.

array HaruPage::getTextMatrix ( void ) - Returns the current text transformation matrix of the page as an array of 6 elements: a, b, c, d, x and y.

int HaruPage::getTextRenderingMode ( void ) - 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.

float HaruPage::getTextRise ( void ) - Returns the current value of text rising.

float HaruPage::getTextWidth ( string $text ) - Returns the width of the text using current fontsize, character spacing and word spacing.

array HaruPage::getTransMatrix ( void ) - Returns the current transformation matrix of the page as an array of 6 elements: a, b, c, d, x and y.

float HaruPage::getWidth ( void ) - Returns the width of the page.

float HaruPage::getWordSpace ( void ) - Returns the current value of word spacing.

bool HaruPage::lineTo ( float $x , float $y ) - Draws a line from the current point to the specified point.

int HaruPage::measureText ( string $text , float $width [, bool $wordwrap ] ) - Returns the number of characters which can be included within the specified width.

bool HaruPage::moveTextPos ( float $x , float $y [, bool $set_leading ] ) - 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). If optional parameter set_leading is TRUE, the function sets the text leading to -y. The default value of set_leading is FALSE.

bool HaruPage::moveTo ( float $x , float $y ) - Defines starting point for new drawing path.

bool HaruPage::moveToNextLine ( void ) - Moves text position to the start of the next line.

bool HaruPage::rectangle ( float $x , float $y , float $width , float $height ) - Appends a rectangle to the current drawing path.

bool HaruPage::setCharSpace ( float $char_space ) - Defines character spacing for the page.

bool HaruPage::setCMYKFill ( float $c , float $m , float $y , float $k ) - Defines filling color for the page.

bool HaruPage::setCMYKStroke ( float $c , float $m , float $y , float $k ) - Defines stroking color for the page.

bool HaruPage::setDash ( array $pattern , int $phase ) - Defines the dash pattern for the page.

bool HaruPage::setFlatness ( float $flatness ) - Defines flatness for the page.

bool HaruPage::setFontAndSize ( object $font , float $size ) - Defines current font and its size for the page.

bool HaruPage::setGrayFill ( float $value ) - Defines filling color for the page.

bool HaruPage::setGrayStroke ( float $value ) - Defines stroking color for the page.

bool HaruPage::setHeight ( float $height ) - Defines height of the page.

bool HaruPage::setHorizontalScaling ( float $scaling ) - Defines horizontal scaling for text showing on the page. The initial value is 100.

bool HaruPage::setLineCap ( int $cap ) - Defines the shape to be used at the ends of lines.

bool HaruPage::setLineJoin ( int $join ) - Defines line join style for the page.

bool HaruPage::setLineWidth ( float $width ) - Defines line width for the page.

bool HaruPage::setMiterLimit ( float $limit ) - Defines the current value of the miter limit of 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.

bool HaruPage::setRGBStroke ( float $r , float $g , float $b ) - Defines stroking color for the page. All values must be between 0 and 1.

bool HaruPage::setRotate ( int $angle ) - Defines rotation angle of the page.

bool HaruPage::setSize ( int $size , int $direction ) - Changes size and direction of the page to a predefined format.

bool HaruPage::setSlideShow ( int $type , float $disp_time , float $trans_time ) - Defines transition style for the page.

bool HaruPage::setTextLeading ( float $text_leading ) - Defines line spacing for 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.

bool HaruPage::setTextRenderingMode ( int $mode ) - Defines text rendering mode for the page.

bool HaruPage::setTextRise ( float $rise ) - Defines the current value of text rising.

bool HaruPage::setWidth ( float $width ) - Defines width of the page.

bool HaruPage::setWordSpace ( float $word_space ) - Defines word spacing for the page.

bool HaruPage::showText ( string $text ) - Prints out the text at the current position of the page.

bool HaruPage::showTextNextLine ( string $text [, float $word_space [, float $char_space ]] ) - Moves the current position to the start of the next line and print out the text.

bool HaruPage::stroke ([ bool $close_path ] ) - Paints the current path.

bool HaruPage::textOut ( float $x , float $y , string $text ) - Prints the text on the specified position.

bool HaruPage::textRect ( float $left , float $top , float $right , float $bottom , string $text [, int $align ] ) - Prints the text inside the specified region.