PSPDFPageTemplate


@interface PSPDFPageTemplate : PSPDFModel

A PSPDFPageTemplate helps PSPDFNewPageConfiguration configure a new page to be added to a document correctly.

You can modify the templates available via PSPDFConfiguration, 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: PSPDFNewPageType, identifier: TemplateIdentifier?)

    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 (^)(UIImage *_Nullable,
                                               NSError *_Nullable))completion;

    Swift

    func renderThumbnail(with size: CGSize, completion: @escaping (UIImage?, 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 (readonly, nonatomic) PSPDFNewPageType pageType;

    Swift

    var pageType: PSPDFNewPageType { get }
  • The template’s identifier, if this is one of the predefined patterns.

    Declaration

    Objective-C

    @property (readonly, nonatomic, nullable) PSPDFTemplateIdentifier identifier;

    Swift

    var identifier: TemplateIdentifier? { get }
  • The name of the template, not localized.

    Warning

    Renaming internal default templates will assert.

    Declaration

    Objective-C

    @property (readwrite, copy, nonatomic, nullable)
        PSPDFTemplateIdentifier templateName;

    Swift

    var templateName: TemplateIdentifier? { get set }
  • Localized version of the identifier, suitable for display.

    Declaration

    Objective-C

    @property (readonly, nonatomic) 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 (readonly, nonatomic, 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 (readonly, nonatomic, 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 (readonly, assign, nonatomic) NSUInteger sourcePageIndex;

    Swift

    var sourcePageIndex: UInt { get }
  • Array containing the default set of templates provided by PSPDFKit. This contains .dot5mm, .grid5mm, .lines5mm and .lines7mm.

    Declaration

    Objective-C

    @property (readonly, nonatomic, class)
        NSArray<PSPDFPageTemplate *> *_Nonnull defaultTemplates;

    Swift

    class var defaultTemplates: [PSPDFPageTemplate] { get }
  • Instantiates a blank page template.

    Declaration

    Objective-C

    @property (readonly, nonatomic, class) PSPDFPageTemplate *_Nonnull blankTemplate;

    Swift

    class var blank: PSPDFPageTemplate { get }

    Return Value

    PSPDFPageTemplate instance with PSPDFNewPageTypeEmptyPage and PSPDFTemplateIdentifierBlank.