Module pdfimposer :: Class AbstractConverter

Class AbstractConverter

source code

The base class for all pdfimposer converter classes.

It is an abstract class, with some abstract functions which should be overriden : - get_input_height - get_input_width - get_page_count - bookletize - linearize - reduce

Instance Methods
 
__init__(self, layout='2x1', format='A4', flip=TwoSidedFlip.SHORT_EDGE, copy_pages=False)
Create an AbstractConverter instance.
source code
 
set_output_height(self, height)
Set the height of the output page.
source code
 
get_output_height(self)
Get the height of the output page.
source code
 
set_output_width(self, width)
Set the width of the output page.
source code
 
get_output_width(self)
Get the width of the output page.
source code
 
set_pages_in_width(self, num)
Set the number of input pages to put in the width on one output page.
source code
 
get_pages_in_width(self)
Get the number of input pages to put in the width on one output page.
source code
 
set_pages_in_height(self, num)
Set the number of input pages to put in the height on one output page.
source code
 
get_pages_in_height(self)
Get the number of input pages to put in the height on one output page.
source code
 
set_copy_pages(self, copy_pages)
Set wether the same group of input pages shoud be copied to fill the corresponding output page or not.
source code
 
get_copy_pages(self)
Get wether the same group of input pages will be copied to fill the corresponding output page or not.
source code
 
set_progress_callback(self, progress_callback)
Register a progress callback function.
source code
 
get_progress_callback(self)
Get the progress callback function.
source code
 
set_two_sided_flip(self, flip)
Set the edge which the paper will be flipped on when printed. Defaults to TwoSidedFlip.SHORT_EDGE, where all the output pages are the right way up. If your printer can only flip over the long edge, set this to TwoSidedFlip.LONG_EDGE. The imposer will rotate all even output pages 180° to compensate.
source code
 
get_two_sided_flip(self)
Get the edge which the paper will be flipped on when printed.
source code
 
get_input_size(self)
Return the page size of the input document.
source code
 
get_input_height(self)
Return the page height of the input document.
source code
 
get_input_width(self)
Return the page width of the input document.
source code
 
get_input_orientation(self)
Return the page orientation of the input document.
source code
 
set_layout(self, layout)
Set the layout of input pages on one output page.
source code
 
get_layout(self)
Return the layout of input pages on one output page.
source code
 
get_pages_in_sheet(self)
Calculate the number of input page that will be put on one output page.
source code
 
set_output_format(self, format)
Set the format of the output paper.
source code
 
get_output_format(self)
Return the format of the output paper.
source code
 
get_input_format(self)
Return the format of the input paper
source code
 
get_page_count(self)
Return the number of pages of the input document.
source code
 
get_reduction_factor(self)
Calculate the reduction factor.
source code
 
get_increasing_factor(self)
Calculate the increasing factor.
source code
 
bookletize(self)
Convert a linear document to a booklet.
source code
 
linearize(self)
Convert a booklet to a linear document.
source code
 
reduce(self)
Put multiple input pages on one output page.
source code
Class Variables
  page_formats = {"A3":(841, 1190), "A3":(842, 1192), "A4":(595,...
Method Details

__init__(self, layout='2x1', format='A4', flip=TwoSidedFlip.SHORT_EDGE, copy_pages=False)
(Constructor)

source code 
Create an AbstractConverter instance.
Parameters:
  • layout - The layout of input pages on one output page (see set_layout).
  • format - The format of the output paper (see set_output_format).
  • flip - Render the output booklet for two-sided printing with flipping on the short (default) or long edge. Long-edge flip will result in even-numbered output pages being upside-down.
  • copy_pages - Wether the same group of input pages shoud be copied to fill the corresponding output page or not (see set_copy_pages).

set_output_height(self, height)

source code 
Set the height of the output page.
Parameters:
  • height - The height of the output page in defalut user space units.

get_output_height(self)

source code 
Get the height of the output page.
Returns:
The height of the output page in defalut user space units.

set_output_width(self, width)

source code 

Set the width of the output page.

  • width The height of the output page in defalut user space units.

get_output_width(self)

source code 
Get the width of the output page.
Returns:
The width of the output page in defalut user space units.

set_pages_in_width(self, num)

source code 
Set the number of input pages to put in the width on one output page.
Parameters:
  • num - An integer representing the number of pages in width.

get_pages_in_width(self)

source code 
Get the number of input pages to put in the width on one output page.
Returns:
An integer representing the number of pages in width.

set_pages_in_height(self, num)

source code 
Set the number of input pages to put in the height on one output page.
Parameters:
  • num - An integer representing the number of pages in height.

get_pages_in_height(self)

source code 
Get the number of input pages to put in the height on one output page.
Returns:
An integer representing the number of pages in height.

set_copy_pages(self, copy_pages)

source code 
Set wether the same group of input pages shoud be copied to fill the corresponding output page or not.
Parameters:
  • copy_pages - True to get copies of the same group of input page on one output page. False to get diffrent groups of input pages on one output page.

get_copy_pages(self)

source code 
Get wether the same group of input pages will be copied to fill the corresponding output page or not.
Returns:
True if copies of the same group of input page will get copied on one output page. False if diffrent groups of input pages will go on one output page.

set_progress_callback(self, progress_callback)

source code 

Register a progress callback function.

Register a callback function that will be called to inform on the progress of the conversion.

Parameters:
  • progress_callback - The callback function which is called to return the conversion progress. Its signature must be : a string for the progress message; a number in the range [0, 1] for the progress.

get_progress_callback(self)

source code 

Get the progress callback function.

Get the callback function that will be called to inform on the progress of the conversion.

Returns:
The callback function which is called to return the conversion progress.

set_two_sided_flip(self, flip)

source code 
Set the edge which the paper will be flipped on when printed. Defaults to TwoSidedFlip.SHORT_EDGE, where all the output pages are the right way up. If your printer can only flip over the long edge, set this to TwoSidedFlip.LONG_EDGE. The imposer will rotate all even output pages 180° to compensate.
Parameters:
  • flip - Either TwoSidedFlip.SHORT_EDGE or TwoSidedFlip.LONG_EDGE.

get_two_sided_flip(self)

source code 
Get the edge which the paper will be flipped on when printed.
Returns:
Either TwoSidedFlip.SHORT_EDGE or TwoSidedFlip.LONG_EDGE.

get_input_size(self)

source code 
Return the page size of the input document.
Returns:
A tuple (width, height) representing the page size of the input document expressed in default user space units.

get_input_height(self)

source code 
Return the page height of the input document.
Returns:
The page height of the input document expressed in default user space units.
Decorators:
  • @abstractmethod

get_input_width(self)

source code 
Return the page width of the input document.
Returns:
The page width of the input document expressed in default user space units.
Decorators:
  • @abstractmethod

get_input_orientation(self)

source code 
Return the page orientation of the input document.
Returns:
A constant from PageOrientation, or None (if square paper).

set_layout(self, layout)

source code 
Set the layout of input pages on one output page.
Parameters:
  • layout - A string of the form WxH, or a tuple or list of the form (W, H), where W is the number of input pages to put on the width of the output page and H is the number of input pages to put in the height of an output page.

get_layout(self)

source code 
Return the layout of input pages on one output page.
Returns:
A string of the form WxH, where W is the number of input pages to put on the width of the output page and H is the number of input pages to put in the height of an output page.

get_pages_in_sheet(self)

source code 
Calculate the number of input page that will be put on one output page.
Returns:
An integer representing the number of input pages on one output page.

set_output_format(self, format)

source code 

Set the format of the output paper.

recognized.

Parameters:
  • format - A string representing name ot the the desired paper format, among the keys of page_formats (e.g. A3, A4, A5).
Raises:
  • UnknonwFormatError - if the given paper format is not

get_output_format(self)

source code 
Return the format of the output paper.
Returns:
A string representing the name of the paper format (e.g. A3, A4, A5).

get_input_format(self)

source code 
Return the format of the input paper
Returns:
A string representing the name of the paper format (e.g. A3, A4, A5).

get_page_count(self)

source code 
Return the number of pages of the input document.
Returns:
The number of pages of the input document.
Decorators:
  • @abstractmethod

get_reduction_factor(self)

source code 
Calculate the reduction factor.
Returns:
The reduction factor to be applied to an input page to obtain its size on the output page.

get_increasing_factor(self)

source code 
Calculate the increasing factor.
Returns:
The increasing factor to be applied to an input page to obtain its size on the output page.

bookletize(self)

source code 

Convert a linear document to a booklet.

Convert a linear document to a booklet, arranging the pages as required.

Decorators:
  • @abstractmethod

linearize(self)

source code 

Convert a booklet to a linear document.

Convert a booklet to a linear document, arranging the pages as required.

Decorators:
  • @abstractmethod

reduce(self)

source code 
Put multiple input pages on one output page.
Decorators:
  • @abstractmethod

Class Variable Details

page_formats

Value:
{"A3":(841, 1190), "A3":(842, 1192), "A4":(595, 841), "A4":(595, 842),\
 "A5":(420, 595), "Tabloid":(792, 1224), "Letter":(612, 792), "Legal":\
(612, 1008),}