New-KFBarcode

Syntax

New-KFBarcode 
  -AsStream 
  -Data <string>
  [-BarcodeFormat <format> ("QR_CODE")]
  [-Height <int> (100)] 
  [-Width <int> (100)]
  [-Margin <int> (10))
  [-PureBarcode[:$false]]
  [-GS1Format[:$false]]
  [-ErrorCorrection <error-correction> ($null)]
  [-BackgroundColor <bg-color> ("White")]
  [-ForegroundColor <fg-color> ("Black")]
  [-OutputImageFormat <output-format> ("png")]
  [-ThrowErrors[:$true]]
New-KFBarcode 
  -AsBase64 
  -Data <string>
  [-BarcodeFormat <format> ("QR_CODE")]
  [-Height <int> (100)] 
  [-Width <int> (100)]
  [-Margin <int> (10))
  [-PureBarcode[:$false]]
  [-GS1Format[:$false]]
  [-ErrorCorrection <error-correction> ($null)]
  [-BackgroundColor <bg-color> ("White")]
  [-ForegroundColor <fg-color> ("Black")]
  [-OutputImageFormat <output-format> ("png")]
  [-ThrowErrors[:$true]]
New-KFBarcode 
  -AsDataUrl 
  -Data <string>
  [-BarcodeFormat <format> ("QR_CODE")]
  [-Height <int> (100)] 
  [-Width <int> (100)]
  [-Margin <int> (10))
  [-PureBarcode[:$false]]
  [-GS1Format[:$false]]
  [-ErrorCorrection <error-correction> ($null)]
  [-BackgroundColor <bg-color> ("White")]
  [-ForegroundColor <fg-color> ("Black")]
  [-OutputImageFormat <output-format> ("png")]
  [-ThrowErrors[:$true]]
New-KFBarcode 
  -AsString 
  -Data <string>
  [-BarcodeFormat <format> ("QR_CODE")]
  [-Height <int> (100)] 
  [-Width <int> (100)]
  [-Margin <int> (10))
  [-PureBarcode[:$false]]
  [-GS1Format[:$false]]
  [-ErrorCorrection <error-correction> ($null)]
  [-BackgroundColor <bg-color> ("White")]
  [-ForegroundColor <fg-color> ("Black")]
  -OutputImageFormat Svg
  [-ThrowErrors[:$true]]

Support

>= kenaflow 2.0.28

Return

System.Stream or string.

Description

We use the open source library ZXING.NET to generate barcodes from within a kenaflow workflow.

The barcode can be returned by the cmdlet as a System.Stream object or a Base64 encoded string that contains the barcode image or as a so called "data URL" that contains the image for easy embedding into HTML.

The data for the barcode is provided with parameter -data <string>.

Valid barcode formats are:

  • QR_CODE
  • AZTEC
  • CODABAR
  • CODE_39
  • CODE_93
  • CODE_128
  • DATA_MATRIX
  • EAN_8
  • EAN_13
  • ITF
  • MAXICODE
  • PDF_417
  • RSS_14
  • RSS_EXPANDED
  • UPC_A
  • UPC_E
  • All_1D
  • UPC_EAN_EXTENSION
  • MSI
  • PLESSEY
  • IMB

The default ist "QR_CODE".

-GS1Format can be used with "DATA_MATRIX" and "CODE_128".

-ErrorCorrection <error-correction> can be used to tell the encode how much redundancy should be included in the barcode image. <error-correction> is a string. It's value depends on the barcode type.

For "QR_CODE":

"H" : ~30% correction "Q" : ~25% correction "M" : ~15% correction "L" : ~7% correction

[-OutputImageFormat <output-format> ("png")] specifies the image format that is created. Here are the supported types:

  • Bmp
  • Emf
  • Gif
  • Icon
  • Jpeg
  • Png
  • Tiff
  • Wmf
  • Svg (>= _kenaflow _ 4.0.22)

The return value in case of -AsDataUrl is a string that contains the MIME type of the image and the image itself as a Base64 encoded string. Here is more information about that: https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs There are also some examples.

Parameters

-AsStream

Specifies the return value type: System.IO.Stream

-AsBase64

Specifies the return value type: a string with the Base64 encoded image

-AsDataUrl

Specifies the return value type: a data URL with the MIME type and the image itself

-AsString

If OutputImageFormat is SVG this parameter can be used to retrieve the SVG vector image as (unencoded) string

-Data <string>

The data that is encoded as barcode

[-BarcodeFormat <format> ("QR_CODE")]

The format of the barcode image. Default is "QR_CODE"

[-Height <int> (100)]

The height of the barcode image. Default is 100 pixels.

[-Width <int> (100)]

The widht of the barcode image. Default is 100 pixels.

[-Margin <int>)

The margin (top, left, right, bottom) of the barcode image. If not specified the default value of the barcode creation tool is used. ( Before kenaflow 4.0.22 it has a default value of 10.)

[-PureBarcode[:$false]]

If set to $true only the barcode is contained in the resulting image. No numbers or characters.

[-GS1Format[:$false]]

A kind of special format for grouping values in the barcode. Please search the internet for more information.

[-ErrorCorrection <error-correction> ($null)]

For "QR_CODE" is specifies the amount of redundancy in the resulting image.

[-BackgroundColor <bg-color> ("White")]

The color of the image background as System.Drawing.Color structure. Default is "System.Drawing.Color.White"

[-ForegroundColor <fg-color> ("Black")]

The color of the barcode pixels as System.Drawing.Color structure. Default is "System.Drawing.Color.Black"

[-OutputImageFormat <output-format> ("png")]

The output image format. Please see the "description" section above for details.

[-ThrowErrors[:$true]]

This is a default parameter for all kenaflow cmdlets. If set to $true (default!) the engine will pass exception within the cmdlet to the script for further handling.

Example

$barcode = Get-KFBarcode -AsBase64 -Data "Hello kenaflow" -ErrorCorrection "M"
Write-KFLog $barcode