extract library
Bangla text extraction from PDFs.
A separate library on purpose: importing package:bangla_pdf/bangla_pdf.dart
to generate a PDF costs nothing from this file.
import 'package:bangla_pdf/extract.dart';
final result = BanglaPdfExtractor.extract(bytes);
print(result.encodingDetected); // unicode | bijoy | mixed | none
print(result.text);
It handles three kinds of document:
- Unicode — a modern PDF with a
/ToUnicodeCMap, or/ActualTextspans like the ones this package writes. Read directly. - Bijoy / ANSI — the legacy encoding behind most Bangladeshi
government and newspaper PDFs. The text layer is Latin-1 mojibake
(
Avgvi ‡mvbvi evsjv); it is converted back to Unicode per text run, because only the run's font can tell Bijoy bytes from real English. - Scanned — no text layer at all. Reported as
BanglaTextEncoding.none, with
BanglaPdfExtractor.ocrHookavailable to plug in an OCR engine.
Classes
- BanglaPdfExtractor
- Reads Bangla text out of a PDF.
- ExtractedPage
- One extracted page.
- ExtractionResult
- The result of extracting a document.
Enums
- BanglaTextEncoding
- How the Bangla in a document was encoded.
Functions
-
bijoyToUnicode(
String ansi) → String - Converts one Bijoy/ANSI run to Unicode Bangla.
Typedefs
- BanglaOcrHook = String? Function(ExtractedPage page)
- Called for a page with no text layer, to supply text from elsewhere.