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>]
1
Add-PdfQRCode -Path <string> -Text <string> [-Size <int>] [-OffsetX <int>] [-OffsetY <int>] [<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

Integer

OffsetX

Horizontal offset in points of the QR Code from the left border of the PDF file.

0

yes

Integer

OffsetY

Vertical offset in points of the QR Code from the top border of the PDF file.

0

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.
-OffsetX and -OffsetY position the top-left corner of the QR Code relative to the top-left corner of the page, in points (1/72 inch).

The Offset and Alignment arguments are mutually exclusive and cannot be used together.

Examples

Adding a QR Code to the center of the PDF:

Add-PdfQRCode -Path 'C:\Vault\Inventor\Drawings\Pad Lock.idw.pdf' -Text 'doc.coolorange.com' -Size 1 -VerticalAlignment Center -HorizontalAlignment Center

Adding a QR Code at an exact position, e.g. into a field of the drawing’s title block:

Add-PdfQRCode -Path 'C:\Vault\Inventor\Drawings\Pad Lock.idw.pdf' -Text 'doc.coolorange.com' -Size 1 -OffsetX 720 -OffsetY 480

Using the QR Code cmdlet inside the Sample.CreatePDF job:

# Depending on the information that needs to be stored in the QR Code, one of the following lines can be added after the Export-Document call in the Sample.CreatePDF job

# Adds a QR Code with the thin client hyperlink
Add-PdfQRCode -Path $localPDFfileLocation -Text $file.ThinClientHyperLink -Size 1 -VerticalAlignment Bottom -HorizontalAlignment Left

# Adds a QR Code with the filename
Add-PdfQRCode -Path $localPDFfileLocation -Text $file._Name -Size 1 -VerticalAlignment Bottom -HorizontalAlignment Left

# Adds a QR Code with the part number of the file
Add-PdfQRCode -Path $localPDFfileLocation -Text $file._PartNumber -Size 1 -VerticalAlignment Bottom -HorizontalAlignment Left

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

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

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