Introduced barcode extraction feature for image formats.
The following C# code snippet shows how to get barcodes from an image via API:
// Create an instance of Parser class
using (Parser parser = new Parser(Constants.SampleImageWithBarcodes))
{
// Check if the file supports barcodes extraction
if (!parser.Features.Barcodes)
{
Console.WriteLine("File doesn't support barcodes extraction.");
return;
}
// Extract barcodes from the image.
IEnumerable<PageBarcodeArea> barcodes = parser.GetBarcodes();
// Iterate over barcodes
foreach (PageBarcodeArea barcode in barcodes)
{
// Print the page index
Console.WriteLine("Page: " + barcode.Page.Index.ToString());
// Print the barcode value
Console.WriteLine("Value: " + barcode.Value);
}
}
Parse Barcodes from Documents
Ability to define fields of barcode type (TemplateBarcode
) in templates.
// Define a barcode field
TemplateBarcode barcode = new TemplateBarcode(
new Rectangle(new Point(590, 80), new Size(150, 150)),
"QR");
// Create a template
Template template = new Template(new TemplateItem[] { barcode });
// Create an instance of Parser class
using (Parser parser = new Parser(Constants.SamplePdfWithBarcodes))
{
// Parse the document by the template
DocumentData data = parser.ParseByTemplate(template);
// Print all extracted data
for (int i = 0; i < data.Count; i++)
{
Console.Write(data[i].Name + ": ");
PageBarcodeArea area = data[i].PageArea as PageBarcodeArea;
Console.WriteLine(area == null ? "Not a template barcode field" : area.Value);
}
}
Image Detection by Content
Image detection and extraction ability allows you to extract images from compressed ZIP archives or email attachments.
// Create an instance of Parser class
using (Parser parser = new Parser(filePath))
{
// Extract images
IEnumerable<PageImageArea> images = parser.GetImages();
// Check if images extraction is supported
if (images == null)
{
Console.WriteLine("Images extraction isn't supported");
return;
}
// Iterate over images
foreach (PageImageArea image in images)
{
// Print a page index, rectangle and image type:
Console.WriteLine(string.Format("Page: {0}, R: {1}, Type: {2}", image.Page.Index, image.Rectangle, image.FileType));
}
}
Support for .NET 6
Support for .NET 6 has been introduced.
Get Info of Password Protected File
Auto-detect the file type of a password-protected OOXML document.
// Get a file info
Options.FileInfo info = Parser.GetFileInfo(filePath, new LoadOptions("password"));
// Check IsEncrypted property
Console.WriteLine(info.IsEncrypted ? "Password is required" : "");
// Print the file type
Console.WriteLine(info.FileType.ToString());
For a complete list of features, enhancements, and bug fixes in this release please visit, GroupDocs.Parser for .NET 22.2 Release Notes.