FIX: Add PDF.js library to web/index.html for SfPdfViewer web support

This commit is contained in:
Leon Bösche
2026-01-11 18:13:36 +01:00
parent c8eb0aefe3
commit d6277f5469
2 changed files with 17 additions and 3 deletions

View File

@@ -178,8 +178,10 @@ class _DocumentViewerModalState extends State<DocumentViewerModal> {
}
if (state is DocumentViewerReady) {
if (state.caps.isPdf) {
// Log the URL being used for debugging
// Log the URL and auth being used for debugging
print('Loading PDF from: ${state.viewUrl}');
print('Token: ${state.token.substring(0, 20)}...');
print('Headers being passed: Authorization: Bearer ${state.token.substring(0, 20)}...');
// Pass token via Authorization header - SfPdfViewer supports headers parameter
return SfPdfViewer.network(
state.viewUrl.toString(),
@@ -187,8 +189,13 @@ class _DocumentViewerModalState extends State<DocumentViewerModal> {
'Authorization': 'Bearer ${state.token}',
},
onDocumentLoadFailed: (details) {
print('PDF load failed: ${details.error}');
print('Description: ${details.description}');
print('PDF load FAILED');
print(' Error: ${details.error}');
print(' Description: ${details.description}');
},
onDocumentLoaded: (PdfDocumentLoadedDetails details) {
print('✅ PDF loaded successfully');
print(' Pages: ${details.document.pages.count}');
},
);
} else {

View File

@@ -55,6 +55,13 @@
<title>b0esche_cloud</title>
<link rel="manifest" href="manifest.json">
<!-- PDF.js library for SfPdfViewer on web -->
<script type="module" async>
import * as pdfjsLib from 'https://cdnjs.cloudflare.com/ajax/libs/pdf.js/4.9.155/pdf.min.mjs';
pdfjsLib.GlobalWorkerOptions.workerSrc = "https://cdnjs.cloudflare.com/ajax/libs/pdf.js/4.9.155/pdf.worker.min.mjs";
window.pdfjsLib = pdfjsLib;
</script>
</head>
<body>