Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,12 @@ class PdfString implements IPdfPrimitive {
if (data![0] == 0xfe && data![1] == 0xff) {
this.value = decodeBigEndian(data, 2, data!.length - 2);
isHex = false;
data = <int>[];
for (int i = 0; i < this.value!.length; i++) {
data!.add(this.value!.codeUnitAt(i).toUnsigned(8));
// 16-byte fields (e.g. /ID) are raw binary identifiers — never
// append decoded character bytes to them.
if (data!.length != 16) {
for (int i = 0; i < this.value!.length; i++) {
data!.add(this.value!.codeUnitAt(i).toUnsigned(8));
}
}
} else {
this.value = byteToString(data!);
Expand Down
33 changes: 25 additions & 8 deletions packages/syncfusion_flutter_pdfviewer/lib/src/pdfviewer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2313,8 +2313,17 @@ class SfPdfViewerState extends State<SfPdfViewer> with WidgetsBindingObserver {
_performTextExtraction();
}
}

Uint8List? signatureBytes;
if (_document != null) {
try {
signatureBytes = _renderDigitalSignatures();
} catch (_) {
// Digital-signature flattening is best-effort; fall back to raw bytes.
}
}
final int pageCount = await _plugin.initializePdfRenderer(
_renderDigitalSignatures() ?? _pdfBytes,
signatureBytes ?? _pdfBytes,
_password,
);
_pdfViewerController._pageCount = pageCount;
Expand Down Expand Up @@ -2352,12 +2361,17 @@ class SfPdfViewerState extends State<SfPdfViewer> with WidgetsBindingObserver {
} catch (e) {
if (widget.onDocumentLoadFailed != null) {
if (widget.password == '' || widget.password == null) {
widget.onDocumentLoadFailed!(
PdfDocumentLoadFailedDetails(
'Empty Password Error',
'The provided `password` property is empty so unable to load the encrypted document.',
),
);
// Only report "no password" when the dialog won't be shown.
// When canShowPasswordDialog is true the UI handles it,
// so firing onDocumentLoadFailed here is confusing noise.
if (!widget.canShowPasswordDialog) {
widget.onDocumentLoadFailed!(
PdfDocumentLoadFailedDetails(
'Empty Password Error',
'The provided `password` property is empty so unable to load the encrypted document.',
),
);
}
} else {
widget.onDocumentLoadFailed!(
PdfDocumentLoadFailedDetails(
Expand Down Expand Up @@ -2409,7 +2423,10 @@ class SfPdfViewerState extends State<SfPdfViewer> with WidgetsBindingObserver {
/// Render and flatten digital signatures in the PDF document.
Uint8List? _renderDigitalSignatures() {
if (_document!.form.fields.count != 0) {
final PdfDocument pdfDocument = PdfDocument(inputBytes: _pdfBytes);
final PdfDocument pdfDocument = PdfDocument(
inputBytes: _pdfBytes,
password: _password,
);
bool isDigitalSignature = false;
Uint8List? digitalSignatureBytes;

Expand Down