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 |
Vertical position of the QR Code on the PDF file. |
Center |
yes |
|
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 'C:\Vault\Inventor\Drawings\Pad Lock.idw.pdf' -Text 'doc.coolorange.com' -Size 1 -VerticalAlignment Center -HorizontalAlignment Center
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!" } |