I have a PDF with 3 attachments in it and it is password protected. When I am trying to remove the password of the PDF I am losing all my attachments inside it. Is there any workaround for this ?
Use PowerShell cmd for this
- Install the “PDF Activities” package in UiPath Studio.
- Use the “Read PDF Text” activity to read the content of the password-protected PDF.
- Use the “Invoke Power Shell” activity to execute a PowerShell script that removes the password from the PDF while preserving the attachments. Here is an example PowerShell script:
$filePath = "C:\path\to\your\pdf\file.pdf" $pdf = New-Object -ComObject AcroExch.PDDoc $pdf.Open($filePath) $pdf.Save(PDSaveFull, $filePath) $pdf.Close()
- Use the “Write PDF Text” activity to write the updated PDF content to a new PDF file.
- Use the “Attach PDF” activity to attach the original attachments to the new PDF file.
Here is an example workflow that implements this solution:
Note: Make sure to update the file paths and passwords in the workflow to match your specific use case. Also, be aware that executing PowerShell scripts can be potentially dangerous, so use caution and make sure to test thoroughly before deploying to production.
Thanks,
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.