FIX: Add PDF.js library to web/index.html for SfPdfViewer web support
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user