API Reference
- class pydyf.Object
Base class for PDF objects.
- property compressible
Whether the object can be included in an object stream.
- 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.
- class pydyf.Stream(stream=None, extra=None, compress=False)
Bases:
Object
PDF Stream object.
- begin_marked_content(tag, property_list=None)
Begin marked-content sequence.
- 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_odd
set 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)
color_space is deprecated, use set_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_marked_content()
End marked-content sequence.
- 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_odd
is set toTrue
.
- fill_and_stroke(even_odd=False)
Fill and stroke path usign nonzero winding rule.
Use even-odd rule if
even_odd
is set toTrue
.
- fill_stroke_and_close(even_odd=False)
Fill, stroke and close path using nonzero winding rule.
Use even-odd rule if
even_odd
is set toTrue
.
- inline_image(width, height, color_space, bpc, raw_data)
Add an inline image.
- line_to(x, y)
Add line from current point to point
(x, y)
.
- move_text_to(x, y)
Move text to next line at
(x, y)
distance from previous line.
- move_to(x, y)
Begin new subpath by moving current point to
(x, y)
.
- paint_shading(name)
Paint shape and color shading using shading dictionary
name
.
- 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
stroke
is set toTrue
.
- set_color_space(space, stroke=False)
Set the nonstroking color space.
If stroke is set to
True
, set the stroking color space instead.
- set_color_special(name, stroke=False, *operands)
Set special color for nonstroking operations.
Set special color for stroking operation if
stroke
is 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_matrix(a, b, c, d, e, f)
Set current transformation matrix.
- Parameters:
- 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_matrix(a, b, c, d, e, f)
Set current text and text line transformation matrix.
- Parameters:
- set_text_rendering(mode)
Set text rendering mode.
- set_text_rise(height)
Set text rise.
- shading(name)
shading is deprecated, use paint_shading instead.
- show_text(text)
Show text strings with individual glyph positioning.
- show_text_string(text)
Show single text string.
- 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)
text_matrix is deprecated, use set_text_matrix instead.
- transform(a, b, c, d, e, f)
transform is deprecated, use set_matrix instead.
- 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
Dictionary
containing references to the other objects.
- current_position
Current position in the PDF.
- info
PDF
Dictionary
containing the PDF’s metadata.
- pages
PDF
Dictionary
containing the PDF’s pages.
- write(output, version=b'1.7', identifier=False, compress=False)
Write PDF to output.
- Parameters:
- 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.