7. Add a picture to the header and footer - CodeBlueG/PSForms GitHub Wiki

Pictures can be added to the header and/or footer of the form to apply some branding to the application. Personally, I add my company logo to the bottom left of a page and the customer logo to the top right.

Pictures are added in two stages, the first is to create the base-64 encoded image of the file and add this to the form object when it is initialised, and the second part is to apply the image onto the form.

To initialse the image

Add images to the form object using the CustomerLogo and CompanyLogo attributes with the following commands;

  $TestForm.CustomerLogo = $CustomerLogo  
  $TestForm.CompanyLogo = $CompanyLogo  

Where the two variables contain the base-64 encoded images.
Adding the logos to the form object in this way ensures that the form as well as the header and footer sections are correctly sized.

To apply the logos to the form

Adding the images to the form is achieved with the following commands;

$picCompanyLogo = Add-FormPicture -formObject $TestForm-pictureImage $TestForm.CompanyLogo -pictureLocation "Footer"  
$picCustomerLogo = Add-FormPicture -formObject $TestForm-pictureImage $TestForm.CustomerLogo -pictureLocation "Header"  

As it is unlikely that the images will need to be referenced again in the future, the don't strictly need to be made into a variable, however, running the cmdlet without a variable will result in the details of the image being written to the console. This can be avoided by making the command equal to $null as below;

  $null = Add-FormPicture -formObject $TestForm-pictureImage $TestForm.CustomerLogo -pictureLocation "Header"   

Form header