How do we unblock a pdf file programatically.
Hi @Divya_Salve
In UiPath, you can unblock a PDF file programmatically using a custom activity or by executing PowerShell commands through the Invoke PowerShell activity. The unblocking process involves removing the “Blocked” property that might be added to the file when it is downloaded from the internet or copied from another source. Here’s a step-by-step guide on how to do it using the Invoke PowerShell activity:
Step 1: Add the Invoke PowerShell activity
Drag and drop the “Invoke PowerShell” activity into your UiPath workflow.
Step 2: Write the PowerShell script
In the Properties panel of the Invoke PowerShell activity, enter the following PowerShell script:
Unblock-File -Path "C:\Path\to\your\file.pdf"
Step 3: Run the workflow
Run your UiPath workflow, and it will execute the PowerShell script, unblocking the specified PDF file.
Check the below Image for your reference.
Hope it helps!!
Hi @Divya_Salve
Unlocking a password-protected PDF file using UiPath involves using an external PDF library or tool that can handle encryption and decryption. One popular approach is to use the “PDF activities” package provided by UiPath, which utilizes iTextSharp, a popular PDF library for .NET.
Here’s a step-by-step guide to unlock a password-protected PDF file using UiPath:
-
Install the “PDF activities” package:
- In UiPath Studio, go to the “Manage Packages” window (Activities panel > Package Manager).
- Search for “PDF activities” and click the “Install” button to add the package to your project.
-
Load the PDF and unlock it:
- Use the “Read PDF Text” activity to read the content of the PDF file. This activity requires the password to unlock the PDF.
- If the PDF is password-protected, the activity will prompt you to provide the password.
-
Perform your desired operations:
- Once the PDF is unlocked, you can perform any necessary operations on it, such as reading its contents, extracting data, or updating it.
Here’s an example workflow to unlock a password-protected PDF file:
Sequence
Read PDF Text (Input: "path/to/protected_pdf.pdf", Password: "password123")
(Perform other operations on the unlocked PDF as needed)
Replace "path/to/protected_pdf.pdf"
with the actual file path of the password-protected PDF you want to unlock, and "password123"
with the correct password for the PDF.
Hope it works!!
Hi @Divya_Salve ,
Check this below powershell command and a reference screenshot to unblock file,
filePath = "Your_FullFilePath"
Powershell Command:- "Unblock-File -Path "+filePath
Hope this may help you