Module pdfimposer

Module pdfimposer

source code

Converts PDF documents between different page layouts.

This module enables to:

The StreamConverter class works on StreamIO, while the FileConverter class works on files.

Some convenience functions are also provided.

Classes
  PageOrientation
The page orientation constants
  PdfConvError
The base class for all exceptions raised by PdfImposer.
  MismachingOrientationsError
This exception is raised if the required layout is incompatible with the input page orientation.
  UnknownFormatError
This exception is raised when the user tries to set an unknown page format.
  UserInterruptError
This exception is raised when the user interrupts the conversion.
  AbstractConverter
The base class for all pdfimposer converter classes.
  StreamConverter
This class performs conversions on file-like objects (e.g. a StreamIO).
  FileConverter
This class performs conversions on true files.
Functions
 
_(x) source code
 
bookletize_on_stream(input_stream, output_stream, layout='2x1', format='A4', copy_pages=False)
Convert a linear document to a booklet.
source code
 
bookletize_on_file(input_file, output_file=None, layout='2x1', format='A4', copy_pages=False)
Convert a linear PDF file to a booklet.
source code
 
linearize_on_stream(input_stream, output_stream, layout='2x1', format='A4', copy_pages=False)
Convert a booklet to a linear document.
source code
 
linearize_on_file(input_file, output_file=None, layout='2x1', format='A4', copy_pages=False)
Convert a booklet to a linear PDF file.
source code
 
reduce_on_stream(input_stream, output_stream, layout='2x1', format='A4', copy_pages=False)
Put multiple input pages on one output page.
source code
 
reduce_on_file(input_file, output_file=None, layout='2x1', format='A4', copy_pages=False)
Put multiple input pages on one output page.
source code
Variables
  __package__ = None
Function Details

bookletize_on_stream(input_stream, output_stream, layout='2x1', format='A4', copy_pages=False)

source code 

Convert a linear document to a booklet.

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

This is a convenience function around StreamConverter

Parameters:
  • input_stream - The file-like object from which tne input PDF document should be read.
  • output_stream - The file-like object to which tne output PDF document should be written.
  • layout - The layout of input pages on one output page (see set_layout).
  • format - The format of the output paper (see set_output_format).
  • copy_pages - Wether the same group of input pages shoud be copied to fill the corresponding output page or not (see set_copy_pages).

bookletize_on_file(input_file, output_file=None, layout='2x1', format='A4', copy_pages=False)

source code 

Convert a linear PDF file to a booklet.

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

This is a convenience function around FileConverter

Parameters:
  • input_file - The name to the input PDF file.
  • output_file - The name of the file where the output PDF should de written. If ommited, defaults to the name of the input PDF postponded by '-conv'.
  • layout - The layout of input pages on one output page (see set_layout).
  • format - The format of the output paper (see set_output_format).
  • copy_pages - Wether the same group of input pages shoud be copied to fill the corresponding output page or not (see set_copy_pages).

linearize_on_stream(input_stream, output_stream, layout='2x1', format='A4', copy_pages=False)

source code 

Convert a booklet to a linear document.

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

This is a convenience function around StreamConverter

Parameters:
  • input_stream - The file-like object from which tne input PDF document should be read.
  • output_stream - The file-like object to which tne output PDF document should be written.
  • layout - The layout of output pages on one input page (see set_layout).
  • format - The format of the output paper (see set_output_format).
  • copy_pages - Wether the same group of input pages shoud be copied to fill the corresponding output page or not (see set_copy_pages).

linearize_on_file(input_file, output_file=None, layout='2x1', format='A4', copy_pages=False)

source code 

Convert a booklet to a linear PDF file.

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

This is a convenience function around FileConverter

Parameters:
  • input_file - The name to the input PDF file.
  • output_file - The name of the file where the output PDF should de written. If ommited, defaults to the name of the input PDF postponded by '-conv'.
  • layout - The layout of input pages on one output page (see set_layout).
  • format - The format of the output paper (see set_output_format).
  • copy_pages - Wether the same group of input pages shoud be copied to fill the corresponding output page or not (see set_copy_pages).

reduce_on_stream(input_stream, output_stream, layout='2x1', format='A4', copy_pages=False)

source code 

Put multiple input pages on one output page.

This is a convenience function around StreamConverter

Parameters:
  • input_stream - The file-like object from which tne input PDF document should be read.
  • output_stream - The file-like object to which tne output PDF document should be written.
  • layout - The layout of input pages on one output page (see set_layout).
  • format - The format of the output paper (see set_output_format).
  • copy_pages - Wether the same group of input pages shoud be copied to fill the corresponding output page or not (see set_copy_pages).

reduce_on_file(input_file, output_file=None, layout='2x1', format='A4', copy_pages=False)

source code 

Put multiple input pages on one output page.

This is a convenience function around FileConverter

Parameters:
  • input_file - The name to the input PDF file.
  • output_file - The name of the file where the output PDF should de written. If ommited, defaults to the name of the input PDF postponded by '-conv'.
  • layout - The layout of input pages on one output page (see set_layout).
  • format - The format of the output paper (see set_output_format).
  • copy_pages - Wether the same group of input pages shoud be copied to fill the corresponding output page or not (see set_copy_pages).