pdf417BarcodeGenerator()
Generates a high-density linear barcode.
Declaration
class func pdf417BarcodeGenerator() -> any CIFilter & CIPDF417BarcodeGeneratorReturn Value
The generated image.
Discussion
This method generates a PDF417 barcode as an image. PDF417 is a high-density stacked linear barcode format defined in the ISO 15438 standard. Use this filter to generate alphanumeric or numeric-only barcodes. Commonly used on identification cards or inventory management because of the large amount of data the barcode can hold.
The PDF417 barcode generator filter uses the following properties:
messageAn NSData object representing the data to be encoded as a barcode.
minWidthA
floatrepresenting the minimum width of the barcode’s data area, in pixels as an NSNumber.maxWidthA
floatrepresenting the maximum width of the barcode’s data area, in pixels, as an NSNumber.maxHeightA
floatrepresenting the maximum height of the barcode’s data area, in pixels, as an NSNumber.minHeightA
floatrepresenting the minimum height of the barcode’s data area, in pixels, as an NSNumber.dataColumsA
floatrepresenting the number of columns in the data area as an NSNumber.rowsA
floatrepresenting the number of rows in the data area as an NSNumber.preferredAspectRatioA
floatrepresenting the desired aspect ratio as an NSNumber.compactionModeAn option that determines which method the generator uses to compress data as an NSNumber. See the note below for the possible values.
compactStyleA
Booleanvalue of0or1that determines the omission of redundant elements to make the generated barcode more compact as an NSNumber.correctionLevelA
floatbetween 0 and 8 that determines the amount of redundancy to include in the barcode’s data to prevent errors when the barcode is read. If left unspecified, the generator chooses a correction level based on the size of the message data.alwaysSpecifyCompactionA
Booleanvalue of0or1that determines the inclusion of information about the compaction mode in the barcode as an NSNumber. If a PDF417 barcode doesn’t contain compaction mode information, the reader assumes text-based compaction.
The compactionMode property takes one of the following numeric values:
Value | Name | Description |
|---|---|---|
| Automatic | The generator automatically chooses a compression method. This option is the default. |
| Numeric | Valid only when the message is an ASCII-encoded string of digits, achieving optimal compression for that type of data. |
| Text | Valid only when the message is all ASCII-encoded alphanumeric and punctuation characters, achieving optimal compression for that type of data. |
| Byte | Valid for any data, but least compact. |
Select either 1 or the appropriate valid value for your data that gives the most compact output.
The following code creates a filter that generates a PDF417 barcode:
func pdf417Barcode(inputMessage: String) -> CIImage {
let pdf417BarcodeGenerator = CIFilter.pdf417BarcodeGenerator()
pdf417BarcodeGenerator.message = inputMessage.data(using: .ascii)!
pdf417BarcodeGenerator.minWidth = 56
pdf417BarcodeGenerator.maxWidth = 58
pdf417BarcodeGenerator.maxHeight = 283
pdf417BarcodeGenerator.minHeight = 13
pdf417BarcodeGenerator.dataColumns = 9
pdf417BarcodeGenerator.rows = 6
pdf417BarcodeGenerator.preferredAspectRatio = 0.0
pdf417BarcodeGenerator.compactionMode = 1
pdf417BarcodeGenerator.compactStyle = 1
pdf417BarcodeGenerator.correctionLevel = 0.01
pdf417BarcodeGenerator.alwaysSpecifyCompaction = 0
return pdf417BarcodeGenerator.outputImage!
}[Image]
See Also
Filters
attributedTextImageGenerator()aztecCodeGenerator()barcodeGenerator()blurredRectangleGenerator()checkerboardGenerator()code128BarcodeGenerator()lenticularHaloGenerator()meshGenerator()qrCodeGenerator()randomGenerator()roundedRectangleGenerator()roundedRectangleStrokeGenerator()starShineGenerator()stripesGenerator()sunbeamsGenerator()