PSPDFProcessorConfiguration


@interface PSPDFProcessorConfiguration : NSObject <NSCopying>

Container for various settings for manipulating documents with PSPDFProcessor.

Note

Some basic options are available without the Document Editor component, however most options do require this component to be licensed. Learn more at https://pspdfkit.com/pdf-sdk/ios/document-editor/
  • Designated initializer

    Declaration

    Objective-C

    - (nullable instancetype)initWithDocument:(nullable PSPDFDocument *)document;

    Swift

    init?(document: PSPDFDocument?)

    Parameters

    document

    The document that the configuration is based on. If a document is given, it needs to be valid, else we return nil.

    Return Value

    The processor configuration or nil in case the document cannot be processed or is not valid.

  • The source document.

    Declaration

    Objective-C

    @property (readonly, nonatomic, nullable) PSPDFDocument *document;

    Swift

    var document: PSPDFDocument? { get }
  • Returns the page count of the currently configured generated document.

    Declaration

    Objective-C

    @property (readonly, nonatomic) NSInteger pageCount;

    Swift

    var pageCount: Int { get }
  • Instructs the processor to change form field names as described in the mapping. The partial field name (see PDF Reference 1.7, 12.7.3.2, “Field Names”).

    Note

    This method requires the Document Editor component to be enabled for your license.

    Declaration

    Objective-C

    @property (readwrite, copy, nonatomic)
        NSDictionary<NSString *, NSString *> *_Nonnull formFieldNameMappings;

    Swift

    var formFieldNameMappings: [String : String] { get set }
  • Instructs the processor to change form mapping names as described in the mapping. The mapping name that shall be used when exporting interactive form field data from the document.

    Note

    This method requires the Document Editor component to be enabled for your license.

    Declaration

    Objective-C

    @property (readwrite, copy, nonatomic)
        NSDictionary<NSString *, NSString *> *_Nonnull formMappingNameMappings;

    Swift

    var formMappingNameMappings: [String : String] { get set }
  • Moves pages from the specified indexes to the destination index.

    Note

    This method requires the Document Editor component to be enabled for your license.

    Declaration

    Objective-C

    - (void)movePages:(nonnull NSIndexSet *)indexes
        toDestinationIndex:(PSPDFPageIndex)destinationPageIndex;

    Swift

    func movePages(_ indexes: IndexSet, toDestinationIndex destinationPageIndex: PageIndex)
  • Removes pages from the document. This will also update pageCount.

    Declaration

    Objective-C

    - (void)removePages:(nonnull NSIndexSet *)indexes;

    Swift

    func removePages(_ indexes: IndexSet)
  • If this is set to @YES, all blank pages will be removed from the generated document. This does NOT update pageCount as it only goes into effect while processing the document.

    Declaration

    Objective-C

    - (void)setShouldStripBlankPagesOnGenerate:(BOOL)shouldStrip;

    Swift

    func setShouldStripBlankPagesOnGenerate(_ shouldStrip: Bool)
  • Removes all pages that are not listed in indexes.

    Declaration

    Objective-C

    - (void)includeOnlyIndexes:(nonnull NSIndexSet *)indexes;

    Swift

    func includeOnlyIndexes(_ indexes: IndexSet)
  • Rotates a page. degrees must be a value of 0, 90, 180 or 270.

    Note

    This method requires the Document Editor component to be enabled for your license.

    Declaration

    Objective-C

    - (void)rotatePage:(PSPDFPageIndex)pageIndex by:(PSPDFRotation)degrees;

    Swift

    func rotatePage(_ pageIndex: PageIndex, by degrees: Rotation)
  • Scales the given page index to the given size. The size must be specified in PDF points.

    Note

    This method requires the Document Editor component to be enabled for your license.

    Declaration

    Objective-C

    - (void)scalePage:(PSPDFPageIndex)pageIndex toSize:(CGSize)size;

    Swift

    func scalePage(_ pageIndex: PageIndex, to size: CGSize)
  • Scales the given page index to the given size. The size must be specified in millimeters.

    Note

    This method requires the Document Editor component to be enabled for your license.

    Declaration

    Objective-C

    - (void)scalePage:(PSPDFPageIndex)pageIndex toSizeInMillimeter:(CGSize)mmSize;

    Swift

    func scalePage(_ pageIndex: PageIndex, toSizeInMillimeter mmSize: CGSize)
  • Changes the CropBox for the given page to the given rect. The rect must be specified in points. This does NOT scale the page. See scalePage:toSizeInMillimeter: and scalePage:toSize:. Definition of a CropBox from the PDF spec: The crop box defines the region to which the contents of the page shall be clipped (cropped) when displayed or printed. Unlike the other boxes, the crop box has no defined meaning in terms of physical page geometry or intended use; it merely imposes clipping on the page contents. However, in the absence of additional information (such as imposition instructions specified in a JDF or PJTF job ticket), the crop box determines how the page’s contents shall be positioned on the output medium. The default value is the page’s media box. TL;DR: The visible part of the page.

    Note

    This method requires the Document Editor component to be enabled for your license.

    Declaration

    Objective-C

    - (void)changeCropBoxForPageAtIndex:(PSPDFPageIndex)pageIndex
                                 toRect:(CGRect)rect;

    Swift

    func changeCropBoxForPage(at pageIndex: PageIndex, to rect: CGRect)
  • Changes the MediaBox for the given page to the given rect. The rect must be specified in points. This does NOT scale the page. See scalePage:toSizeInMillimeter: and scalePage:toSize:. Definition of a MediaBox from the PDF spec: The media box defines the boundaries of the physical medium on which the page is to be printed. It may include any extended area surrounding the finished page for bleed, printing marks, or other such purposes. It may also include areas close to the edges of the medium that cannot be marked because of physical limitations of the output device. Content falling outside this boundary may safely be discarded without affecting the meaning of the PDF file. TL;DR: The size of the page.

    Note

    This method requires the Document Editor component to be enabled for your license.

    Declaration

    Objective-C

    - (void)changeMediaBoxForPageAtIndex:(PSPDFPageIndex)pageIndex
                                  toRect:(CGRect)rect;

    Swift

    func changeMediaBoxForPage(at pageIndex: PageIndex, to rect: CGRect)
  • Adds a new page at destinationPageIndex. If newPageConfiguration is nil, the size of the new page will match the page size of the first page.

    Note

    This method requires the Document Editor component to be enabled for your license.

    Declaration

    Objective-C

    - (void)addNewPageAtIndex:(PSPDFPageIndex)destinationPageIndex
                configuration:
                    (nullable PSPDFNewPageConfiguration *)newPageConfiguration;

    Swift

    func addNewPage(at destinationPageIndex: PageIndex, configuration newPageConfiguration: PSPDFNewPageConfiguration?)
  • This method allows you to change how a certain type of annotation is included in the resulting document. If all annotations should be changed, use PSPDFAnnotationTypeAll as the annotationTypes. If finer control is needed, look at modifyAnnotations:change:error:.

    Declaration

    Objective-C

    - (void)modifyAnnotationsOfTypes:(PSPDFAnnotationType)annotationTypes
                              change:(PSPDFAnnotationChange)annotationChange;

    Swift

    func modifyAnnotations(ofTypes annotationTypes: AnnotationType, change annotationChange: PSPDFAnnotationChange)
  • This method allows you to change the way certain annotations are included in the resulting document. The annotations selected here take priority over the changes specified using modifyAnnotationsOfType:change: or modifyFormsOfType:change:.

    Note

    This method might take a long time if you specify a lot of annotations. Use carefully.

    Declaration

    Objective-C

    - (BOOL)modifyAnnotations:(nonnull NSArray<PSPDFAnnotation *> *)annotations
                       change:(PSPDFAnnotationChange)annotationChange
                        error:(NSError *_Nullable *_Nullable)error;

    Swift

    func modifyAnnotations(_ annotations: [PSPDFAnnotation], change annotationChange: PSPDFAnnotationChange) throws
  • This method allows you to change the way certain form types are included in the resulting document. For example, you can choose to only remove signature form elements.

    Note

    This method requires the AcroForm component to be enabled for your license.

    Declaration

    Objective-C

    - (void)modifyFormsOfType:(PSPDFFormFieldType)formFieldType
                       change:(PSPDFAnnotationChange)annotationChange;

    Swift

    func modifyForms(of formFieldType: PSPDFFormFieldType, change annotationChange: PSPDFAnnotationChange)
  • Merges the item onto the page with index destinationPageIndex. A item can be a image or another PDF page, see PSPDFProcessorItem.

    Note

    This method requires the Document Editor component to be enabled for your license.

    Declaration

    Objective-C

    - (void)mergeItem:(nonnull PSPDFProcessorItem *)item
               onPage:(PSPDFPageIndex)destinationPageIndex;

    Swift

    func merge(_ item: PSPDFProcessorItem, onPage destinationPageIndex: PageIndex)
  • Adds drawing commands to every page.

    The drawing block of type PSPDFRenderDrawBlock will be called for each page. The drawing will get flattened on each page currently configured to be exported.

    This will set up a similar drawing block as you’d get with calling UIGraphicsBeginImageContext. The origin will be in the top-left of the visible area of the page. The page rectangle passed to the drawing block has zero origin and the size has the page rotation applied.

    Declaration

    Objective-C

    - (void)drawOnAllCurrentPages:(nonnull PSPDFRenderDrawBlock)drawBlock;

    Swift

    func drawOnAllCurrentPages(_ drawBlock: @escaping PSPDFRenderDrawBlock)
  • Adjusts the stroke color of a given page.

    Note

    This method requires the Comparison component to be enabled for your license.

    Declaration

    Objective-C

    - (void)changeStrokeColorOnPageAtIndex:(PSPDFPageIndex)pageIndex
                                   toColor:(nonnull UIColor *)color;

    Swift

    func changeStrokeColorOnPage(at pageIndex: PageIndex, to color: UIColor)

    Parameters

    pageIndex

    Index of the page, whose stroke color should be changed.

    color

    The new color used to change the strokes.

  • Merges a page from a source document with a page of the configuration’s document.

    Note

    sourceDocument can only contain a single data provider.

    Note

    This method requires the Comparison component to be enabled for your license.

    Declaration

    Objective-C

    - (void)mergePageFromDocument:(nonnull PSPDFDocument *)sourceDocument
                         password:(nullable NSString *)password
                  sourcePageIndex:(PSPDFPageIndex)sourcePageIndex
             destinationPageIndex:(PSPDFPageIndex)destinationPageIndex
                        transform:(CGAffineTransform)transform
                        blendMode:(CGBlendMode)blendMode;

    Swift

    func mergePage(from sourceDocument: PSPDFDocument, password: String?, sourcePageIndex: PageIndex, destinationPageIndex: PageIndex, transform: CGAffineTransform, blendMode: CGBlendMode)

    Parameters

    sourceDocument

    Document containing the page that should be merged.

    password

    The password the source document is encrypted with. Use nil if the source document is not encrypted.

    sourcePageIndex

    Index of the source document’s page that should be used for merging.

    destinationPageIndex

    Index of the destination document’s page the source page should be merged into.

    transform

    Defines how the merged page should be transformed. Use identity to leave it unchanged.

    blendMode

    Defines how the two pages should be blended into each other.

  • Applies all redaction annotations on all pages of the document. Only takes effect once the document is processed with PSPDFProcessor.

    Note

    This method requires the Redaction component to be enabled for your license.

    Declaration

    Objective-C

    - (void)applyRedactions;

    Swift

    func applyRedactions()
  • Applies all redaction annotations on a specified page index of the document. Only takes effect once the document is processed with PSPDFProcessor.

    Note

    This method requires the Redaction component to be enabled for your license.

    Declaration

    Objective-C

    - (void)applyRedactionsOnPageAtIndex:(PSPDFPageIndex)pageIndex;

    Swift

    func applyRedactionsOnPage(at pageIndex: PageIndex)

    Parameters

    pageIndex

    Index of the page where all redaction annotations should be applied.

  • Returns the metadata that will be written into the new document. By default, this is set to the metadata of the original document.

    Note

    On writing metadata to the new document, PSPDFMetadataModDateKey will be set to the current date and time and PSPDFMetadataProducerKey will be set to PSPDFKit. You can overwrite these values by setting them with updateMetadata.

    Declaration

    Objective-C

    @property (readonly, nonatomic)
        NSDictionary<NSString *, NSString *> *_Nonnull metadata;

    Swift

    var metadata: [String : String] { get }
  • Updates the metadata that will be saved in the generated PDF. Any value you pass along here will either be replaced or inserted into the current metadata configuration. See PSPDFMetadataTitleKey for examples of what keys to use.

    Note

    This does not remove any metadata entries. See clearMetadata.

    Declaration

    Objective-C

    - (void)updateMetadata:(nonnull NSDictionary<NSString *, NSString *> *)metadata;

    Swift

    func updateMetadata(_ metadata: [String : String])
  • Clears any previous metadata.

    Note

    PSPDFMetadataModDateKey and PSPDFMetadataProducerKey will still be set in the resulting PDF. See metadata.

    Declaration

    Objective-C

    - (void)clearMetadata;

    Swift

    func clearMetadata()