groupdocs-free-consulting / projects

0 stars 0 forks source link

I want to merge multiple word documents #24

Closed saleem005 closed 1 year ago

saleem005 commented 2 years ago

Hi, I want to merge multiple word documents into a single file. I am using the following code and this is showing the error. Error is also given below while I am passing correct path. Error: Can't find file located at 'public/WordProcessing/HS003b - Basic Health and Safety Rules Induction (1).docx'

Code: $documentApi = CommonUtils::GetDocumentApiInstance();

    $fileInfo1 = new FileInfo();
    $fileInfo1->setFilePath('public/WordProcessing/HS003b - Basic Health and Safety Rules Induction (1).docx');
    $item1 = new JoinItem();
    $item1->setFileInfo($fileInfo1);
    $fileInfo2 = new FileInfo();
    $fileInfo2->setFilePath('public/WordProcessing/HS003b - Basic Health and Safety Rules Induction (1).docx');
    $item2 = new JoinItem();
    $item2->setFileInfo($fileInfo2);

    $options = new JoinOptions();
    $options->setJoinItems([$item1, $item2]);
    $options->setOutputPath("Output/joined.docx");

    $request = new joinRequest($options);
    $response = $documentApi->join($request);

    echo "Output file path: " . $response->getPath();
    echo "\n";
AlexNosk commented 2 years ago

@saleem005 The mentioned error means that Aspose.Words cannot find the file. Please make sure the file is available and it's file name is specified correctly. Also, please try specifying absolute file path.