Stephen's Space

PDFLib

PDFLib provides a high-level interface to the PDFKit framework, allowing for easy PDF manipulation and modification. The library also provides functionalities such as PDF OCR, document enhancement, and more.

PDFLib Basics

Script Objects

ILImage

Wrapper object around NSImage and CoreImage functionality providing easy access to complex operations.

Instance Handlers

flip over axis - Flips the image vertically or horizontally. axis must be one of X_AXIS, Y_AXIS, 0, or 1.

rotate by degrees - Rotates the image clockwise by the specified amount of degrees. degrees must be a real number.

extractText() - Extracts text from the image. Returns a list of text strings found in the image.

classifications above confidenceThreshold - Gets a list of possible classifications for objects in the image. confidenceThreshold must be a real number representing the minimum confidence level of each returned classification. Returns the classifications as a list of record objects with identifier (text) and confidence (real) fields.

extractPayloads() - Gets the payload text of all barcodes, QR codes, etc. in the image. Returns the payloads as a list of text strings.

countFaces() - Returns the integer number of human faces observed in the image.

save in filePath as fileType - Saves the image at the provided file path using the specified file type. If the image was loaded from a local file, filePath defaults to the original file path. fileType must be one of "png", "jpg", "jpeg", "gif", "bmp", or "tiff", and it defaults to "png". Returns true if the image was saved successfully, false otherwise.

open - Opens the image, accounting for any modifications. Returns true if the image was opened successfully, false otherwise.


Top-Level Handlers

extractText from theImage - Extracts text from an ILImage object. Returns the list of text strings found in the image.

|rotation| of theImage by degrees - Rotates an ILImage object clockwise by the specified amount of degrees. degrees must be a real number.

rotate(theImage, degrees) - Rotates an ILImage object clockwise by the specified amount of degrees. degrees must be a real number.

classifications for theImage above confidenceThreshold - Gets a list of possible classifications for objects in an ILImage object. confidenceThreshold must be a real number representing the minimum confidence level of each returned classification. Returns the classifications as a list of record objects with identifier (text) and confidence (real) fields.

extractPayloads from theImage - Gets the payload text of all barcodes, QR codes, etc. in an ILImage object. Returns the payloads as a list of text strings.

countFaces for theImage - Returns the integer number of human faces observed in an ILImage object.

Symbol(symbolName, pointSize) - Initializes an ILImage script object from the system symbol with the specified name, sized to the specified point size. symbolName must be a text string, and pointSize must be a number. Returns the newly created ILImage object.

createImage from theData - Creates an ILImage object from the provided data. theData can be either an AppleScript or Objective-C data object, or a base 64 encoded string. Returns the newly created ILImage object.

imageFromData:theData - Creates an ILImage object from the provided data. theData can be either an AppleScript or Objective-C data object, or a base 64 encoded string. Returns the newly created ILImage object.


Constants

X_AXIS = 1 - The horizontal axis of an image; the line comprising the bottom edge of the image.

Y_AXIS = 0 - The vertical axis of the image; the line comprising the left edge of the image.