PTPrint
@interface PTPrint : NSObject
The PTPrint
class handles preparing a PTPDFDoc
for printing.
-
Returns a new
PTPrintPrepareDocumentHandler
for the given PDF document.Declaration
Objective-C
+ (nonnull PTPrintPrepareDocumentHandler *)CreatePrintFormatterForDocument: (nonnull PTPDFDoc *)pdfDoc;
Swift
class func createPrintFormatter(forDocument pdfDoc: PTPDFDoc) -> PTPrintPrepareDocumentHandler
Parameters
pdfDoc
The PDF document to be formatted for printing.
Return Value
A new
PTPrintPrepareDocumentHandler
instance.
-
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
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:(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
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:(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
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:(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
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.