How to delete pages from pdf

Hi …i have a requirement like i need to delete some selected pages from pdf.can any one help me

Hi @Narendra_K

Sure, I can help you with that. Here’s an overview of the steps to delete selected pages from a PDF using UiPath:

  1. Install the UiPath.PDF.Activities package from the UiPath Marketplace.
  2. Use the “Read PDF Text” activity to read the page numbers you want to delete from the PDF.
  3. Use the “Delete Pages” activity to delete the selected pages from the PDF.
  4. Use the “Save PDF Document” activity to save the updated PDF.

Here are some more details on each step:

  1. Install the UiPath.PDF.Activities package: To install this package, follow these steps: a. In UiPath Studio, go to the “Manage Packages” option from the “Activities” panel. b. Search for “UiPath.PDF.Activities” and click on the “Install” button. c. Once the package is installed, you can start using the activities in your workflow.
  2. Use the “Read PDF Text” activity: Use the “Read PDF Text” activity to read the page numbers you want to delete from the PDF. You can extract the page numbers using regular expressions or string manipulation. Store the page numbers in a variable.
  3. Use the “Delete Pages” activity: Use the “Delete Pages” activity to delete the selected pages from the PDF. Pass the PDF file path and the page numbers you want to delete as input to this activity.
  4. Use the “Save PDF Document” activity: Use the “Save PDF Document” activity to save the updated PDF. Pass the updated PDF file path as input to this activity.

That’s it! Your UiPath workflow should now be able to delete selected pages from a PDF file.

Hi Nitya thanks for your response.i will use the same.

@Narendra_K

Welcome to the community

You can use extract pdf with page range as below

"2-5,7,10-End"

This will extract pages 2 to 5 ,7 and 10 to end of doc as one file

i.e., it would remove 1,6,8 and 9

Cheers

2 Likes

Delete pages activity not available for me

@Narendra_K

Please try the above mentioned approach…it should do the work for you

Cheers

I need to delete pages from pdf in dynamic format… suppose i hav pdf with 100 pages .bot will check the invoice number where ever maths found it will add the that page to the list.suppose in the first iteration it matches 4 and 99.so i need to extract the pdf using4 and 99 page and then delete 4 and 99 this is first iteration.i need to repeat the same till last page… delete

@Narendra_K

Then use read pdf in a loop and increment the page number field and read each page…check for the key word…if key word present save the page number…to a list of page numbers…

And after the loop use extract pdf and provide input as String.Join(",",listOfPages)

Now all the pages which are identified are extracted as you need

Hope this helps

Cheers

if requirement is like
Read pages which invoice numbers are present and later get pdf pages which are not extracted
Below approach
Firstly get number of pages and then convert the range to array say PdfPageNos by Enumerable.Range(1,TotalPageCount).ToArray
1.Loop through the invoice numbers list
2. get page numbers and extract the data for particular invoice no. then add the page no. to array say DeletePages
3.after loop is completed Now get RemainingPages by using PdfPageNos.Except(DeletePages).ToArray

Finally use extract PDF activity and provide the String.Join(“,”,RemainingPages) as input

Regards

Hi @Nitya1

I gave it a try and it doesn’t look like this activity exists:
image

Could you please share how you arrived at this solution?

1 Like