Hello everyone,
I am using “Power Shell” in order to fill the fields in an editable PDF. The script works properly (it can be found on this forum) but when I try to pass as variables the paths, an error is shown:
[System.Reflection.Assembly]::LoadFrom($path1) | Out-Null
$PDFDoc = New-Object iTextSharp.text.pdf.PdfReader -ArgumentList $path2
$PDFDoc_ = New-Object iTextSharp.text.pdf.PdfStamper($PDFDoc,[System.IO.File]::Create($path3))
I really do not know why…
Any ideas? Thanks a bunch!
Pablito
(Pawel Wozniak)
July 15, 2019, 8:41am
3
Hi @EngAnalyst ,
Please have a look here
Maybe it will help you:
How to Integrate PowerShell with UiPath
This topic is a step by step guide for integrating Powershell with Uipath. There is an ‘Invoke Powershell Activity’ available in Uipath which can be used to run the powershell scripts.
For our example purpose, let us consider a simple powershell script which gives us the status of windows services on the machine. This script will have two input parameters:
• ServiceState (String) – To get the status of service. For e.g. ‘Running’ , ‘Stopped’ etc
• Outp…
Thank you very much @Pablito
I already read such a thread but I am not able to sort it out… The sentence that seems to be mistaken is the second one:
$PDFDoc = New-Object iTextSharp.text.pdf.PdfReader -ArgumentList $path2
But I do not know why… I am really confused.
Thanks a lot again.
Pablito
(Pawel Wozniak)
July 15, 2019, 9:05am
5
I think $path2 needs to be declared before you can use it as a parameter.
All the parameters (also path1, path3…)?
Btw happy birthday @Pablito !
Pablito
(Pawel Wozniak)
July 15, 2019, 9:13am
7
Thanks
Yes. Normally all used variables needs to be declared prior to use them in code. The only exception is when you are using variables like this:
$variable = Get-Something -Parameter | Sort-Object blablabla
In this case you can use variable even inside the whole code as you are assigning parameters to it in the same moment where you are declaring it.
Thanks Pablito.
Finally I sorted it out. Have a nice day.