Hpdf::Page
Inherits Hpdf::Helper / Reference / Object
The page handle is used to operate an individual page.
When Doc#add_page or Doc#insert_page is invoked, a page object
is created.
Constructors
Instance methods
appends a circle to the current path.
An application can invoke arc when the graphics_mode of the
page is in GMode::PageDescription or GMode::PathObject.
- x, y the center point of the circle.
- ray the ray of the circle.
- ang1 the angle of the begining of the arc.
- ang2 the angle of the end of the arc. It must be greater than ang1.
begins a text object and sets the current text position to
the point (0, 0). An application can invoke begin_text when
the graphics mode of the page is in GMode::PageDescription.
And it changes the graphics mode to GMode::TextObject.
sets the character spacing for text showing.
The initial value of character spacing is 0.
An application can invoke char_space= when the graphics
mode of the page is in GMode::PageDescription or GMode::TextObject.
- value the value of character spacing.
appends a circle to the current path.
An application can invoke circle when the graphics_mode of the
page is in GMode::PageDescription or GMode::PathObject.
- x, y the center point of the circle.
- ray the ray of the circle.
clip modifies the current clipping path by intersecting
it with the current path using the nonzero winding number
rule. The clipping path is only modified after the succeeding
painting operator. To avoid painting the current path, use
the function end_path.
Following painting operations will only affect the regions of
the page contained by the clipping path. Initially, the
clipping path includes the entire page. There is no way to
enlarge the current clipping path, or to replace the clipping
path with a new one. The functions g_save and g_restore
may be used to save and restore the current graphics state,
including the clipping path.
appends a strait line from the current point to the start point
of sub path. The current point is moved to the start point of sub
path. An application can invoke close_path when the graphics
mode of the page is in GMode::PathObject.
closes the current path, fills the current path using the
even-odd rule, then it paints the path. An application can
invoke close_path_eofill_stroke when the graphics_mode
of the page is in GMode::PathObject or GMode::ClippingPath. And it changes the
graphics mode to GMode::PageDescription.
closes the current path, fills the current path using the
nonzero winding number rule, then it paints the path.
An application can invoke close_path_fill_stroke when the
graphics mode of the page is in GMode::PathObject or GMode::ClippingPath. And it
changes the graphics mode to GMode::PageDescription.
closes the current path, then it paints the path.
An application can invoke close_path_stroke when the graphics
mode of the page is in GMode::PathObject or GMode::ClippingPath. And it changes the
graphics mode to GMode::PageDescription.
returns the current value of the page's filling color. cmyk_fill is
valid only when the page's filling color space is ColorSpace::DeviceCmyk.
returns the current value of the page's stroking color. cmyk_stroke is
valid only when the page's stroking color space is ColorSpace::DeviceCmyk.
concatenates the page's current transformation matrix and specified
matrix. For example, if you want to rotate the coordinate system of the
page by 45 degrees, use concat as like demonstrated in the rotate method.
An application can invoke concat when the graphics_mode of the
page is in GMode::PageDescription.
Example to change the dpi using concat
concat 72 / dpi, 0, 0, 72 / dpi, 0, 0
Example rotate 45 degrees
rad1 = degree / 180 * Math::PI
context do
concat Math.cos(rad1), Math.sin(rad1), -Math.sin(rad1),
Math.cos(rad1), 0, 0
text Hpdf::Base14::Helvetica, 70 do
text_out 100, 100, "Hello World"
end
end
creates a new link annotation object for the page.
- rect a rectangle of clickable area.
- dst a handle of destination object to jump to.
creates a new text annotation object for the page.
- rect a rectangle where the annotation is displayed
- text the text to be displayed.
- encoder an encoder handle which is used to encode the text. If it is null, PDFDocEncoding is used.
creates a new web link annotation object for the page.
- rect a rectangle of clickable area.
- uri URL of destination to jump to.
creates a white rectangle form XObject within rect.
The returned XObject can be drawn repeatedly with execute_x_object.
- rect the bounding rectangle for the white rectangle XObject on the page.
wraps image as a form XObject within rect. If zoom is true, the image
is scaled to fill the rectangle.
The returned XObject can be drawn repeatedly with execute_x_object.
- rect the bounding rectangle for the XObject on the page.
- image the image to embed as a form XObject.
- zoom if
true, the image is scaled to fill rect.
gets the size of the page's current font. It returns the size of the page's current font. Otherwise it returns 0.
gets the current position for path painting. It returns a Point
struct indicating the current position for path painting of the page.
Otherwise it returns a Point struct of {0, 0}.
An application can invoke #current_pos only when graphics mode is GMode::PathObject.
gets the current position for text showing. It returns a Point struct
indicating the current position for text showing of the page.
Otherwise it returns a Point struct of {0, 0}.
An application can invoke current_text_pos only when graphics
mode is GMode::TextObject.
appends a Bézier curve to the current path using two specified points.
The point (x1, y1) and the point (x2, y2) are used as the control
points for a Bézier curve and current point is moved to the point
(x3, y3). An application can invoke curve_to when the graphics
mode of the page is in GMode::PathObject.
- x1, y1, x2, y2, x3, y3 the control points for a Bézier curve.

appends a Bézier curve to the current path using two spesified points.
The current point and the point (x2, y2) are used as the control
points for a Bézier curve and current point is moved to the point
(x3, y3). An application can invoke curve_to2 when the graphics
mode of the page is in GMode::PathObject.

appends a Bézier curve to the current path using two spesified points.
The point (x1, y1) and the point (x3, y3) are used as the control
points for a Bézier curve and current point is moved to the point
(x3, y3). An application can invoke curve_to3 when the graphics
mode of the page is in GMode::PathObject.

gets the current pattern of the page. First argument is the pattern, second is the phase.
shows an image in one operation.
An application can invoke draw_image when the graphics_mode
of the page is in GMode::PageDescription.
- image the image object.
- x, y the lower-left point of the region where image is displayed.
- width the width of the region where image is displayed.
- height the width of the region where image is displayed.
draws a rectangle with the given coordinates and linw width
draws a rectangle with the given rectangle and linw width
appends an ellipse to the current path.
An application can invoke ellipse when the graphics_mode of the
page is in GMode::PageDescription or GMode::PathObject.
- x, y the center point of the ellipse.
- xray the horizontal radius.
- yray the vertical radius.
ends the path object without filling and painting operation.
An application can invoke end_path when the graphics_mode
of the page is in GMode::PathObject or GMode::ClippingPath. And it changes the
graphics mode to GMode::PageDescription.
clip modifies the current clipping path by intersecting it
with the current path using the even-odd rule. The clipping
path is only modified after the succeeding painting operator.
To avoid painting the current path, use the function end_path.
Following painting operations will only affect the regions of
the page contained by the clipping path. Initially, the
clipping path includes the entire page. There is no way to
enlarge the current clipping path, or to replace the clipping
path with a new one. The functions g_save and g_restore
may be used to save and restore the current graphics state,
including the clipping path.
HPDF_Page_Clip() modifies the current clipping path by intersecting it with the current path using the even-odd rule. The clipping path is only modified after the succeeding painting operator. To avoid painting the current path, use the function HPDF_Page_EndPath().
fills the current path using the even-odd rule.
An application can invoke eofill when the graphics_mode of the
page is in GMode::PathObject or GMode::ClippingPath. And it changes the graphics mode
to GMode::PageDescription.
fills the current path using the even-odd rule, then it paints
the path. An application can invoke eofill_stroke when the
graphics mode of the page is in GMode::PathObject or GMode::ClippingPath. And it
changes the graphics mode to GMode::PageDescription.
applys the graphics state to the page.
An application can invoke ext_g_state= when the graphics_mode of
the page is in GMode::PageDescription.
fills the current path using the nonzero winding number rule.
An application can invoke fill when the graphics_mode of thepage is inGMode::PathObjectorGMode::ClippingPath. And it changes the graphics mode to GMode::PageDescription`.
fills the current path using the nonzero winding number rule,
then it paints the path. An application can invoke fill_stroke
when the graphics_mode of the page is in GMode::PathObject or GMode::ClippingPath.
And it changes the graphics mode to GMode::PageDescription.
sets the flatness tolerance for curve rendering. value must be in the range 0–100.
restore the graphics state which is saved by g_save.
An application can invoke g_save when the graphics_mode of the
page is in GMode::PageDescription.
saves the page's current graphics parameter to the stack.
An application can invoke g_save up to 28 and can restore the
saved parameter by invoking g_restore, when the graphics_mode of
the page is in GMode::PageDescription.
returns the current value of the page's filling color. gray_fill is
valid only when the page's stroking color space is ColorSpace::DeviceGray.
sets the filling color.
An application can invoke gray_fill= when the graphics_mode
of the page is in GMode::PageDescription or GMode::TextObject.
- value the value of the gray level between 0 and 1.
returns the current value of the page's stroking color. gray_fill is
valid only when the page's stroking color space is ColorSpace::DeviceGray.
sets the stroking color.
An application can invoke gray_stroke= when the graphics_mode
of the page is in GMode::PageDescription or GMode::TextObject.
- value the value of the gray level between 0 and 1.
changes the height of a page.
- h Specify the new height of a page. The valid value is between 3 and 14400.
returns the current value of the page's horizontal scaling for text showing.
sets the horizontal scalling for text showing.
The initial value of horizontal scalling is 100.
An application can invoke horizontal_scalling= when the
graphics mode of the page is in GMode::PageDescription or
GMode::TextObject.
sets the shape to be used at the ends of line.
An application can invoke line_cap= when the graphics
mode of the page is in GMode::PageDescription or GMode::TextObject.
- line_cap the style of line-cap.
Sets the line join style in the page.
An application can invoke line_join= when the graphics
mode of the page is in GMode::PageDescription or GMode::TextObject.
- line_join the style of line-join.
appends a path from the current point to the specified point.
An application can invoke line_to when the graphics_mode of
the page is in GMode::PathObject.
- x, y the end point of the path
gets the current line width of the page. It returns the current line width for path painting of the page. Otherwise it returns 1.
sets the width of the line used to stroke a path.
An application can invoke line_width= when the graphics
mode of the page is in GMode::PageDescription or GMode::TextObject.
- line_width the width of line.
calculates the byte length which can be included within the specified width.
- text the text to get the width for.
- width The width of the area to put the text.
- word_wrap Assume there are three words
"ABCDE FGH IJKL", and the substring until"J"can be included within the width. If word_wrap parameter isfalse,12characters can be included; if word_wrap istrue, only10characters will fit, i.e. until the end of the previous word. This value is available as propertylen_includedin the returned MeasuredText struct.
measures the passed text width using the current font and font size.
An application can invoke measure_text_width when the graphics_mode
of the page is in GMode::TextObject.
moves the current text position to the start of the next line with
using specified offset values. If the start position of the current
line is (x1, y1), the start of the next line is (x1 + x, y1 + y).
An application can invoke move_text_pos when the graphics_mode of
the page is in GMode::TextObject.
- x, y the offset of the start of the next line.
starts a new subpath and move the current point for drawing path,
move_to sets the start point for the path to the point (x, y)
and changes the graphics mode to GMode::PathObject.
An application can invoke move_to when the graphics_mode of the
page is in GMode::PageDescription or GMode::PathObject.
- x, y the start point for drawing path
moves the current text position to the start of the next line.
If the start position of the current line is (x1, y1), the start
of the next line is (x1, y1 - text leading).
An application can invoke move_to_next_line when the graphics
mode of the page is in GMode::TextObject.
NOTE: Since the default value of Text Leading is 0, an application
has to invoke text_leading= before move_to_next_line to set
text leading.
changes the current text position, using the specified offset values.
If the current text position is (x1, y1), the new text position will
be (x1 + x, y1 + y). Also, the text-leading is set to -y.
An application can invoke move_text_pos when the graphics_mode of
the page is in GMode::TextObject.
- x, y the offset of the start of the next line.
create path at given coordinates and yields the block closes the path at the end and returns the result of the block
appends a rectangle to the current path.
An application can invoke rectangle when the graphics_mode of
the page is in GMode::PageDescription or GMode::PathObject.
returns the current value of the page's filling color. rgb_fill is valid
only when the page's filling color space is ColorSpace::DeviceRgb.
returns the current value of the page's stroking color. rgb_stroke is
valid only when the page's stroking color space is ColorSpace::DeviceRgb.
sets rotation angle of the page.
- angle Specify the rotation angle of the page. It must be a multiple of 90 Degrees.
sets one of the page's bounding boxes (media, crop, bleed, trim, or art).
- boundary which box to set (see
PageBoundary). - left, bottom, right, top the coordinates of the box.
sets the filling color.
An application can invoke set_cmyk_fill when the graphics_mode
of the page is in GMode::PageDescription or GMode::TextObject.
- c, m, y, k the level of each color element. They must be between 0 and 1.
sets the stroking color.
An application can invoke set_cmyk_stroke when the graphics_mode
of the page is in GMode::PageDescription or GMode::TextObject.
- c, m, y, k the level of each color element. They must be between 0 and 1.
Sets the line dash pattern in the page. An application can invoke
set_dash when the graphics_mode of the page is in
GMode::PageDescription or GMode::TextObject.
- pattern pattern of dashes and gaps used to stroke paths, can have at most 8 elements.
- phase the phase in which the pattern begins (default is 0).
Samples of the dash pattern:
set_dash []
set_dash [3], phase: 1
set_dash [7, 3], phase: 2
set_dash [8, 7, 2, 7]
sets the type of font and size leading.
An application can invoke set_font_and_size when the graphics
mode of the page is in GMode::PageDescription or
GMode::TextObject.
sets the filling color.
An application can invoke set_rgb_fill when the graphics_mode
of the page is in GMode::PageDescription or GMode::TextObject.
- r, g, b the level of each color element. They must be between 0 and 1.
sets the stroking color.
An application can invoke set_rgb_stroke when the graphics_mode
of the page is in GMode::PageDescription or GMode::TextObject.
- r, g, b the level of each color element. They must be between 0 and 1.
changes the size and direction of a page to a predefined size.
- size Specify a predefined page-size value. The following values are available.
- direction Specify the direction of the page.
configures the setting for slide transition of the page.
- style the transition style.
- disp_time the display duration of the page. (in seconds)
- trans_time the duration of the transition effect. Default value is 1 (second).
set_text_matrix sets a transformation matrix for text to be drawn
in using show_text.
- a the horizontal rotation of the text. Typically expressed as cosine(Angle)
- b the vertical rotation of the text. Typically expressed as sine(Angle)
- c, d ?? appear to be controlling offset adjustments after text drawn ???
- x the page x coordinate
- y the page y coordinate
If the parameter a or d is zero, then the parameters b or c cannot be zero.
Text is typically output using the show_text function. The function
text_rect does not use the active text matrix.
An application can invoke set_text_matrix when the graphics_mode of
the page is in GMode::TextObject.
paints a shading on the page.
An application can invoke shading= when the graphics_mode of
the page is in GMode::PageDescription.
prints the text at the current position on the page.
An application can invoke show_text when the graphics_mode of the
page is in GMode::PageDescription or GMode::TextObject.
- text the text to print.
moves the current text position to the start of the next line,
then prints the text at the current position on the page.
An application can invoke show_text_next_line when the
graphics mode of the page is in GMode::PageDescription or
GMode::TextObject.
moves the current text position to the start of the next line,
then sets the word spacing, character spacing and prints the
text at the current position on the page.
An application can invoke show_text_next_line_ex when the
graphics mode of the page is in GMode::TextObject.
paints the current path.
An application can invoke stroke when the graphics_mode of the
page is in GMode::PathObject or GMode::ClippingPath.
And it changes the graphics mode to GMode::PageDescription.
table creates a table at the given rect and yields the block in the context of the created table.
- line_width changes the line with of the drawn cells
- spacing spacing between the cells, by default there is no spacing
- fixed_row_height allows to specify the row height instead of calculation
table creates a table at the given coordinates and yields the block in the context of the created table.
- line_width changes the line with of the drawn cells
- spacing spacing between the cells, by default there is no spacing
- fixed_row_height allows to specify the row height instead of calculation
ends a text object. An application can invoke text_end
when the graphics_mode of the page is in GMode::TextObject.
And it changes the graphics mode to GMode::PageDescription.
sets the text leading (line spacing) for text showing.
The initial value of leading is 0.
An application can invoke text_leading= when the graphics
mode of the page is in GMode::PageDescription or
GMode::TextObject.
prints the text on the specified position.
An application can invoke text_out when the graphics_mode
of the page is in GMode::TextObject.
- x, y the point position where the text is displayed.
- text the text to show.
print the text inside the specified region. Some chars may not
in the displayed in the space, the number of displayed chars is
returned.
An application can invoke text_rect when the graphics_mode
of the page is in GMode::TextObject.
- left, top, right, bottom coordinates of corners of the region to output text.
- text the text to show.
- align the alignment of the text.
see text_rect.
sets the text rendering mode.
The initial value of text rendering mode is TextRenderingMode::Fill.
An application can invoke text_rendering_mode= when the graphics
mode of the page is in GMode::PageDescription or GMode::TextObject.
moves the text position in vertical direction by the amount of value.
Useful for making subscripts or superscripts.
An application can invoke text_rise= when the graphics
mode of the page is in GMode::PageDescription or GMode::TextObject.
- value text rise, in user space units.
gets the width of the text in current fontsize, character spacing and word spacing.
changes the width of a page.
- w Specify the new width of a page. The valid value is between 3 and 14400.
sets the word spacing for text showing.
The initial value of word spacing is 0.
An application can invoke word_space= when the graphics_mode
of the page is in GMode::PageDescription or GMode::TextObject.
- value the value of word spacing.
sets the initial zoom factor shown when the page is opened in a viewer.
- zoom the zoom factor. Must be between 0.08 and 32.