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 is DocumentViewerReady) {
|
||||||
if (state.caps.isPdf) {
|
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('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
|
// Pass token via Authorization header - SfPdfViewer supports headers parameter
|
||||||
return SfPdfViewer.network(
|
return SfPdfViewer.network(
|
||||||
state.viewUrl.toString(),
|
state.viewUrl.toString(),
|
||||||
@@ -187,8 +189,13 @@ class _DocumentViewerModalState extends State<DocumentViewerModal> {
|
|||||||
'Authorization': 'Bearer ${state.token}',
|
'Authorization': 'Bearer ${state.token}',
|
||||||
},
|
},
|
||||||
onDocumentLoadFailed: (details) {
|
onDocumentLoadFailed: (details) {
|
||||||
print('PDF load failed: ${details.error}');
|
print('❌ PDF load FAILED');
|
||||||
print('Description: ${details.description}');
|
print(' Error: ${details.error}');
|
||||||
|
print(' Description: ${details.description}');
|
||||||
|
},
|
||||||
|
onDocumentLoaded: (PdfDocumentLoadedDetails details) {
|
||||||
|
print('✅ PDF loaded successfully');
|
||||||
|
print(' Pages: ${details.document.pages.count}');
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -55,6 +55,13 @@
|
|||||||
|
|
||||||
<title>b0esche_cloud</title>
|
<title>b0esche_cloud</title>
|
||||||
<link rel="manifest" href="manifest.json">
|
<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>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
|||||||
Reference in New Issue
Block a user