Add-PdfQRCode

Adds a QR Code to a PDF file.

Syntax

1
Add-PdfQRCode -Path <string> -Text <string> [-Size <int>] [-VerticalAlignment <VerticalAlignment>] [-HorizontalAlignment <HorizontalAlignment>] [<CommonParameters>]

Parameters

Type

Name

Description

Default value

Optional

String

Path

Path to the PDF file to which the QR Code will be added.

no

String

Text

Text with the data that needs to be added to the QR Code.

no

Integer

Size

Size of the QR Code.

2

yes

VerticalAlignment

VerticalAlignment

Vertical position of the QR Code on the PDF file.

Center

yes

HorizontalAlignment

HorizontalAlignment

Horizontal position of the QR Code on the PDF file.

Center

yes

Return type

Bool ← on success the cmdlet returns $true otherwise $false. On failure the Exception/ErrorMessage can be accessed using $Error.

Remarks

For PDF files with multiple pages, the QR Code is only applied to the first page.
The -Size parameter is unitless, it controls the relative size of the QR Code as the exact size varies depending on the amount of data it holds. Larger values will result in a larger QR Code.
Vertical and horizontal alignment have a default offset of 3% of the page size from the border if not placed in the center.

Examples

Adding a QR Code to the center of the PDF

Add-PdfQRCode -Path '$/Designs/Test.pdf' -Text 'doc.coolorange.com' -Size 1 -VerticalAlignment Center -HorizontalAlignment Center

Error handling, analyze why QR Code could not be added using $Error:

1
2
3
4
5
$result = Add-PdfQRCode -Path '$/Not/Existing/File.pdf' -Text 'doc.coolorange.com'

if(-not $result){
    $Error[0].Exception #Returns: "File '$/Not/Existing/File.pdf' not found!"
}