Aspose.pdf giving IndexOutofRange


#1

My code snippet is below. I am reading scanned pdf(flat form) which has text boxes with values {{vin}}. I have only 4 {{fname}} {{lname}} {{vin}} {{make}} textboxes on that pdf. But it is giving me IndexOutOfRAngeException.

Document pdfDocument = null;

	try {
		pdfDocument = new Document(DBConnectionUtil.FORM_DIR + filename);
		Form pdfForm = pdfDocument.getForm();
		Field[] pdfFields = pdfForm.getFields();
		
		DBObject dbObj = DBConnectionUtil.getDataFromMongoDB(dealId);

		// Create TextAbsorber object to find all instances of the input search phrase
		TextFragmentAbsorber textFragmentAbsorber = new TextFragmentAbsorber("{{vin}}") ;

		// Accept the absorber for first page of document
		pdfDocument.getPages().accept(textFragmentAbsorber);

		// Get the extracted text fragments into collection
		TextFragmentCollection textFragmentCollection = textFragmentAbsorber.getTextFragments();

		if (textFragmentCollection.size() != 0) {
			// Loop through the fragments
			for (TextFragment textFragment : (Iterable<TextFragment>) textFragmentCollection) {
				String text = textFragment.getText().substring(2, textFragment.getText().length()-2);
				String name = FieldsMapper.getKeyForValue(text);

				if (dbObj != null) {
					String dbValue = (String) dbObj.get(name);

					if (dbValue == null) {
						dbValue = "";
					}

					System.out.println("Key " + text + " " + " dbValue " + dbValue);

					// Update text and other properties
					textFragment.setText(dbValue);
					// textFragment.getTextState().setFont(FontRepository.findFont("Verdana"));
					// textFragment.getTextState().setFontSize(22);
					// textFragment.getTextState().setForegroundColor(Color.getBlue());
					// textFragment.getTextState().setBackgroundColor(Color.getGray());

				}
			}
		} else {

		}


	}
	catch (IndexOutOfRangeException e) {
		e.printStackTrace();
	}
	finally {
		if (pdfDocument != null) {
			pdfDocument.close();
		}
	}

Exception com.aspose.pdf.exceptions.IndexOutOfRangeException: At most 4 elements (for any collection) can be viewed in evaluation mode.

I am not sure why I have this error? Please help


#2

@anukanni

Thank you for contacting support.

You are currently facing evaluation limitation which allows to process only four items from any collection, along with evaluation watermark, as explained in Licensing . You may avoid this limitation and test the API in its full capacity by applying a free 30-days temporary license .