PTPrint
@interface PTPrint : NSObject
The PTPrint class handles preparing a PTPDFDoc for printing.
-
Returns a new
PTPrintPrepareDocumentHandlerfor the given PDF document.Declaration
Objective-C
+ (nonnull PTPrintPrepareDocumentHandler *)CreatePrintFormatterForDocument: (nonnull PTPDFDoc *)pdfDoc;Swift
class func createPrintFormatter(forDocument pdfDoc: PTPDFDoc) -> PTPrintPrepareDocumentHandlerParameters
pdfDocThe PDF document to be formatted for printing.
Return Value
A new
PTPrintPrepareDocumentHandlerinstance.
-
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:(nonnull PTPDFDoc *)doc Delegate:(nonnull id<PTPrintDelegate>)printDelegate UserData:(nonnull id)userData;Swift
func prepareDoc(toPrint doc: PTPDFDoc, delegate printDelegate: any PTPrintDelegate, userData: Any)Parameters
docA valid
PTPDFDocobject.printDelegateAn object that conforms to the
PTPrintDelegateprotocol.userDataUser 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:(nonnull NSString *)docFilePath FromRect:(CGRect)rect InView:(nonnull UIView *)view WithJobName:(nullable NSString *)jobName Animated:(BOOL)animated CompletionHandler: (nonnull UIPrintInteractionCompletionHandler)completionHandler;Swift
func printDoc(_ docFilePath: String, from rect: CGRect, in view: UIView, withJobName jobName: String?, animated: Bool) async throws -> (UIPrintInteractionController, Bool)Parameters
docFilePathNumber of seconds between refreshes.
rectThe rectangle from which to present the
UIPrintInteractionController.viewThe view that is the superview of the presented
UIPrintInteractionController.jobNameThe name of the print job. (Optional)
animatedWhether the presented
UIPrintInteractionControlleris animated.completionHandlerFunction 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:(nonnull NSString *)docFilePath FromBarButtonItem:(nonnull UIBarButtonItem *)barButtonItem WithJobName:(nullable NSString *)jobName Animated:(BOOL)animated CompletionHandler: (nonnull UIPrintInteractionCompletionHandler)completionHandler;Swift
func printDoc(_ docFilePath: String, from barButtonItem: UIBarButtonItem, withJobName jobName: String?, animated: Bool) async throws -> (UIPrintInteractionController, Bool)Parameters
docFilePathThe file path of the PDF document that will be printed.
barButtonItemThe
UIBarButtonItemobject that the user tapped for printing.jobNameThe name of the print job. (Optional)
animatedWhether the presented
UIPrintInteractionControlleris animated.completionHandlerFunction 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:(nonnull NSString *)docFilePath WithJobName:(nullable NSString *)jobName Animated:(BOOL)animated CompletionHandler: (nonnull UIPrintInteractionCompletionHandler)completionHandler;Swift
func printDoc(_ docFilePath: String, withJobName jobName: String?, animated: Bool) async throws -> (UIPrintInteractionController, Bool)Parameters
docFilePathThe file path of the PDF document that will be printed.
jobNameThe name of the print job. (Optional)
animatedWhether the presented
UIPrintInteractionControlleris animated.completionHandlerFunction that is called when printing is complete.
PTPrint Class Reference