GroupDocs.Parser for Java 23.10 Release Notes
Full List of Issues Covering all Changes in this Release
Key | Summary | Category |
---|---|---|
PARSERNET-2151 | Improve template fields parsing functionality | Improvement |
PARSERNET-2150 | Implement the ability to set CASE of template fields | Feature |
Public API and Backward Incompatible Changes
Improve template fields parsing functionality
Description
This features allows to set the size of the border that is ignored when captured by the rectangular area.
Public API changes
PageAreaOptions public class was updated with changes as follows:
- Added PageAreaOptions(Rectangle rectangle, double rectangleTolerance) constructor.
- Added RectangleTolerance property.
PageTextAreaOptions public class was updated with changes as follows:
- Added PageTextAreaOptions(String expression, Rectangle rectangle, double rectangleTolerance) constructor.
- Added PageTextAreaOptions(String expression, boolean matchCase, boolean uniteSegments, boolean ignoreFormatting, Rectangle rectangle, double rectangleTolerance) constructor.
TemplateOptions public class was added.
Template public class was updated with changes as follows:
- Added Template(Iterable<? extends TemplateItem> items, TemplateOptions options) constructor.
- Added Options property.
Usage
The following example shows how to set the size of the border that is ignored when captured by the rectangular area:
// Define a barcode field
TemplateBarcode barcode = new TemplateBarcode(
new Rectangle(new Point(405, 55), new Size(100, 50)),
"QR");
// Create a template
Template template = new Template(Arrays.asList(new TemplateItem[]{barcode}), new TemplateOptions(0.5));
// Create an instance of Parser class
try (Parser parser = new Parser(Constants.SamplePdfWithBarcodes)) {
// Iterate over document pages
for (DocumentPageData data : parser.parsePagesByTemplate(template)) {
System.out.println(String.format("Page: %s", data.getPageIndex()));
// Print all extracted data
for (int i = 0; i < data.getCount(); i++) {
// Print field name
System.out.print(data.get(i).getName() + ": ");
// As we have defined only barcode fields in the template,
// we cast PageArea property value to PageBarcodeArea
PageBarcodeArea area = data.get(i).getPageArea() instanceof PageBarcodeArea
? (PageBarcodeArea) data.get(i).getPageArea()
: null;
System.out.println(area == null ? "Not a template barcode field" : area.getValue());
}
}
}
Improve template fields parsing functionality
Description
This improvement allows to set the case of the field name.
Public API changes
TemplateBarcode public class was updated with changes as follows:
- Added TemplateBarcode(Rectangle rectangle, String name, Integer pageIndex, boolean useUpperCaseName) constructor.
TemplateField public class was updated with changes as follows:
- Added TemplateField(TemplatePosition position, String name, Integer pageIndex, boolean useUpperCaseName) constructor.
TemplateTable public class was updated with changes as follows:
- Added TemplateTable(TemplateTableLayout layout, String name, Integer pageIndex, boolean useUpperCaseName) constructor.
- Added TemplateTable(TemplateTableParameters parameters, String name, Integer pageIndex, boolean useUpperCaseName) constructor.
Usage
The following example shows how to create an instance of template item without name case converting:
// Create an instance of barcode field
TemplateBarcode barcode = new TemplateBarcode(rectangle, "FieldName", 1, false);
// Create an instance of text field
TemplateField field = new TemplateField(position, "FieldName", 1, false);
// Create an instance of table field with layout
TemplateTable table = new TemplateTable(layout, "TableName", null, false);
// Create an instance of table field with table parameters
TemplateTable table = new TemplateTable(parameters, "TableName", 1, false);