This REST API allows add attachments into pdf documents. Attachments should be uploaded into cloud storage before importing.
The table below contains the full list of properties that can be specified.
Name
Description
Comment
FilePath
The file path in the storage
Required property
StorageName
Storage name
Could be omitted for default storage
VersionId
File version Id
Useful for storages that support file versioning
Password
The password to open file
Should be specified only for password-protected documents
Attachments
Collection of attachments files paths
OutputPath
Path to resultant document
Required
Resource URI
HTTP POST ~/import
Swagger UI lets you call this REST API directly from the browser.
cURL example
* First get JSON Web Token
* Please get your Client Id and Client Secret from https://dashboard.groupdocs.cloud/applications. Kindly place Client Id in "client_id" and Client Secret in "client_secret" argument.
curl -v "https://api.groupdocs.cloud/connect/token"\
-X POST \
-d "grant_type=client_credentials&client_id=xxxx&client_secret=xxxx"\
-H "Content-Type: application/x-www-form-urlencoded"\
-H "Accept: application/json"* cURL example to join pages from several documents into one document
curl -v "https://api.groupdocs.cloud/v1.0/merger/import"\
-X POST \
-H "Content-Type: application/json"\
-H "Accept: application/json"\
-H "Authorization: Bearer
<jwt token>"-d "{
'FileInfo':
{
'FilePath': 'Pdf/one-page-password.pdf',
'Password': 'password'
},
'Attachments': [ "Txt/document.txt" ],
'OutputPath': 'Output/with-attachment.pdf'
}"
Using an SDK (API client) is the quickest way for a developer to speed up the development. An SDK takes care of a lot of low-level details of makingRequests and handlingResponses and lets you focus on writing code specific to your particular project. Check out our GitHub repository for a complete list of GroupDocs.Merger Cloud SDKs along with working examples, to get you started in no time. Please check the article to learn how to add an SDK to your project.
// For complete examples and data files, please go to https://github.com/groupdocs-merger-cloud/groupdocs-merger-cloud-dotnet-samplesstringMyClientSecret="";// Get ClientId and ClientSecret from https://dashboard.groupdocs.cloudstringMyClientId="";// Get ClientId and ClientSecret from https://dashboard.groupdocs.cloudvarconfiguration=newConfiguration(MyClientId,MyClientSecret);varapiInstance=newDocumentApi(configuration);try{varoptions=newImportOptions{FileInfo=newFileInfo{FilePath="Pdf/one-page-password.pdf",Password="password"},Attachments=newList<string>{"Txt/document.txt"},OutputPath="Output/with-attachment.pdf"};varrequest=newImportRequest(options);varresponse=apiInstance.Import(request);Console.WriteLine("Output file path: "+response.Path);}catch(Exceptione){Console.WriteLine("Exception while calling api: "+e.Message);}
// For complete examples and data files, please go to https://github.com/groupdocs-merger-cloud/groupdocs-merger-cloud-java-samples
StringMyClientSecret="";// Get ClientId and ClientSecret from https://dashboard.groupdocs.cloud
StringMyClientId="";// Get ClientId and ClientSecret from https://dashboard.groupdocs.cloud
Configurationconfiguration=newConfiguration(MyClientId,MyClientSecret);DocumentApiapiInstance=newDocumentApi(configuration);try{ImportOptionsoptions=newImportOptions();FileInfofileInfo=newFileInfo();fileInfo.setFilePath("Pdf/one-page-password.pdf");fileInfo.setPassword("password");options.setFileInfo(fileInfo);options.addAttachmentsItem("Txt/document.txt");options.setOutputPath("output/with-attachment.pdf");CallImportRequestrequest=newCallImportRequest(options);DocumentResultresponse=apiInstance.callImport(request);System.err.println("Output file path: "+response.getPath());}catch(ApiExceptione){System.err.println("Exception while calling api:");e.printStackTrace();}
// For complete examples and data files, please go to https://github.com/groupdocs-merger-cloud/groupdocs-merger-cloud-php-samples
useGroupDocs\Merger\Model;useGroupDocs\Merger\Model\Requests;$ClientId="";// Get ClientId and ClientSecret from https://dashboard.groupdocs.cloud
$ClientSecret="";// Get ClientId and ClientSecret from https://dashboard.groupdocs.cloud
$configuration=newGroupDocs\Merger\Configuration();$configuration->setAppSid($ClientId);$configuration->setAppKey($ClientSecret);$documentApi=newGroupDocs\Merger\DocumentApi($configuration);$fileInfo=newModel\FileInfo();$fileInfo->setFilePath("Pdf/one-page-password.pdf");$fileInfo->setPassword("password");$options=newModel\ImportOptions();$options->setFileInfo($fileInfo);$options->setAttachments(["Txt/document.txt"]);$options->setOutputPath("Output/with-attachment.pdf");$request=newRequests\importRequest($options);$response=$documentApi->import($request);echo"Output file path: ".$response->getPath();echo"\n";
// For complete examples and data files, please go to https://github.com/groupdocs-merger-cloud/groupdocs-merger-cloud-node-samples
global.merger_cloud=require("groupdocs-merger-cloud");global.clientId="XXXX-XXXX-XXXX-XXXX";// Get ClientId and ClientSecret from https://dashboard.groupdocs.cloud
global.clientSecret="XXXXXXXXXXXXXXXX";// Get ClientId and ClientSecret from https://dashboard.groupdocs.cloud
global.documentApi=merger_cloud.DocumentApi.fromKeys(clientId,clientSecret);letoptions=newmerger_cloud.ImportOptions();options.fileInfo=newmerger_cloud.FileInfo();options.fileInfo.filePath="Pdf/one-page-password.pdf";options.fileInfo.password="password";options.attachments=["Txt/document.txt"];options.outputPath="Output/with-attachment.pdf";letresult=awaitdocumentApi._import(newmerger_cloud.ImportRequest(options));console.log("Output file path: "+result.path);
# For complete examples and data files, please go to https://github.com/groupdocs-merger_cloud-cloud/groupdocs-merger_cloud-cloud-python-samplesfromgroupdocs_merger_cloudimport*importgroupdocs_merger_cloudclient_id="XXXX-XXXX-XXXX-XXXX"# Get ClientId and ClientSecret from https://dashboard.groupdocs.cloudclient_secret="XXXXXXXXXXXXXXXX"# Get ClientId and ClientSecret from https://dashboard.groupdocs.clouddocumentApi=groupdocs_merger_cloud.DocumentApi.from_keys(client_id,client_secret)options=groupdocs_merger_cloud.ImportOptions()options.file_info=groupdocs_merger_cloud.FileInfo("Pdf/one-page-password.pdf",None,None,"password")options.attachments=["Txt/document.txt"]options.output_path="Output/with-attachment.pdf"result=documentApi.call_import(groupdocs_merger_cloud.CallImportRequest(options))print("Output file path = "+result.path)
# For complete examples and data files, please go to https://github.com/groupdocs-merger-cloud/groupdocs-merger-cloud-ruby-samplesrequire'groupdocs_merger_cloud'$client_id="XXXX-XXXX-XXXX-XXXX"# Get ClientId and ClientSecret from https://dashboard.groupdocs.cloud$client_secret="XXXXXXXXXXXXXXXX"# Get ClientId and ClientSecret from https://dashboard.groupdocs.clouddocumentApi=GroupDocsMergerCloud::DocumentApi.from_keys($client_id,$client_secret)options=GroupDocsMergerCloud::ImportOptions.newoptions.file_info=GroupDocsMergerCloud::FileInfo.newoptions.file_info.file_path='Pdf/one-page-password.pdf'options.file_info.password='password'options.attachments=["Txt/document.txt"]options.output_path="Output/with-attachment.pdf"result=documentApi.import(GroupDocsMergerCloud::ImportRequest.new(options))puts("Output file path: "+result.path)
Was this page helpful?
Any additional feedback you'd like to share with us?
Please tell us how we can improve this page.
Thank you for your feedback!
We value your opinion. Your feedback will help us improve our documentation.