web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Failed extract PDF pag...
Power Automate
Answered

Failed extract PDF pages into new file

(0) ShareShare
ReportReport
Posted on by 9

I try to extract many PDF file pages into a new PDF file using the "each loop" action.

I want to named every extracted files with the listthat stored in the .txt files.

I got an error :

"Failed to extract new PDF file from 'C:\Users\xx\\xxxx.pdf'

here is the flow:

 

ss.png



  • MichaelAnnis Profile Picture
    5,727 Moderator on at

    Show us the double down on the "Extract PDF file pages to new PDF file" please.

  • jopay Profile Picture
    9 on at


    ss2.png

     

     

     

     

     

     

     

     

     

     

     

     

  • jopay Profile Picture
    9 on at

    I also try this method :

     

    get files in folder and stored in %files%

    read text from file and stored in %fileContents%

    for each %currentitem% in %files%

    extract pdf pages 4-5 from %currentitem% to C:\xxx.pdf  and stored to extractedPDF

    rename xxx.pdf to %fileContent%

    got an error : "Can't rename file"

    Illegal characters in path.: Microsoft.Flow.RPA.Desktop.Robin.SDK.ActionException: Can't rename file ---> System.ArgumentException: Illegal characters in path.

     

    rename box.pngss3.png

  • Verified answer
    MichaelAnnis Profile Picture
    5,727 Moderator on at

    What is "FileContents"?

     

    If it is more than 1 line, that is not going to work.  If it is only 1 line and creates a valid filename, each time you loop you are going to overwrite the previous one.

     

    I think FileContents is a list; if that is the case, instead of "For each" do a loop.

     

    Only assuming %FileContents% is a list in the same order as %Files%:

    After get files to %Files%

    Loop starting at 0 to %Files.Count - 1% increment 1

    Whenever you want to reference the Current File, in replace of %CurrentItem%, use %Files[LoopIndex]%

    Whenever you want to reference the current line of File Contents, use %FileContents[LoopIndex]%

     

    Now it should name them appropriately.

  • jopay Profile Picture
    9 on at

    This is works. Thank you

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Automate

#1
Mohsin Ali Profile Picture

Mohsin Ali 299

#2
11manish Profile Picture

11manish 274 Super User 2026 Season 2

#3
Henil Profile Picture

Henil 119

Last 30 days Overall leaderboard