public class

Print

extends Object
java.lang.Object
   ↳ com.pdftron.pdf.Print

Class Overview

Print is a utility class that can be used to print PDF documents. It is only supported on Android 4.4 and up (API Level 19+).

Summary

Nested Classes
class Print.Compat Compatibility layer for older API. 
interface Print.PrintCallback PrintCallback interface provides a way for users to receive callback when print job is finished. 
Constants
int PRINT_CONTENT_ANNOTATION_BIT
int PRINT_CONTENT_DOCUMENT_BIT
int PRINT_CONTENT_SUMMARY_BIT
Public Constructors
Print()
Public Methods
static void addPrintListener(Print.PrintCallback listener)
Add a listener that will be invoked by Print.PrintCallback.
static void clearPrintListeners()
Remove all listeners that are notified of any callback from PrintCallback.
static PDFDoc exportAnnotations(PDFDoc inputDoc, boolean isRtl)
Export comments and summary of annotations
static void removePrintListener(Print.PrintCallback listener)
Remove a listener that was previously added via addPrintListener(PrintCallback).
static void startPrintJob(Context context, String jobName, PDFDoc doc, String password, Integer printContent, Boolean isRtl)
Print the document using the current available printers or print services installed on the device and the supplied password.
static void startPrintJob(Context context, String jobName, PDFDoc inputDoc, Integer printContent, Boolean isRtl)
Print the document using the current available printers or print services installed on the device.
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final int PRINT_CONTENT_ANNOTATION_BIT

Constant Value: 2 (0x00000002)

public static final int PRINT_CONTENT_DOCUMENT_BIT

Constant Value: 1 (0x00000001)

public static final int PRINT_CONTENT_SUMMARY_BIT

Constant Value: 4 (0x00000004)

Public Constructors

public Print ()

Public Methods

public static void addPrintListener (Print.PrintCallback listener)

Add a listener that will be invoked by Print.PrintCallback.

Components that add a listener should take care to remove it when finished. Other components that take ownership of the print may call clearPrintListeners() to remove all attached listeners.

Parameters
listener listener to add

public static void clearPrintListeners ()

Remove all listeners that are notified of any callback from PrintCallback.

public static PDFDoc exportAnnotations (PDFDoc inputDoc, boolean isRtl)

Export comments and summary of annotations

Parameters
inputDoc the document to be printed
isRtl if true, the summary of annotations will be right aligned; otherwise, left aligned
Returns
  • the output document containing comments and summary of annotations
Throws
com.pdftron.common.PDFNetException
PDFNetException

public static void removePrintListener (Print.PrintCallback listener)

Remove a listener that was previously added via addPrintListener(PrintCallback).

Parameters
listener listener to remove

public static void startPrintJob (Context context, String jobName, PDFDoc doc, String password, Integer printContent, Boolean isRtl)

Print the document using the current available printers or print services installed on the device and the supplied password.

This method will try to initialize the document's SecurityHandler using the supplied password (it assumes the document uses standard security).

Parameters
context the context
jobName job name which will be displayed in the print queue
doc the document to be printed
password the password
printContent the content to be printed. Valid values are
  • {1: document only}
  • {3: document and annotations
  • {4: summary of annotations only
  • {7: document, annotations and summary of annotations
isRtl if true, the summary of annotations will be right aligned; otherwise, left aligned
Throws
PDFNetException It will explicitly throw the exception if:
  • the document is encrypted and the password is wrong

public static void startPrintJob (Context context, String jobName, PDFDoc inputDoc, Integer printContent, Boolean isRtl)

Print the document using the current available printers or print services installed on the device.

Note:

Parameters
context the context
jobName job name which will be displayed in the print queue
inputDoc the document to be printed
printContent the content to be printed. Valid values are
  • {1: document only}
  • {3: document and annotations
  • {4: summary of annotations only
  • {7: document, annotations and summary of annotations
isRtl if true, the summary of annotations will be right aligned; otherwise, left aligned
Throws
PDFNetException It will explicitly throw the exception if:
  • the device is not running on Android 4.4 (API Level 19) or higher
  • the document is a portfolio/collection