You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Future extractImagesFromPath(String pdfPath) async {
final doc = await PdfDocument.openFile(pdfPath);
final pages = doc.pageCount;
for (int i = 1; i <= pages; i++) {
var page = await doc.getPage(i);
var imgPDF = await page.render();
var img = await imgPDF.createImageDetached();
var imgBytes = await img.toByteData(format: ImageByteFormat.png);
var libImage = imglib.decodeImage(imgBytes!.buffer
.asUint8List(imgBytes.offsetInBytes, imgBytes.lengthInBytes));
final tempDir = await getTemporaryDirectory();
final tempFile = File('${tempDir.path}/temp_image_$i.png');
await tempFile.writeAsBytes(imglib.encodePng(libImage!));
// Read the barcodes from the temporary file
DecodeParams params = DecodeParams(maxSize: 1920); // Set the max size as needed
Codes results = await zx.readBarcodesImagePath(XFile(tempFile.path), params: params);
if (results.codes.isNotEmpty) {
for (var result in results.codes) {
if (result.isValid) {
print('QR Code Data: ${result.text}');
} else {
print('No QR code detected');
}
}
} else {
print('No QR codes detected');
}
}
}`
I am unable to detect the barcodes, I am using the latest version of flutter-zxing.
The text was updated successfully, but these errors were encountered:
`
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@OverRide
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body: Center(
child: ElevatedButton(
onPressed: () async {
FilePickerResult? result = await FilePicker.platform.pickFiles(
type: FileType.custom,
allowedExtensions: ['pdf'],
);
}
}
Future extractImagesFromPath(String pdfPath) async {
final doc = await PdfDocument.openFile(pdfPath);
final pages = doc.pageCount;
for (int i = 1; i <= pages; i++) {
var page = await doc.getPage(i);
}
}`
I am unable to detect the barcodes, I am using the latest version of flutter-zxing.
The text was updated successfully, but these errors were encountered: