cancel
Showing results for 
Search instead for 
Did you mean: 

Document Merge

Debra_Christens
Champ in-the-making
Champ in-the-making
I am looking to find a way to merge documents with matching keywords together into a single document. Is there a way to do that using the scripting in a workflow? I looked at the Hyland SDK documentation and couldn’t find anything, but thought I might be searching on the wrong terms. If not through a workflow script, do you have any other suggestions on how this could be accomplished? I am guessing it would require use of the SDK, since I am not aware of a built in function for this anywhere.
10 REPLIES 10

Not applicable

Hi Rob,

Does Document.Imaging.AddPage() work with PDF?

Thanks,

KOBPONG

Chiu_Ki_Sit1
Champ on-the-rise
Champ on-the-rise

No. You have to use 3rd party library to merge those pdf files.

Farhan_Yahu
Champ on-the-rise
Champ on-the-rise

Hi Debbie,

Hope you have managed to complete the script to merge document with matching keyword. I am trying to achieve the same functionality, can you please help me with the script

Vivek_Kumar
Confirmed Champ
Confirmed Champ

Hi Debbie,

Sorry for the late reply. I think this part of code will be helpful for you.

[embed:dc8ab71f-3b98-42d9-b0f6-e21e02a0f8e2:60395be3-8474-4102-8283-af31aa564ddf:type=csharp&text=Storage%20storage%20%3D%20application.Core.Storage%3B%0D%0ADocument%20doc%20%3D%20args.Document%3B%0D%0A%0D%0AKeywordType%20keytype%20%3D%20application.Core.KeywordTypes.Find%28%22Matching_Keyword%22%29%3B%20%2F%2FEnter%20Keyword%20name%2C%20you%20want%20to%20find%20matching%20documents%0D%0AKeywordRecord%20keyrec%20%3D%20doc.KeywordRecords.Find%28keytype%29%3B%0D%0AKeyword%20keyword%20%3D%20keyrec.Keywords.Find%28%22Matching_Keyword%22%29%3B%20%20%2F%2FEnter%20Keyword%20name%2C%20you%20want%20to%20find%20matching%20documents%0D%0A%0D%0ADocumentQuery%20docquery%20%3D%20application.Core.CreateDocumentQuery%28%29%3B%0D%0Adocquery.AddKeyword%28keyword%29%3B%0D%0ADocumentList%20doclist%20%3D%20docquery.Execute%2825%29%3B%20%2F%2FEnter%20here%20limit%20for%20max%20document%20in%20the%20list%0D%0A%0D%0ADocumentType%20newdocumenttype%20%3D%20application.Core.DocumentTypes.Find%28%22DocumentType%22%29%3B%20%2F%2FEnter%20your%20new%20merged%20doc%20type%0D%0AFileType%20fileType%20%3D%20application.Core.FileTypes.Find%28%22Image%20File%20Format%22%29%3B%0D%0AStoreNewDocumentProperties%20storeDocumentProperties%20%3D%20storage.CreateStoreNewDocumentProperties%28newdocumenttype%2C%20fileType%29%3B%0D%0AstoreDocumentProperties.AddKeyword%28keyword%29%3B%0D%0ADocument%20merged_doc%3B%0D%0A%0D%0Ausing%20%28PageData%20pd%20%3D%20application.Core.Retrieval.Default.GetDocument%28doc.DefaultRenditionOfLatestRevision%29%29%0D%0A%7B%0D%0A%20%20%20%20merged_doc%20%3D%20application.Core.Storage.StoreNewDocument%28pd%2CstoreDocumentProperties%29%3B%0D%0A%7D%0D%0A%0D%0AImaging%20imaging%20%3D%20merged_doc.Imaging%3B%0D%0A%0D%0Aforeach%28Document%20document%20in%20doclist%29%0D%0A%7B%0D%0A%09if%28document.ID%20%3D%3D%20doc.ID%29%0D%0A%09%7B%7D%0D%0A%09%0D%0A%09else%0D%0A%09%7B%0D%0A%09%09using%20%28PageData%20pd1%20%3D%20application.Core.Retrieval.Default.GetDocument%28document.DefaultRenditionOfLatestRevision%29%29%0D%0A%20%20%20%20%20%20%20%20%7B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20imaging.AddPage%28pd1%2C2%29%3B%0D%0A%20%20%20%20%20%20%20%20%7D%0D%0A%09%7D%0D%0A%7D]

Reply if you need any help.

Thanks and Regards,

Vivek Kumar

Storage storage = application.Core.Storage;
Document doc = args.Document;
KeywordType keytype = application.Core.KeywordTypes.Find("Matching_Keyword");

//Enter Keyword name, you want to find matching documents
KeywordRecord keyrec = doc.KeywordRecords.Find(keytype);
Keyword keyword = keyrec.Keywords.Find("Matching_Keyword");

//Enter Keyword name, you want to find matching documents
DocumentQuery docquery = application.Core.CreateDocumentQuery();
docquery.AddKeyword(keyword);

//Enter here limit for max document in the list
DocumentList doclist = docquery.Execute(25);


DocumentType newdocumenttype = application.Core.DocumentTypes.Find("DocumentType");

//Enter your new merged doc type
FileType fileType = application.Core.FileTypes.Find("Image File Format");
StoreNewDocumentProperties storeDocumentProperties = storage.CreateStoreNewDocumentProperties(newdocumenttype, fileType);
storeDocumentProperties.AddKeyword(keyword);

Document merged_doc;
using (PageData pd = application.Core.Retrieval.Default.GetDocument(doc.DefaultRenditionOfLatestRevision))
{
merged_doc = application.Core.Storage.StoreNewDocument(pd,storeDocumentProperties);
}

Imaging imaging = merged_doc.Imaging;
foreach(Document document in doclist)
{
if(document.ID == doc.ID)
{

}
else
{
using (PageData pd1 = application.Core.Retrieval.Default.GetDocument(document.DefaultRenditionOfLatestRevision))
{
imaging.AddPage(pd1,2);
}
}
}

Getting started

Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.