Accept Page Break

Accept automatic page break or not

Add Font

Add a TrueType or Type1 font

Arguments

Argument Type Default value Description
family
style
fname
uniFalse

Add Image To Pdf

Add image to PDF which can be new or existing PDF.

Arguments

Argument Type Default value Description
imagefilefilepath to image file to add into PDF
sourceNonefilepath to source, if not given add image to currently active PDF
targetNonefilepath of target PDF
coverage0.2[description], defaults to 0.2
param imagefile:
 filepath to image file to add into PDF
param source:filepath to source, if not given add image to currently active PDF
param target:filepath of target PDF
param coverage:[description], defaults to 0.2
raises ValueError:
 [description]

Result will be always written to target_pdf so that needs to be given for the keyword.

Add Page

Start a new page

Arguments

Argument Type Default value Description
orientation

Add Pages

Adds pages into PDF documents.

Arguments

Argument Type Default value Description
pages int 1number of pages to add, defaults to 1
param pages:number of pages to add, defaults to 1

Add Pages To Document

Add empty pages into current source document

Arguments

Argument Type Default value Description
pages int 1number of pages to add, defaults to 1
source_pdf str Nonefilepath to the source pdf
target_pdf str Nonefilename to the target pdf, stored by default to output_directory
param pages:number of pages to add, defaults to 1
param source_pdf:
 filepath to the source pdf
param target_pdf:
 filename to the target pdf, stored by default to output_directory

Alias Nb Pages

Define an alias for total number of pages

Arguments

Argument Type Default value Description
alias{nb}

Cell

Output a cell

Arguments

Argument Type Default value Description
w
h0
txt
border0
ln0
align
fill0
link

Check Page

Decorator to protect drawing methods

Close

Terminate document

Close All Pdf Documents

Close all opened PDF file descriptors.

Close Pdf Document

Close PDF file descriptor for certain file.

Arguments

Argument Type Default value Description
source_pdf str Nonefilepath
param source_pdf:
 filepath
raises ValueError:
 if file descriptor for the file is not found

Code 39

Barcode 3of9

Arguments

Argument Type Default value Description
txt
x
y
w1.5
h5.0

Dashed Line

Draw a dashed line. Same interface as line() except: - dash_length: Length of the dash - space_length: Length of the space between dashes

Arguments

Argument Type Default value Description
x1
y1
x2
y2
dash_length1
space_length1

Draw a dashed line. Same interface as line() except: - dash_length: Length of the dash - space_length: Length of the space between dashes

Dump Pdf As Xml

Get PDFMiner format XML dump of the PDF

Arguments

Argument Type Default value Description
source_pdf str Nonefilepath
param source_pdf:
 filepath
return:XML content

Ellipse

Draw a ellipse

Arguments

Argument Type Default value Description
x
y
w
h
style

Error

Fatal error

Arguments

Argument Type Default value Description
msg

Extract Pages From Pdf

Extract pages from source PDF and save to target PDF document.

Arguments

Argument Type Default value Description
source_pdf str Nonefilepath to the source pdf
target_pdf str Nonefilename to the target pdf, stored by default to output_directory
pages typing.Any Nonepage numbers to extract from PDF (numbers start from 0) if None then extracts all pages
param source_pdf:
 filepath to the source pdf
param target_pdf:
 filename to the target pdf, stored by default to output_directory
param pages:page numbers to extract from PDF (numbers start from 0) if None then extracts all pages

Page numbers starting from 1.

Get All Figures

Return all figures in the PDF document.

return:dictionary of figures divided into pages

PDF needs to be parsed before elements can be found.

Get Info

Get information from PDF document.

Arguments

Argument Type Default value Description
source_pdf str Nonefilepath to the source pdf
param source_pdf:
 filepath to the source pdf
return:dictionary of PDF information

Get Input Fields

Get input fields in the PDF.

Arguments

Argument Type Default value Description
source_pdf str Nonesource filepath, defaults to None
replace_none_value bool Falseif value is None replace it with key name, defaults to False
param source_pdf:
 source filepath, defaults to None
param replace_none_value:
 if value is None replace it with key name, defaults to False
return:dictionary of input key values or None

Stores input fields internally so that they can be used without parsing PDF again.

Parameter replace_none_value is for convience to visualize fields.

Get Number Of Pages

Get number of pages in the document.

Arguments

Argument Type Default value Description
source_pdf str Nonefilepath to the source pdf
param source_pdf:
 filepath to the source pdf
raises PdfReadError:
 if file is encrypted or other restrictions are in place

Get Output Directory

Get output directory where target files are saved to.

return:absolute filepath as string

Get String Width

Get width of a string in the current font

Arguments

Argument Type Default value Description
s

Get Text From Pdf

Get text from set of pages in source PDF document.

Arguments

Argument Type Default value Description
source_pdf str Nonefilepath to the source pdf
pages typing.Any Nonepage numbers to get text (numbers start from 0)
param source_pdf:
 filepath to the source pdf
param pages:page numbers to get text (numbers start from 0)
return:dictionary of pages and their texts

PDF needs to be parsed before text can be read.

Get Value From Anchor

Get closest text (value) to anchor element.

Arguments

Argument Type Default value Description
locator strelement to set anchor to
pagenum int 1page number where search if performed on, default 1 (first)
direction str rightin which direction to search for text, directions 'top', 'bottom', 'left' or 'right', defaults to 'right'
strict bool Falseif element margins should be used for matching points, used when direction is 'top' or 'bottom', default False
regexp str Noneexpected format of value to match, defaults to None

PDF needs to be parsed before elements can be found.

param locator:element to set anchor to
param pagenum:page number where search if performed on, default 1 (first)
param direction:
 in which direction to search for text, directions 'top', 'bottom', 'left' or 'right', defaults to 'right'
param strict:if element margins should be used for matching points, used when direction is 'top' or 'bottom', default False
param regexp:expected format of value to match, defaults to None
return:closest matching text or None

Get X

Get x position

Get Y

Get y position

Html To Pdf

Use HTML content to generate PDF file.

Arguments

Argument Type Default value Description
content str NoneHTML content
filename str Nonefilepath where to save PDF document
variables dict Nonedictionary of variables to fill into template, defaults to {}
create_dirs bool Truedirectory structure is created if it is missing, default True
exists_ok bool Truefile is overwritten if it exists, default True
param content:HTML content
param filename:filepath where to save PDF document
param variables:
 dictionary of variables to fill into template, defaults to {}
param create_dirs:
 directory structure is created if it is missing, default True
param exists_ok:
 file is overwritten if it exists, default True

Image

Put an image on the page

Arguments

Argument Type Default value Description
name
xNone
yNone
w0
h0
type
link

Interleaved 2 Of 5

Barcode I2of5 (numeric), adds a 0 if odd lenght

Arguments

Argument Type Default value Description
txt
x
y
w1.0
h10.0

Is Pdf Encrypted

Check if PDF is encrypted.

Arguments

Argument Type Default value Description
source_pdf str Nonefilepath to the source pdf

Returns True even if PDF was decrypted.

param source_pdf:
 filepath to the source pdf
return:True if file is encrypted

Line

Draw a line

Arguments

Argument Type Default value Description
x1
y1
x2
y2

Ln

Line Feed; default value is last cell height

Arguments

Argument Type Default value Description
h

Multi Cell

Output text with automatic or explicit line breaks

Arguments

Argument Type Default value Description
w
h
txt
border0
alignJ
fill0
split_onlyFalse

Normalize Text

Check that text input is in the correct format/encoding

Arguments

Argument Type Default value Description
txt

Open

Begin document

Open Pdf Document

Open PDF document.

Arguments

Argument Type Default value Description
source_pdf str Nonefilepath to the source pdf
param source_pdf:
 filepath to the source pdf
raises ValueError:
 if PDF is already open

Also opens file for reading.

Output

Output PDF to some destination

Arguments

Argument Type Default value Description
name
dest

Page No

Get current page number

Page Rotate

Rotate pages in source PDF document and save to target PDF document.

Arguments

Argument Type Default value Description
pages intpage numbers to extract from PDF (numbers start from 0)
source_pdf str Nonefilepath to the source pdf
target_pdf str Nonefilename to the target pdf, stored by default to output_directory
clockwise bool Truedirectorion that page will be rotated to, default True
angle int 90number of degrees to rotate, default 90
param source_pdf:
 filepath to the source pdf
param target_pdf:
 filename to the target pdf, stored by default to output_directory
param pages:page numbers to extract from PDF (numbers start from 0)
param clockwise:
 directorion that page will be rotated to, default True
param angle:number of degrees to rotate, default 90

Parse Pdf

Parse source PDF into entities which can be used for text searches for example.

Arguments

Argument Type Default value Description
source_pdf str Nonesource

Parse source PDF into entities which can be used for text searches for example.

param source_pdf:
 source

Pdf Decrypt

Decrypt PDF with password.

Arguments

Argument Type Default value Description
source_pdf str Nonefilepath to the source pdf
target_pdf str Nonefilepath to the decrypted pdf
password str Nonepassword as a string
param source_pdf:
 filepath to the source pdf
param target_pdf:
 filepath to the decrypted pdf
param password:password as a string
return:True if decrypt was successful, else False or Exception
raises ValueError:
 on decryption errors

Pdf Encrypt

Encrypt PDF document.

Arguments

Argument Type Default value Description
source_pdf str Nonefilepath to the source pdf
target_pdf str Nonefilename to the target pdf, stored by default to output_directory
user_pwd str allows opening and reading PDF with restrictions
owner_pwd str Noneallows opening PDF without any restrictions, by default same user_pwd
use_128bit bool Truewhether to 128bit encryption, when false 40bit encryption is used, default True
param source_pdf:
 filepath to the source pdf
param target_pdf:
 filename to the target pdf, stored by default to output_directory
param user_pwd:allows opening and reading PDF with restrictions
param owner_pwd:
 allows opening PDF without any restrictions, by default same user_pwd
param use_128bit:
 whether to 128bit encryption, when false 40bit encryption is used, default True

Rect

Draw a rectangle

Arguments

Argument Type Default value Description
x
y
w
h
style

Replace Text

Replace text content with something else in the PDF.

Arguments

Argument Type Default value Description
text strthis text will be replaced
replace strused to replace text
param text:this text will be replaced
param replace:used to replace text

Rotate

Arguments

Argument Type Default value Description
angle
xNone
yNone

Save Pdf

Save current over itself or to target_pdf

Arguments

Argument Type Default value Description
source str Nonefilepath to source PDF
target str Nonefilepath to target PDF
use_modified_reader bool Falseneeds to be set to True if using modified PDF reader
param source:filepath to source PDF
param target:filepath to target PDF
param use_modified_reader:
 needs to be set to True if using modified PDF reader

Set Anchor To Element

Sets anchor point in the document for further searches.

Arguments

Argument Type Default value Description
locator strelement to search for

PDF needs to be parsed before elements can be found.

param locator:element to search for
return:True if element was found

Set Author

Author of document

Arguments

Argument Type Default value Description
author

Set Auto Page Break

Set auto page break mode and triggering margin

Arguments

Argument Type Default value Description
auto
margin0

Set Compression

Set page compression

Arguments

Argument Type Default value Description
compress

Set Creator

Creator of document

Arguments

Argument Type Default value Description
creator

Set Display Mode

Set display mode in viewer

Arguments

Argument Type Default value Description
zoom
layoutcontinuous

The "zoom" argument may be 'fullpage', 'fullwidth', 'real', 'default', or a number, interpreted as a percentage.

Set Draw Color

Set color for all stroking operations

Arguments

Argument Type Default value Description
r
g-1
b-1

Set Field Value

Set value for field with given name.

Arguments

Argument Type Default value Description
field_name strfield to update
value typing.Anynew value for the field
save bool False
param field_name:
 field to update
param value:new value for the field

Tries to match on field identifier and its label.

Exception is thrown if field can't be found or more than 1 field matches the given field_name.

Set Fill Color

Set color for all filling operations

Arguments

Argument Type Default value Description
r
g-1
b-1

Set Font

Select a font; size given in points

Arguments

Argument Type Default value Description
family
style
size0

Set Font Size

Set font size in points

Arguments

Argument Type Default value Description
size

Set Keywords

Keywords of document

Arguments

Argument Type Default value Description
keywords

Set Left Margin

Set left margin

Arguments

Argument Type Default value Description
margin

Set Line Width

Set line width

Arguments

Argument Type Default value Description
width

Set Margins

Set left, top and right margins

Arguments

Argument Type Default value Description
left
top
right-1

Set Output Directory

Set output directory where target files are saved to.

Arguments

Argument Type Default value Description
outdir str .output directory path, default to current directory
param outdir:output directory path, default to current directory

Set Right Margin

Set right margin

Arguments

Argument Type Default value Description
margin

Set Subject

Subject of document

Arguments

Argument Type Default value Description
subject

Set Text Color

Set color for text

Arguments

Argument Type Default value Description
r
g-1
b-1

Set Title

Title of document

Arguments

Argument Type Default value Description
title

Set Top Margin

Set top margin

Arguments

Argument Type Default value Description
margin

Set X

Set x position

Arguments

Argument Type Default value Description
x

Set Xy

Set x and y positions

Arguments

Argument Type Default value Description
x
y

Set Y

Set y position and reset x

Arguments

Argument Type Default value Description
y

Switch To Pdf Document

Switch library's current fileobject to already open file or open file if not opened.

Arguments

Argument Type Default value Description
source_pdf str Nonefilepath

Switch library's current fileobject to already open file or open file if not opened.

param source_pdf:
 filepath
raises ValueError:
 if PDF filepath is not given and there are no active file to activate

Template Html To Pdf

Use HTML template file to generate PDF file.

Arguments

Argument Type Default value Description
template str Nonefilepath to HTML template
filename str Nonefilepath where to save PDF document
variables dict Nonedictionary of variables to fill into template, defaults to {}
create_dirs bool Truedirectory structure is created if it is missing, default True
exists_ok bool Truefile is overwritten if it exists, default True
param template:filepath to HTML template
param filename:filepath where to save PDF document
param variables:
 dictionary of variables to fill into template, defaults to {}
param create_dirs:
 directory structure is created if it is missing, default True
param exists_ok:
 file is overwritten if it exists, default True

Text

Output a string

Arguments

Argument Type Default value Description
x
y
txt

Update Field Values

Update field values in PDF if it has fields.

Arguments

Argument Type Default value Description
source_pdf str Nonesource PDF with fields to update
target_pdf str Noneupdated target PDF
newvals dict Nonedictionary with key values to update
param source_pdf:
 source PDF with fields to update
param target_pdf:
 updated target PDF
param newvals:dictionary with key values to update

Write

Output text in flowing mode

Arguments

Argument Type Default value Description
h
txt
link

Write Html

Parse HTML and convert it to PDF

Arguments

Argument Type Default value Description
text
image_mapNone