API Reference¶
-
class
pydyf.Object¶ Base class for PDF objects.
-
property
data¶ Data contained in the object. Shall be defined in each subclass.
-
free¶ Indicate if an object is used (
'n'), or has been deleted and therefore is free ('f').
-
generation¶ Version number of the object, non-negative.
-
property
indirect¶ Indirect representation of an object.
-
number¶ Number of the object.
-
offset¶ Position in the PDF of the object.
-
property
reference¶ Object identifier.
-
property
-
class
pydyf.Stream(stream=None, extra=None, compress=False)¶ PDF Stream object.
Inherits from
Object.-
begin_text()¶ Begin a text object.
-
clip(even_odd=False)¶ Modify current clipping path by intersecting it with current path.
Use the nonzero winding number rule to determine which regions lie inside the clipping path by default.
Use the even-odd rule if
even_oddset toTrue.
-
close()¶ Close current subpath.
Append a straight line segment from the current point to the starting point of the subpath.
-
color_space(space, stroke=False)¶ Set the nonstroking color space.
If stroke is set to
True, set the stroking color space instead.
-
compress¶ Compress the stream data if set to
True. Default isFalse.
-
curve_end_to(x1, y1, x3, y3)¶ Add cubic Bézier curve to current path
The curve shall extend to
(x3, y3)using (x1, y1)` and(x3, y3)as the Bézier control points.
-
curve_start_to(x2, y2, x3, y3)¶ Add cubic Bézier curve to current path
The curve shall extend to
(x3, y3)using the current point and(x2, y2)as the Bézier control points.
-
curve_to(x1, y1, x2, y2, x3, y3)¶ Add cubic Bézier curve to current path.
The curve shall extend from
(x3, y3)using(x1, y1)and(x2, y2)as the Bézier control points.
-
property
data¶ Data contained in the object. Shall be defined in each subclass.
-
draw_x_object(reference)¶ Draw object given by reference.
-
end()¶ End path without filling or stroking.
-
end_text()¶ End text object.
-
extra¶ Metadata containing at least the length of the Stream.
-
fill(even_odd=False)¶ Fill path using nonzero winding rule.
Use even-odd rule if
even_oddis set toTrue.
-
fill_and_stroke(even_odd=False)¶ Fill and stroke path usign nonzero winding rule.
Use even-odd rule if
even_oddis set toTrue.
-
fill_stroke_and_close(even_odd=False)¶ Fill, stroke and close path using nonzero winding rule.
Use even-odd rule if
even_oddis set toTrue.
-
line_to(x, y)¶ Add line from current point to point
(x, y).
-
move_to(x, y)¶ Begin new subpath by moving current point to
(x, y).
-
pop_state()¶ Restore graphic state.
-
push_state()¶ Save graphic state.
-
rectangle(x, y, width, height)¶ Add rectangle to current path as complete subpath.
(x, y)is the lower-left corner and width and height the dimensions.
-
set_color_rgb(r, g, b, stroke=False)¶ Set RGB color for nonstroking operations.
Set RGB color for stroking operations instead if
strokeis set toTrue.
-
set_color_special(name, stroke=False)¶ Set color for nonstroking operations.
Set color for stroking operation if
strokeis set toTrue.
-
set_dash(dash_array, dash_phase)¶ Set dash line pattern.
-
set_font_size(font, size)¶ Set font name and size.
-
set_line_cap(line_cap)¶ Set line cap style.
-
set_line_join(line_join)¶ Set line join style.
-
set_line_width(width)¶ Set line width.
-
set_miter_limit(miter_limit)¶ Set miter limit.
-
set_state(state_name)¶ Set specified parameters in graphic state.
- Parameters
state_name – Name of the graphic state.
-
set_text_rendering(mode)¶ Set text rendering mode.
-
shading(name)¶ Paint shape and color shading using shading dictionary
name.
-
show_text(text)¶ Show text.
-
stream¶ Python array of data composing stream.
-
stroke()¶ Stroke path.
-
stroke_and_close()¶ Stroke and close path.
-
text_matrix(a, b, c, d, e, f)¶ Set text matrix and text line matrix.
- Parameters
-
transform(a, b, c, d, e, f)¶ Modify current transformation matrix.
- Parameters
-
-
class
pydyf.PDF¶ PDF document.
-
add_object(object_)¶ Add object to the PDF.
-
add_page(page)¶ Add page to the PDF.
- Parameters
page (
Dictionary) – New page.
-
catalog¶ PDF
Dictionarycontaining references to the other objects.
-
current_position¶ Current position in the PDF.
-
info¶ PDF
Dictionarycontaining the PDF’s metadata.
-
pages¶ PDF
Dictionarycontaining the PDF’s pages.
-
write(output)¶ Write PDF to output.
- Parameters
output (binary file object) – Output stream.
-
write_line(content, output)¶ Write line to output.
- Parameters
content (
bytes) – Content to write.output (binary file object) – Output stream.
-
xref_position¶ Position of the cross reference table.
-