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



Last Go to last post Unread Go to first unread post
#1 Posted : Tuesday, June 5, 2018 3:32:52 PM(UTC)
Anthony Northrup

Groups: Registered, Tech Support, Administrators
Posts: 199

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

Combining documents is very straight forward using the LEADTOOLS Documents SDK. Below I've highlighted the key steps necessary for the combining process.

First, create the virtual document using the DocumentFactory.Create(CreateDocumentOptions) method:

// Create the virtual document
CreateDocumentOptions createOptions = new CreateDocumentOptions();
LEADDocument virtualDocument = DocumentFactory.create(createOptions);

Next, for each input document:

  • Load the document using the DocumentFactory.LoadFromFile(LoadDocumentOptions) method
    String inputFile = "Some path";
    LoadDocumentOptions loadOptions = new LoadDocumentOptions();
    LEADDocument tempDocument = DocumentFactory.loadFromFile(inputFile, loadOptions);

  • Append all the pages to the virtual document. You can access the list of pages using the LEADDocument.Pages property
    for (DocumentPage page : tempDocument.getPages())

Create a DocumentConverter for exporting the virtual document

DocumentConverter documentConverter = new DocumentConverter();

If you need to perform OCR on the input documents:

  • Create an OcrEngine using the OcrEngineManager.CreateEngine(OcrEngineType) method (there is only OcrEngineType.LEAD for Java)
    OcrEngine ocrEngine = OcrEngineManager.createEngine(OcrEngineType.LEAD);

  • Startup the OCR engine using the OcrEngine.Startup method (we have a guide for the various parameters here)
    ocrEngine.startup(null, documentConverter.getDocumentWriterInstance(), null, null);

  • Set the OCR engine for the document converter using the DocumentConverter.SetOcrEngineInstance(OcrEngine,bool) method (in my example project I set autoDispose to true, refer to the documentation page for more information)
    documentConverter.setOcrEngineInstance(ocrEngine, true);

Now the the virtual document is created, you'll need to save it:

The RunJob method is synchronous, so once this call is complete you will be able to check the results:

  • The status of the job can be found by accessing the DocumentConverterJob.Status property
    if (job.getStatus() == DocumentConverterJobStatus.SUCCESS)
    	System.out.println("Finished successfully");

  • If there were any errors during the conversion, you can access them via the DocumentConverterJob.Errors property
    for (DocumentConverterJobError error : job.getErrors()) {
    	Exception ex = error.getError();

You can also download a working sample project here:
File Attachment(s):
Project.zip (9kb) downloaded 166 time(s).
Anthony Northrup
Developer Support Engineer
LEAD Technologies, Inc.


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.

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.070 seconds.