Skip to content

Commit

Permalink
WIP: WASM build could not open certain PDF file
Browse files Browse the repository at this point in the history
  • Loading branch information
espresso3389 committed Feb 13, 2025
1 parent d976cbe commit 6784197
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
7 changes: 7 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@
"request": "launch",
"type": "dart",
"program": "example/viewer/lib/main.dart"
},
{
"name": "viewer example (WASM)",
"request": "launch",
"type": "dart",
"program": "example/viewer/lib/main.dart",
"args": ["-d", "chrome", "--wasm"]
}
]
}
5 changes: 2 additions & 3 deletions lib/src/web/pdfrx_web.dart
Original file line number Diff line number Diff line change
Expand Up @@ -152,13 +152,12 @@ class PdfDocumentWeb extends PdfDocument {
required String sourceName,
void Function()? onDispose,
}) async {
final perms = (await document.getPermissions().toDart)?.toDart.cast<int>();

final perms = (await document.getPermissions().toDart)?.toDart.map((v) => v.toDartInt).toList();
final doc = PdfDocumentWeb._(
document,
sourceName: sourceName,
isEncrypted: perms != null,
permissions: perms != null ? PdfPermissions(perms.fold<int>(0, (p, e) => p | e), 2) : null,
permissions: perms != null ? PdfPermissions(perms.fold(0, (p, e) => p | e), 2) : null,
onDispose: onDispose,
);
final pageCount = document.numPages;
Expand Down

0 comments on commit 6784197

Please sign in to comment.