08-23-2017 02:17 PM
I'm working with a Unity Script that processes documents in a scan queue before they're indexed. Among the args is the document, which is of type UnindexedDocument. I'd like to get at the document content, but the UnindexedDocument class doesn't have the DefaultRenditionOfLatestRevision object property like a Document object does, and every GetPage method of every DataProvider requires a Rendition object.
How do I get a Rendition of the Unindexed Document and/or otherwise retrieve the PageData of the document? I attempted a quick hack of calling the app.Core.GetDocumentByID([Doc Handle]), but it comes back null, so no dice. Thanks!
08-30-2017 02:09 PM
You can do this but it has to have a doctype. I created a doctype with one keyword that I use as the file name (application ID). The user types in the application ID, hits scan, and the document is exported to disk with the application ID as the filename. This could also be done programmatically so the user does not have to enter a keyword and the filename is established within the script.
public void OnFullIndexExecute(Hyland.Unity.Application app, Hyland.Unity.ScanQueuePostScanFullIndexEventArgs args)
{
filename = "Test Doc";
// get current doc
Document document = args.Document;
//find the image rendition of the document
Rendition rendition = args.Document.DefaultRenditionOfLatestRevision;
// init PDF data provider
PDFDataProvider imageProvider = app.Core.Retrieval.PDF;
using (PageData pageData = imageProvider.GetDocument(rendition))
{
// use extension from page data object and create path
string fullPath = @"\\ls2\shortcut\Imaging\Document Conversion Staging Area\" + filename + "." + pageData.Extension;//extension will be PDF
// Create file
using (Stream stream = pageData.Stream)
{
Utility.WriteStreamToFile(stream, fullPath);
}
}
Storage storage = app.Core.Storage;
// remove document from scan queue
storage.PurgeDocument(document);
}
08-24-2017 05:35 AM
08-30-2017 08:48 AM
Jeremy,
There is currently no way to get the PageData of an UnindexedDocument using the Unity API. If this functionality is something that you would like to see added, you can contact your first line of support to create a Software Change Request.
08-30-2017 02:09 PM
You can do this but it has to have a doctype. I created a doctype with one keyword that I use as the file name (application ID). The user types in the application ID, hits scan, and the document is exported to disk with the application ID as the filename. This could also be done programmatically so the user does not have to enter a keyword and the filename is established within the script.
public void OnFullIndexExecute(Hyland.Unity.Application app, Hyland.Unity.ScanQueuePostScanFullIndexEventArgs args)
{
filename = "Test Doc";
// get current doc
Document document = args.Document;
//find the image rendition of the document
Rendition rendition = args.Document.DefaultRenditionOfLatestRevision;
// init PDF data provider
PDFDataProvider imageProvider = app.Core.Retrieval.PDF;
using (PageData pageData = imageProvider.GetDocument(rendition))
{
// use extension from page data object and create path
string fullPath = @"\\ls2\shortcut\Imaging\Document Conversion Staging Area\" + filename + "." + pageData.Extension;//extension will be PDF
// Create file
using (Stream stream = pageData.Stream)
{
Utility.WriteStreamToFile(stream, fullPath);
}
}
Storage storage = app.Core.Storage;
// remove document from scan queue
storage.PurgeDocument(document);
}
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.