PTPrint

@interface PTPrint : NSObject <UIPrintInteractionControllerDelegate>

The PTPrint class handles preparing a PTPDFDoc for printing with a system UIPrintInteractionController.

  • An asynchronous selector that prepares a document for printing and calls the printDelegate‘s -[PTPrintDelegate PreparedToPrint:UserData:] when preparation is complete. It may take a moment to prepare the document, so it is recommended that the user be presented with information to this effect.

    Declaration

    Objective-C

    - (void)PrepareDocToPrint:(PTPDFDoc *)doc
                     Delegate:(id<PTPrintDelegate>)printDelegate
                     UserData:(id)userData;

    Swift

    func prepareDoc(toPrint doc: PTPDFDoc!, delegate printDelegate: PTPrintDelegate!, userData: Any!)

    Parameters

    doc

    A valid PTPDFDoc object.

    printDelegate

    An object that conforms to the PTPrintDelegate protocol.

    userData

    User data that is provided to the delegate’s callback selector. (Optional)

  • For iPad. A convenience method to print the PDF document located where the first parameter points. Typically called from an implementation of the -[PTPrintDelegate PreparedToPrint:UserData:] method.

    (If called on an iPhone, then 2nd and 3rd parameters are ignored.)

    Declaration

    Objective-C

    - (void)PrintDoc:(NSString *)docFilePath
                 FromRect:(CGRect)rect
                   InView:(UIView *)view
              WithJobName:(NSString *)jobName
                 Animated:(BOOL)animated
        CompletionHandler:(UIPrintInteractionCompletionHandler)completionHandler;

    Swift

    func printDoc(_ docFilePath: String!, from rect: CGRect, in view: UIView!, withJobName jobName: String!, animated: Bool, completionHandler: UIPrintInteractionController.CompletionHandler!)

    Parameters

    docFilePath

    Number of seconds between refreshes.

    rect

    The rectangle from which to present the UIPrintInteractionController.

    view

    The view that is the superview of the presented UIPrintInteractionController.

    jobName

    The name of the print job. (Optional)

    animated

    Whether the presented UIPrintInteractionController is animated.

    completionHandler

    Function that is called when printing is complete.

  • For iPad. A convenience method to print the PDF document located where the first parameter points. Typically called from an implementation of the -[PTPrintDelegate PreparedToPrint:UserData:] method.

    (If called on an iPhone, then 2nd parameter is ignored.)

    Declaration

    Objective-C

    - (void)PrintDoc:(NSString *)docFilePath
        FromBarButtonItem:(UIBarButtonItem *)barButtonItem
              WithJobName:(NSString *)jobName
                 Animated:(BOOL)animated
        CompletionHandler:(UIPrintInteractionCompletionHandler)completionHandler;

    Swift

    func printDoc(_ docFilePath: String!, from barButtonItem: UIBarButtonItem!, withJobName jobName: String!, animated: Bool, completionHandler: UIPrintInteractionController.CompletionHandler!)

    Parameters

    docFilePath

    The file path of the PDF document that will be printed.

    barButtonItem

    The UIBarButtonItem object that the user tapped for printing.

    jobName

    The name of the print job. (Optional)

    animated

    Whether the presented UIPrintInteractionController is animated.

    completionHandler

    Function that is called when printing is complete.

  • For iPhone (and iPod Touch). A convenience method to print the PDF document located where the first parameter points. Typically called from an implementation of the -[PTPrintDelegate PreparedToPrint:UserData:] method.

    Declaration

    Objective-C

    - (void)PrintDoc:(NSString *)docFilePath
              WithJobName:(NSString *)jobName
                 Animated:(BOOL)animated
        CompletionHandler:(UIPrintInteractionCompletionHandler)completionHandler;

    Swift

    func printDoc(_ docFilePath: String!, withJobName jobName: String!, animated: Bool, completionHandler: UIPrintInteractionController.CompletionHandler!)

    Parameters

    docFilePath

    The file path of the PDF document that will be printed.

    jobName

    The name of the print job. (Optional)

    animated

    Whether the presented UIPrintInteractionController is animated.

    completionHandler

    Function that is called when printing is complete.