Problem/Error with Merge PDF Files Activity

I have created a flow which gets a list of files to be merged, and in a loop, creates merged document.
First Loop, File 1 is the merge of files A + B + C + D
Second loop, File 2 becomes, File 1 + E + F + G + D

In the second loop i am getting error:
Message: None of the objects in the chain is an indirect object\r\nSource: UiPath.IntelligentOCR.StudioWeb.Activities\r\nStackTrace: at UiPath.IntelligentOCR.StudioWeb.Activities.PDF.MergePDFs.MergePDFs.ExecuteAsync(AsyncCodeActivityContext context, CancellationToken cancellationToken)\r\n at UiPath.Shared.Activities.AsyncTaskCodeActivityImplementation.EndExecute(AsyncCodeActivityContext context, IAsyncResult result)\r\n at UiPath.IntelligentOCR.StudioWeb.Activities.PDF.PDFActivityBase.EndExecute(AsyncCodeActivityContext context, IAsyncResult result)\r\n at System.Activities.AsyncCodeActivity.CompleteAsyncCodeActivityData.CompleteAsyncCodeActivityWorkItem.Execute(ActivityExecutor executor, BookmarkManager bookmarkManager)

I have tried using both Merge PDFs and Join PDF documents activities, with similar results.
Problem seems to appear when adding file D twice in the same “merged” document.
I have also tried to first copy file D to a different location (and name), yet again with the same results.

Has anyone come across similar issues? Any ideas?
Is there a way to overcome this behavior?
NOTE: Skipping adding File D twice is not an actual option.

Hey @spantaris,

The error may occurs because the same PDF (File D) is referenced twice in the merge chain, which UiPath’s PDF activities can’t handle. Even copying the file doesn’t help as the internal object references remain identical. A workaround is to first open and re-save File D as a new PDF (flattening it), then include that copy in the merge to avoid the duplicate reference issue.

Hi @spantaris

I think you should create a new copy of File D by extracting its pages (using extract pDF page range), then merge using this copy instead of the original. This avoids duplicate object errors when adding File D multiple times.

Happy Automation

Thank you both @prashant1603765 and @Mir.Jasimuddin
I managed to overcome the unwanted behavior by “recreating” the duplicate PDF file.
As by using Read PDF Page Rage (one by one) and re-merging pages into a new file did not work, solution applied includes splitting pdf pages into images, and then using word to create a new pdf document…
Sounds weird - and probably should not be necessary - but it worked.
I also noticed that this behavior happens after the last couple of corresponding packages version.

1 Like

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