# eric6.WebBrowser.Tools.FilePrinter

Module implementing an object for printing of files.

### Global Attributes

_FilePrintJobs

### Classes

FilePrinter | Class implementing methods for printing on *nix systems.

### Functions

isCupsAvailable | Static method to test the availability of CUPS.
printFile | Static method to print a file.

## FilePrinter

Class implementing methods for printing on *nix systems.

### Derived from

object

### Class Attributes

ApplicationDeletesFiles
ApplicationSelectsPages
SystemDeletesFiles
SystemSelectsPages

### Class Methods

None

### Methods

FilePrinter | Constructor
__doCleanup | Private method to perform some internal cleanup actions.
__processError | Private slot handling process errors.
__processFinished | Private slot handling the end of the process.
_copies | Protected method to assemble the number of copies arguments.
_cupsOptions | Protected method to assemble the CUPS specific arguments.
_deleteFile | Protected method to assemble the jobname arguments.
_destination | Protected method to assemble the printer destination arguments.
_doPrintFile | Protected method to print a file.
_jobname | Protected method to assemble the jobname arguments.
_mediaPageSize | Protected method to get the page size argument.
_mediaPaperSource | Protected method to get the paper source argument.
_optionCollateCopies | Protected method to assemble the collate copies arguments.
_optionCupsProperties | Protected method to assemble the CUPS properties arguments.
_optionDoubleSidedPrinting | Protected method to assemble the double sided printing arguments.
_optionMedia | Protected method to assemble the print media arguments.
_optionPageOrder | Protected method to assemble the page order arguments.
_pages | Protected method to assemble the page range(s) arguments.
_printArguments | Protected method to assemble the command line arguments for the print command.

### Static Methods

None

#### FilePrinter (Constructor)

FilePrinter()

Constructor

#### FilePrinter.__doCleanup

__doCleanup(deleteFile)

Private method to perform some internal cleanup actions.

deleteFile (bool)
  flag indicating to delete the print file

#### FilePrinter.__processError

__processError(error)

Private slot handling process errors.

error (QProcess.ProcessError)
  error value

#### FilePrinter.__processFinished

__processFinished(exitCode, exitStatus)

Private slot handling the end of the process.

exitCode (int)
  exit code of the process
exitStatus (QProcess.ExitStatus)
  exit status of the process

#### FilePrinter._copies

_copies(printer, variant)

Protected method to assemble the number of copies arguments.

printer (QPrinter)
  reference to the printer to print to
variant (str)
  string identifying the print command variant

Returns:
  assembled number of copies arguments

Return Type:
  list of str

#### FilePrinter._cupsOptions

_cupsOptions(printer)

Protected method to assemble the CUPS specific arguments.

printer (QPrinter)
  reference to the printer to print to

Returns:
  assembled CUPS arguments

Return Type:
  list of str

#### FilePrinter._deleteFile

_deleteFile(printer, fileDeletePolicy, variant)

Protected method to assemble the jobname arguments.

printer (QPrinter)
  reference to the printer to print to
fileDeletePolicy (int (0 or 1))
  policy determining who deletes the file to be printed (application or system)
variant (str)
  string identifying the print command variant

Returns:
  assembled jobname arguments

Return Type:
  list of str

#### FilePrinter._destination

_destination(printer, variant)

Protected method to assemble the printer destination arguments.

printer (QPrinter)
  reference to the printer to print to
variant (str)
  string identifying the print command variant

Returns:
  assembled printer destination arguments

Return Type:
  list of str

#### FilePrinter._doPrintFile

_doPrintFile(printer, fileName, fileDeletePolicy, pageSelectPolicy, pageRange)

Protected method to print a file.

printer (QPrinter)
  reference to the printer to print to
fileName (str)
  name (path) of the file to be printed
fileDeletePolicy (int (0 or 1))
  policy determining who deletes the file to be printed (application or system)
pageSelectPolicy (int (0 or 1))
  policy determining who selects the pages to be printed (application or system)
pageRange (str)
  string determining the page range(s) to be printed, if SystemSelectsPages was given for pageSelectPolicy and user chose Selection in print dialog

Returns:
  flag indicating successful print job submission

Return Type:
  bool

#### FilePrinter._jobname

_jobname(printer, variant)

Protected method to assemble the jobname arguments.

printer (QPrinter)
  reference to the printer to print to
variant (str)
  string identifying the print command variant

Returns:
  assembled jobname arguments

Return Type:
  list of str

#### FilePrinter._mediaPageSize

_mediaPageSize(printer)

Protected method to get the page size argument.

printer (QPrinter)
  reference to the printer to print to

Returns:
  page size argument

Return Type:
  str

#### FilePrinter._mediaPaperSource

_mediaPaperSource(printer)

Protected method to get the paper source argument.

printer (QPrinter)
  reference to the printer to print to

Returns:
  paper source argument

Return Type:
  str

#### FilePrinter._optionCollateCopies

_optionCollateCopies(printer)

Protected method to assemble the collate copies arguments.

printer (QPrinter)
  reference to the printer to print to

Returns:
  assembled collate copies arguments

Return Type:
  list of str

#### FilePrinter._optionCupsProperties

_optionCupsProperties(printer)

Protected method to assemble the CUPS properties arguments.

printer (QPrinter)
  reference to the printer to print to

Returns:
  assembled CUPS properties arguments

Return Type:
  list of str

#### FilePrinter._optionDoubleSidedPrinting

_optionDoubleSidedPrinting(printer)

Protected method to assemble the double sided printing arguments.

printer (QPrinter)
  reference to the printer to print to

Returns:
  assembled double sided printing arguments

Return Type:
  list of str

#### FilePrinter._optionMedia

_optionMedia(printer)

Protected method to assemble the print media arguments.

printer (QPrinter)
  reference to the printer to print to

Returns:
  assembled print media arguments

Return Type:
  list of str

#### FilePrinter._optionPageOrder

_optionPageOrder(printer)

Protected method to assemble the page order arguments.

printer (QPrinter)
  reference to the printer to print to

Returns:
  assembled page order arguments

Return Type:
  list of str

#### FilePrinter._pages

_pages(printer, pageSelectPolicy, pageRange, useCupsOptions, variant)

Protected method to assemble the page range(s) arguments.

printer (QPrinter)
  reference to the printer to print to
pageSelectPolicy (int (0 or 1))
  policy determining who selects the pages to be printed (application or system)
pageRange (str)
  string determining the page range(s) to be printed, if SystemSelectsPages was given for pageSelectPolicy and user chose Selection in print dialog
useCupsOptions (bool)
  flag indicating to assemble the arguments for CUPS
variant (str)
  string identifying the print command variant

Returns:
  assembled page range(s) arguments

Return Type:
  list of str

#### FilePrinter._printArguments

_printArguments(printer, fileDeletePolicy, pageSelectPolicy, useCupsOptions, pageRange, variant)

Protected method to assemble the command line arguments for the print command.

printer (QPrinter)
  reference to the printer to print to
fileDeletePolicy (int (0 or 1))
  policy determining who deletes the file to be printed (application or system)
pageSelectPolicy (int (0 or 1))
  policy determining who selects the pages to be printed (application or system)
useCupsOptions (bool)
  flag indicating to assemble the arguments for CUPS
pageRange (str)
  string determining the page range(s) to be printed, if SystemSelectsPages was given for pageSelectPolicy and user chose Selection in print dialog
variant (str)
  string identifying the print command variant

Returns:
  assembled command line arguments for the print command

Return Type:
  list of str

Up

## isCupsAvailable

isCupsAvailable()

Static method to test the availability of CUPS.

Returns:
  flag indicating the availability of CUPS

Return Type:
  bool

Up

## printFile

printFile(printer, fileName, fileDeletePolicy=FilePrinter.ApplicationDeletesFiles, pageSelectPolicy=FilePrinter.ApplicationSelectsPages, pageRange="")

Static method to print a file.

Note: Only CUPS and LPR on *nix systems is supported.

printer (QPrinter)
  reference to the printer to print to
fileName (str)
  name (path) of the file to be printed
fileDeletePolicy (int (0 or 1))
  policy determining who deletes the file to be printed (application or system)
pageSelectPolicy (int (0 or 1))
  policy determining who selects the pages to be printed (application or system)
pageRange (str)
  string determining the page range(s) to be printed, if SystemSelectsPages was given for pageSelectPolicy and user chose Selection in print dialog

Up