How to remove the password of pdf and not lose attachments inside it

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 ?

Hi @Ishan_Shelke

Use PowerShell cmd for this

  1. Install the “PDF Activities” package in UiPath Studio.
  2. Use the “Read PDF Text” activity to read the content of the password-protected PDF.
  3. 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.Save(PDSaveFull, $filePath)
  1. Use the “Write PDF Text” activity to write the updated PDF content to a new PDF file.
  2. 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.


This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.