Welcome Guest! To enable all features, please Login or Register.

Notification

Icon
Error

Options
View
Last Go to last post Unread Go to first unread post
#1 Posted : Thursday, August 23, 2018 12:14:48 PM(UTC)
Rob Cline

Groups: Registered
Posts: 52

Thanks: 14 times

The documentation says that a user can provide their own documentID to a Leadtools Document instance. If the user does not provide one then the class will create one from a guid.
However there is no setter defined for the Document class documentId property.
What is the syntax then to set this value.
 

Try the latest version of LEADTOOLS for free for 60 days by downloading the evaluation: https://www.leadtools.com/downloads

Wanna join the discussion? Login to your LEADTOOLS Support accountor Register a new forum account.

#2 Posted : Thursday, August 23, 2018 12:53:05 PM(UTC)

Hadi  
Hadi

Groups: Manager, Tech Support, Administrators
Posts: 218

Was thanked: 12 time(s) in 12 post(s)

You set the DocumentID in the UploadFile call from the DocumentFactory:

https://www.leadtools.co...tfactory-uploadfile.html
JavaScript Syntax
Code:
uploadFile = function( 
   file, 
   documentId 
) 

Parameters
file: The JavaScript File object representing the file to upload.
documentId Optional: The ID to be used with the loaded document.

Quote:
When the value of documentId is null (the default), then the document factory will create a new unique ID using a GUID generator. If the value is not null, then it is assumed to be a user-defined ID and used as is. In either case, the value is set in the LEADDocument.DocumentId property of the newly created document.

Example:
Code:
   lt.Document.DocumentFactory.uploadFile(file, guid) 
      .done(function (uri) { 
 
         // Done, now load it 
         log("Finished uploading. Now loading..."); 
         var loadDocumentOptions = new lt.Document.LoadDocumentOptions(); 
         // Set the name 
         loadDocumentOptions.name = file.name; 
         lt.Document.DocumentFactory.loadFromUri(uri, loadDocumentOptions) 
            .done(function (doc) { 
 
               log("Document was loaded succesfully"); 
               log("Name is " + doc.name); 
               log("MIMEType is " + doc.mimeType); 
               log("Number of Pages is " + doc.pages.count); 
            }) 
            .fail(showServiceError); 
      }) 
      .fail(showServiceError);
Hadi Chami
Developer Support Manager
LEAD Technologies, Inc.

LEAD Logo
thanks 1 user thanked Hadi for this useful post.
Rob Cline on 8/27/2018(UTC)
 
#3 Posted : Thursday, August 23, 2018 1:35:53 PM(UTC)
Rob Cline

Groups: Registered
Posts: 52

Thanks: 14 times

Thank you for your prompt reply.

You didn't really answer the question I asked in a generic sense, but it did help me to get to the right answer in the documentation.
For instance, how do you set this value for a virtual document that you aren't loading from a file is not answered by your reply.

I believe the correct answer is:
You set the documentID for a new Document by setting the CreateDocumentOptions' DocumentId property to the User value desired prior to creating the new Document.
i.e. CreateDocumentOptions can be set, but Document.documentId is immutable once the Document is instantiated.

In my case, I am using c# in a winform app and creating documents from images loaded by a scanner into a virtual Document.
I am not loading the document from a file and the unique id I need to use is contained in a barcode on the first page scanned in for the document.
Therefore, I do not know the user id I want to use until after I read the barcode on the first page.
By this point the virtual Document will already have assigned a guid as the documentId.

Is my only option in this situation to clone the initial virtual Document to a new Document with a new documentID
 
#4 Posted : Friday, August 24, 2018 2:29:21 PM(UTC)
Anthony Northrup

Groups: Registered, Tech Support, Administrators
Posts: 199

Was thanked: 28 time(s) in 28 post(s)

Hello Rob,

From what you've just said, it sounds like you scan in a document, and create your own LEADDocument from the pages. You can simply use our BarcodeReader before creating the LEADDocument in order to detect/read the ID from the page:
https://www.leadtools.com/help/leadtools/v20/dh/ba/barcodereader.html

How are you scanning the document? If you're using our Twain or WIA SDK you can get the pages as a RasterImage, which the BarcodeReader supports reading directly:


Thanks,
Anthony Northrup
Developer Support Engineer
LEAD Technologies, Inc.

LEAD Logo
 
#5 Posted : Friday, August 24, 2018 4:13:50 PM(UTC)
Rob Cline

Groups: Registered
Posts: 52

Thanks: 14 times

Thanks for the reply.
Are my assumptions below correct?

I do use the Leadtools Twain.dll to perform the scanning.

Under Leadtools 17 I would:
1. Scan the first page into a raster image; read the barcode; get meta data about the document from the database.
2. Add the page to the Page Viewer (i.e. RasterImageList).
3. Save the scanned raster image to a local disk drive as a tif document using a unique sequence number and page from the barcode and current page number.
4. I would keep adding scanned pages images to the PageViewer control until all pages of the current document were read in and saved as in individual files.
5. In the mean time, I had a ton of convoluted code to keep the PageView and Image View (i.e. RasterImageViewer) in sync.
6. Finally, I would combine all individual page raster images into a multi-page raster image that was saved as a multi-page tif file.

It sounds like you are saying with the documentViewer Class I basically can do the same thing, but it is greatly simplified.
However, I need to:
1. Scan the first page into a raster image; read the barcode; get the meta data from the data base.
2. At this point, I can set the documentID and instantiate a new Document.
3. I can then add the first page raster image to the new Document.
4. I can scan and add the rest of the pages to the new Document using the new command system.
5. The command system will automatically keep the ThumbnailContainer and the ViewContainer in sync.
6. It will also keep a memory/cache based version of the Document without my having to maintain these separately.

 
#6 Posted : Monday, August 27, 2018 10:19:11 AM(UTC)
Anthony Northrup

Groups: Registered, Tech Support, Administrators
Posts: 199

Was thanked: 28 time(s) in 28 post(s)

Hello,

Sorry for not getting back to you on Friday. And yes, everything you said in the second list looks good. You'll want to create the new pages using the DocumentPages.CreatePage method, followed up by the DocumentPage.SetImage method.

As for the cache, you'll need to specify the CreateDocumentOptions.Cache property when creating the Document. Then at a later point, such as once all the pages have been added, you can call LEADDocument.SaveToCache for the cache to be updated.

If you have any issues implementing this, please let me know.

Thanks,
Anthony Northrup
Developer Support Engineer
LEAD Technologies, Inc.

LEAD Logo
thanks 1 user thanked Anthony Northrup for this useful post.
Rob Cline on 8/27/2018(UTC)
 
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Powered by YAF.NET | YAF.NET © 2003-2024, Yet Another Forum.NET
This page was generated in 0.101 seconds.