Community

how to process the pdf document having multiple document into seperate text files using ExportPage

Getting the below error while run java program

Assertion failed: refObject != 0, in file .\Tools/JniTools.cpp, 184

here below is java code

private void processImage(String image_path) {

		try {
			//set the multiprocessing params
			IMultiProcessingParams processData = engine.getMultiProcessingParams();
			processData.setMultiProcessingMode(MultiProcessingModeEnum.MPM_Parallel);
			processData.setRecognitionProcessesCount(2);
			
			// Create document
			IFRDocument document = engine.CreateFRDocument();

			//Create insta collection
			IIntsCollection indicesWithContent = engine.CreateIntsCollection();


			try {
				
				
				// Add image file to document
				displayMessage( "Loading image..." );
				document.AddImageFile( image_path, null, null );
				
				// Get page-count
				int pagesCount = document.getPages().getCount();
				
				indicesWithContent.Add(0);
				indicesWithContent.Add(pagesCount-1);
				
				// get the page count
				String str3 = String.valueOf(pagesCount);
				displayMessage("Total Page count is ="+str3); 


				//enable orientation detection
				IDocumentProcessingParams dpp = engine.CreateDocumentProcessingParams();    
				dpp.getPageProcessingParams().getPagePreprocessingParams().setCorrectOrientation(true);

				// Process document
				displayMessage( "Process..." );
				document.Process( dpp );

				document.Analyze(null, null, null);
				document.Recognize(null, null);
				document.Synthesize(null);

				// Save results
				displayMessage( "Saving results..." );
		
				// Save results to txt with default parameters
				String txtExportPath = SamplesConfig.GetSamplesFolder() + "SampleImages/ExportResults/sample.txt";
				displayMessage(txtExportPath.getClass().getSimpleName());

				ITextExportParams txtExportParams = engine.CreateTextExportParams();
				txtExportParams.setRetainLayout(true);

				document.ExportPages( txtExportPath, FileExportFormatEnum.FEF_TextUnicodeDefaults, txtExportParams, indicesWithContent, null, null);

			 	}
			 finally {
				// Close document
				document.Close();
			}
		} catch( Exception ex ) {
			displayMessage( ex.getMessage() );
		}
	}

 

 

0

Comments

0 comments

Please sign in to leave a comment.