isPdfProtected method
Implementation
@override
Future<bool> isPdfProtected({required String filePath}) async {
try {
final file = File(filePath);
if (!file.existsSync()) {
return false;
}
// Simple check for PDF header
final bytes = await file.openRead(0, 1024).toList();
final data = bytes.expand((x) => x).toList();
final content = String.fromCharCodes(data);
// Look for encryption dictionary in PDF
// This is a simple check - not comprehensive
if (content.contains('/Encrypt') || content.contains('/Encrypt ')) {
return true;
}
return false;
} catch (e) {
if (kDebugMode) {
print('Error checking PDF protection: $e');
}
return false;
}
}