Now you have successfully managed to split a PDF into individual PDF pages, without hardcoding the number of pages in the PDF! Automate splitting and merging PDF files in Microsoft Power Automate for Desktop The exception handling has been configured in such a way that when an error is occurred, the flow will jump to the “OutOfBoundsError” label, hence exiting the loop. Hence when the loop index reaches the value of 6, which is when it tries to extract page 6 of the PDF file, it will encounter an error as page 6 does not exist. What this does is: Initially we have increased the end loop index to 100, although our PDF file contains only 5 pages. Under “On error”, choose the option “Continue flow run”, and “Go to label”. Drag and drop the label to the end of the loop on your workspace.Ĭlick on your “Extract PDF file pages into new PDF file” action, and the “On error” option. ![]() We will need to create a label, using the “label” action under “Flow control”. We would need to change the “End to” in the Loop dialogue box to an arbitrary large number. How to split PDF files when number of pages is unknown There would be a few change and additional steps to the flow in the scenario where we aren’t aware of how many pages the PDF file contains. However, it is important to note that we coded the loop to increase from 1 to 5 because we knew beforehand that the total pdf files file contains 5 pages. ![]() Running this flow, will cause the LoopIndex to increment from 1 to 5, and each page has been successfully extracted into five individual PDF files! This continues so on and so forth until five iterations of the loop have been completed. For the second iteration, the loop index becomes the value of 2 and for this iteration will not extract the first page but will extract the second page and save the second page into a new file called “.pdf”. Page %LoopIndex%.pdf, where LoopIndex is 1). The starting loop index is 1 and for the first loop we will extract the first page of the pdf file into a new pdf file called “.pdf” (i.e. What this does is loop through the pdf file five times. Likewise, do the same for the extracted pdf file path instead of hard coding the value to be “”, we shall use the dynamic value “LoopIndex” instead. Remove the “Page selection” value which was hardcoded earlier, click on the and choose “LoopIndex” from the dropdown menu. Then, drag your PDF action into the body of your loop. ![]() Since we know there are 5 individual pages, we will set the “Start from” as 1, the “End to” as 5, and the “Increment by” as 1. Step 2: Implement a loop to repeat for other pagesįirstly, drag the “Loop” action into the workspace. Lastly, select “Overwrite” from the “If file exists” dropdown menu.Īfter running the flow and navigating to our folder, we can see that we have successfully extracted the first page into a separate pdf file called page1.pdf Remember to always add the file extension. For extracted PDF file path, extract the page into a separate PDF file and in this case we have renamed it as “.pdf”. Under the “PDF file” parameter, specify the PDF file you wish to extract the pages from, and set the “Page selection” as the page you want to extract. To explain splitting PDF files, we will be using a single PDF titled “Sample PDF File”, containing five individual pages.įirstly, we will be using the “Extract PDF files pages to new PDF file” action. How to split PDF files in Microsoft Power Automate for Desktop Navigating back to your folder, will show that a merged file containing all five individual PDFs has been successfully created! Next, just to be safe, select the “Overwrite” option for “If file exists”. The input parameter in this case would be the “Files” variableįor the “Merged PDF path”, navigate to your desired folder – in our case here, it is the “Merge PDF” folder, and rename the file as “Merged PDF.pdf”. Next, we will drag and drop the “Merge PDF Files” action, which can be found under PDF actions, into the main workspace. This action will retrieve all the files in this folder and store it inside a variable called Files which is essentially a list of file objects. Under the “Folder” parameter, choose the right folder from the dropdown menu – in our case, it is the “merge PDF” folder. How to merge PDF files in Microsoft Power Automate for Desktopįor the merging files portion of the article, we will be using a folder which contains five individual PDF files as an example.įirstly, we need to use the action “Get files in folders”. ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |