PSPDFPageTemplate
Objective-C
@interface PSPDFPageTemplate : PSPDFModel <NSSecureCoding>
Swift
class PageTemplate : ModelObject, NSSecureCoding
A PSPDFPageTemplate
helps PSPDFNewPageConfiguration
configure a new page to
be added to a document correctly.
You can modify the templates available via PDFConfiguration
, or setting the
pageTemplates
property on the PSPDFDocumentEditorConfiguration
builder.
-
Instantiates a new page template that will take the page at sourcePageIndex from the provided document to insert into a new document.
Declaration
Objective-C
- (nonnull instancetype)initWithDocument:(nonnull PSPDFDocument *)document sourcePageIndex:(NSUInteger)sourcePageIndex;
Swift
init(document: PSPDFDocument, sourcePageIndex: UInt)
Parameters
document
The source document to get the template from.
sourcePageIndex
The page index to extract the template from the document.
Return Value
PSPDFPageTemplate instance.
-
Instantiates a new page template that will tile the a page at sourcePageIndex from the provided document, to insert as a new page into another document.
Declaration
Objective-C
- (nonnull instancetype) initWithTiledPatternFromDocument:(nonnull PSPDFDocument *)document sourcePageIndex:(NSUInteger)sourcePageIndex;
Swift
init(tiledPatternFrom document: PSPDFDocument, sourcePageIndex: UInt)
Parameters
document
The document the tiled pattern should be extracted from.
sourcePageIndex
The page index to extrate the template from the document.
Return Value
PSPDFPageTemplate instance.
-
Instantiates a template with a given page type and identifier.
Declaration
Objective-C
- (nonnull instancetype)initWithPageType:(PSPDFNewPageType)pageType identifier: (nullable PSPDFTemplateIdentifier)identifier;
Swift
init(pageType: PageTemplate.NewPageType, identifier: PageTemplate.Identifier?)
Parameters
pageType
The page type to assign to this pattern.
identifier
Arbitrary identifier to assign to the template.
-
A thumbnail representative of the page template.
For tiled templates, the resulting image is itself a pattern and needs to be rendered as such.
Declaration
Objective-C
- (void)renderThumbnailWithSize:(CGSize)size completion: (nonnull void (^)(NSImage *_Nullable, NSError *_Nullable))completion;
Swift
func renderThumbnail(with size: CGSize, completion: @escaping (NSImage?, Error?) -> Void)
Parameters
completion
Block to call when the rendering succeeds or fails. If there was an error while rendering the thumbnail, the first parameter will be
nil
, and the second parameter will contain the reason. -
The type of page that will be created.
Declaration
Objective-C
@property (nonatomic, readonly) PSPDFNewPageType pageType;
Swift
var pageType: PageTemplate.NewPageType { get }
-
The template’s identifier, if this is one of the predefined patterns.
Declaration
Objective-C
@property (nonatomic, readonly, nullable) PSPDFTemplateIdentifier identifier;
Swift
var identifier: PageTemplate.Identifier? { get }
-
The name of the template, not localized.
Warning
Renaming internal default templates will assert.Declaration
Objective-C
@property (nonatomic, copy, nullable) PSPDFTemplateIdentifier templateName;
Swift
var templateName: PageTemplate.Identifier? { get set }
-
Localized version of the identifier, suitable for display.
Declaration
Objective-C
@property (nonatomic, readonly) NSString *_Nonnull localizedName;
Swift
var localizedName: String { get }
-
The template’s resource URL. Can be nil.
This is the source PDF of
sourceDocument
or of the predefined page patterns PDFs.Declaration
Objective-C
@property (nonatomic, readonly, nullable) NSURL *resourceURL;
Swift
var resourceURL: URL? { get }
-
The template’s source document, if it was instantiated with one. Can be nil.
Declaration
Objective-C
@property (nonatomic, readonly, nullable) PSPDFDocument *sourceDocument;
Swift
var sourceDocument: PSPDFDocument? { get }
-
The source document’s page index to take the page from when processing the template.
Declaration
Objective-C
@property (nonatomic, readonly) NSUInteger sourcePageIndex;
Swift
var sourcePageIndex: UInt { get }
-
Array containing the default set of templates provided by PSPDFKit. This contains .blank, .imagePicker, .dot5mm, .grid5mm, .lines5mm, and .lines7mm.
Declaration
Objective-C
@property (class, nonatomic, readonly) NSArray<PSPDFPageTemplate *> *_Nonnull defaultTemplates;
Swift
class var defaultTemplates: [PageTemplate] { get }
-
Instantiates a blank page template.
Declaration
Objective-C
@property (class, nonatomic, readonly) PSPDFPageTemplate *_Nonnull blankTemplate;
Swift
class var blank: PageTemplate { get }
Return Value
PSPDFPageTemplate instance with
PSPDFNewPageTypeEmptyPage
andPSPDFTemplateIdentifierBlank
. -
Instantiates a page template that acts as a placeholder to let the user import an image to use as background for a new page.
This template has no actual content attached to it. When a user taps this option from the page background picker in
PSPDFNewPageViewController
, then an image can be imported from either the Photo Library or Camera.To provide a default image to use with this template, set
PSPDFDocumentEditorConfiguration.selectedImage
.See
+[PSPDFImagePickerController availableImagePickerSourceTypes];Declaration
Objective-C
@property (class, nonatomic, readonly) PSPDFPageTemplate *_Nonnull imagePickerTemplate;
Swift
class var imagePicker: PageTemplate { get }