Accept Page Break

Arguments

Accept automatic page break or not

Add Font

Arguments

  • family
  • style=
  • fname=
  • uni=False

Add a TrueType or Type1 font

Add Image To Pdf

Arguments

  • imagefile
  • source=None
  • target=None
  • coverage=0.2

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

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

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]

Add Page

Arguments

  • orientation=

Start a new page

Add Pages

Arguments

  • pages: int = 1

Adds pages into PDF documents.

param pages:number of pages to add, defaults to 1

Add Pages To Document

Arguments

  • pages: int = 1
  • source_pdf: str = None
  • target_pdf: str = None

Add empty pages into current source document

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

Arguments

  • alias={nb}

Define an alias for total number of pages

Cell

Arguments

  • w
  • h=0
  • txt=
  • border=0
  • ln=0
  • align=
  • fill=0
  • link=

Output a cell

Check Page

Arguments

Decorator to protect drawing methods

Close

Arguments

Terminate document

Close All Pdf Documents

Arguments

Close all opened PDF file descriptors.

Close Pdf Document

Arguments

  • source_pdf: str = None

Close PDF file descriptor for certain file.

param source_pdf:
 filepath
raises ValueError:
 if file descriptor for the file is not found

Code 39

Arguments

  • txt
  • x
  • y
  • w=1.5
  • h=5.0

Barcode 3of9

Dashed Line

Arguments

  • x1
  • y1
  • x2
  • y2
  • dash_length=1
  • space_length=1

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

Arguments

  • source_pdf: str = None

Get PDFMiner format XML dump of the PDF

param source_pdf:
 filepath
return:XML content

Ellipse

Arguments

  • x
  • y
  • w
  • h
  • style=

Draw a ellipse

Error

Arguments

  • msg

Fatal error

Extract Pages From Pdf

Arguments

  • source_pdf: str = None
  • target_pdf: str = None
  • pages: typing.Any = None

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

Page numbers starting from 1.

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

Get All Figures

Arguments

Return all figures in the PDF document.

PDF needs to be parsed before elements can be found.

return:dictionary of figures divided into pages

Get Info

Arguments

  • source_pdf: str = None

Get information from PDF document.

param source_pdf:
 filepath to the source pdf
return:dictionary of PDF information

Get Input Fields

Arguments

  • source_pdf: str = None
  • replace_none_value: bool = False

Get input fields in the PDF.

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

Parameter replace_none_value is for convience to visualize fields.

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

Get Number Of Pages

Arguments

  • source_pdf: str = None

Get number of pages in the document.

param source_pdf:
 filepath to the source pdf
raises PdfReadError:
 if file is encrypted or other restrictions are in place

Get Output Directory

Arguments

Get output directory where target files are saved to.

return:absolute filepath as string

Get String Width

Arguments

  • s

Get width of a string in the current font

Get Text From Pdf

Arguments

  • source_pdf: str = None
  • pages: typing.Any = None

Get text from set of pages in source PDF document.

PDF needs to be parsed before text can be read.

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

Get Value From Anchor

Arguments

  • locator: str
  • pagenum: int = 1
  • direction: str = right
  • strict: bool = False
  • regexp: str = None

Get closest text (value) to anchor element.

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

Arguments

Get x position

Get Y

Arguments

Get y position

Html To Pdf

Arguments

  • content: str = None
  • filename: str = None
  • variables: dict = None

Use HTML content to generate PDF file.

param content:HTML content
param filename:filepath where to save PDF document
param variables:
 dictionary of variables to fill into template, defaults to {}

Image

Arguments

  • name
  • x=None
  • y=None
  • w=0
  • h=0
  • type=
  • link=

Put an image on the page

Interleaved 2 Of 5

Arguments

  • txt
  • x
  • y
  • w=1.0
  • h=10.0

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

Is Pdf Encrypted

Arguments

  • source_pdf: str = None

Check if PDF is encrypted.

Returns True even if PDF was decrypted.

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

Line

Arguments

  • x1
  • y1
  • x2
  • y2

Draw a line

Ln

Arguments

  • h=

Line Feed; default value is last cell height

Multi Cell

Arguments

  • w
  • h
  • txt=
  • border=0
  • align=J
  • fill=0
  • split_only=False

Output text with automatic or explicit line breaks

Normalize Text

Arguments

  • txt

Check that text input is in the correct format/encoding

Open

Arguments

Begin document

Open Pdf Document

Arguments

  • source_pdf: str = None

Open PDF document.

Also opens file for reading.

param source_pdf:
 filepath to the source pdf
raises ValueError:
 if PDF is already open

Output

Arguments

  • name=
  • dest=

Output PDF to some destination

Page No

Arguments

Get current page number

Page Rotate

Arguments

  • pages: int
  • source_pdf: str = None
  • target_pdf: str = None
  • clockwise: bool = True
  • angle: int = 90

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

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

Arguments

  • source_pdf: str = None

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

param source_pdf:
 source

Pdf Decrypt

Arguments

  • source_pdf: str = None
  • target_pdf: str = None
  • password: str = None

Decrypt PDF with password.

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

Arguments

  • source_pdf: str = None
  • target_pdf: str = None
  • user_pwd: str =
  • owner_pwd: str = None
  • use_128bit: bool = True

Encrypt PDF document.

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

Arguments

  • x
  • y
  • w
  • h
  • style=

Draw a rectangle

Replace Text

Arguments

  • text: str
  • replace: str

Replace text content with something else in the PDF.

param text:this text will be replaced
param replace:used to replace text

Rotate

Arguments

  • angle
  • x=None
  • y=None

Save Pdf

Arguments

  • source: str = None
  • target: str = None
  • use_modified_reader: bool = False

Save current over itself or to target_pdf

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

Arguments

  • locator: str

Sets anchor point in the document for further searches.

PDF needs to be parsed before elements can be found.

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

Set Author

Arguments

  • author

Author of document

Set Auto Page Break

Arguments

  • auto
  • margin=0

Set auto page break mode and triggering margin

Set Compression

Arguments

  • compress

Set page compression

Set Creator

Arguments

  • creator

Creator of document

Set Display Mode

Arguments

  • zoom
  • layout=continuous

Set display mode in viewer

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

Set Draw Color

Arguments

  • r
  • g=-1
  • b=-1

Set color for all stroking operations

Set Field Value

Arguments

  • field_name: str
  • value: typing.Any
  • save: bool = False

Set value for field with given name.

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.

param field_name:
 field to update
param value:new value for the field

Set Fill Color

Arguments

  • r
  • g=-1
  • b=-1

Set color for all filling operations

Set Font

Arguments

  • family
  • style=
  • size=0

Select a font; size given in points

Set Font Size

Arguments

  • size

Set font size in points

Set Keywords

Arguments

  • keywords

Keywords of document

Set Left Margin

Arguments

  • margin

Set left margin

Set Line Width

Arguments

  • width

Set line width

Set Margins

Arguments

  • left
  • top
  • right=-1

Set left, top and right margins

Set Output Directory

Arguments

  • outdir: str = .

Set output directory where target files are saved to.

param outdir:output directory path, default to current directory

Set Right Margin

Arguments

  • margin

Set right margin

Set Subject

Arguments

  • subject

Subject of document

Set Text Color

Arguments

  • r
  • g=-1
  • b=-1

Set color for text

Set Title

Arguments

  • title

Title of document

Set Top Margin

Arguments

  • margin

Set top margin

Set X

Arguments

  • x

Set x position

Set Xy

Arguments

  • x
  • y

Set x and y positions

Set Y

Arguments

  • y

Set y position and reset x

Switch To Pdf Document

Arguments

  • source_pdf: str = None

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

Arguments

  • template: str = None
  • filename: str = None
  • variables: dict = None

Use HTML template file to generate PDF file.

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 {}

Text

Arguments

  • x
  • y
  • txt=

Output a string

Update Field Values

Arguments

  • source_pdf: str = None
  • target_pdf: str = None
  • newvals: dict = None

Update field values in PDF if it has fields.

param source_pdf:
 source PDF with fields to update
param target_pdf:
 updated target PDF
param newvals:dictionary with key values to update

Write

Arguments

  • h
  • txt=
  • link=

Output text in flowing mode

Write Html

Arguments

  • text
  • image_map=None

Parse HTML and convert it to PDF