Closed
Description
Bug description
While loading some PDF documents in Flutter using SfPdfViewer.file returns an error. I have attached some PDFs for the reference.
computer_networks.pdf
sample.pdf
I also tried to load using the same file from the network source and it is having the same issue. Here is the source URL for the pdf I have used.
I have also referred here forum, but could not find the way to implement the below mentioned snippet (as suggested in the forum) in the SfPdfViewer. Is there any way to either resolve the exception or load such PDF files?
// Open an existing corrupted document from disk.
PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Input.pdf", true);
Steps to reproduce
- Create a new flutter web application
flutter create syncfusion_pdfviewer_poc
- Add syncfusion_flutter_pdfviewer package
flutter pub add syncfusion_flutter_pdfviewer
- Add SfPdfViewer widget to load the PDF.
- Run the application.
Code sample
Code sample
main.dart
import 'package:flutter/material.dart';
import 'package:syncfusion_flutter_pdfviewer/pdfviewer.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
),
home: const MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key, required this.title});
final String title;
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
title: Text(widget.title),
),
body: SfPdfViewer.network(
'https://csc-knu.github.io/sys-prog/books/Andrew%20S.%20Tanenbaum%20-%20Computer%20Networks.pdf',
onDocumentLoadFailed: (error) {
debugPrint(error.error);
debugPrint(error.description);
},
),
);
}
}
pubspec.yaml
name: syncfusion_pdfviewer_poc
description: "A new Flutter project."
publish_to: 'none'
version: 1.0.0+1
environment:
sdk: ^3.7.0
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^1.0.8
syncfusion_flutter_pdfviewer: ^28.2.7
dev_dependencies:
flutter_test:
sdk: flutter
flutter_lints: ^5.0.0
flutter:
uses-material-design: true
Screenshots or Video
Screenshots / Video demonstration
PDF.Loading.Issue.mp4
Stack Traces
Stack Traces
Invalid argument (Invalid cross reference table.): null
#0 CrossTable._initialize (package:syncfusion_flutter_pdf/src/pdf/implementation/io/cross_table.dart:206:7)
#1 new CrossTable (package:syncfusion_flutter_pdf/src/pdf/implementation/io/cross_table.dart:27:5)
#2 PdfCrossTable._initializeCrossTable (package:syncfusion_flutter_pdf/src/pdf/implementation/io/pdf_cross_table.dart:192:18)
#3 new PdfCrossTable (package:syncfusion_flutter_pdf/src/pdf/implementation/io/pdf_cross_table.dart:41:9)
#4 PdfDocument._initialize (package:syncfusion_flutter_pdf/src/pdf/implementation/pdf_document/pdf_document.dart:857:28)
#5 new PdfDocument (package:syncfusion_flutter_pdf/src/pdf/implementation/pdf_document/pdf_document.dart:91:5)
#6 SfPdfViewerState._getPdfFile (package:syncfusion_flutter_pdfviewer/src/pdfviewer.dart:3008:14)
#7 SfPdfViewerState._loadPdfDocument (package:syncfusion_flutter_pdfviewer/src/pdfviewer.dart:2091:56)
<asynchronous suspension>
On which target platforms have you observed this bug?
Android, iOS
Flutter Doctor output
Doctor output
[✓] Flutter (Channel stable, 3.29.0, on macOS 14.5 23F79 darwin-arm64, locale en-IN) [1,335ms]
• Flutter version 3.29.0 on channel stable at /Users/saurabh.d/Downloads/flutter 2
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 35c388afb5 (2 weeks ago), 2025-02-10 12:48:41 -0800
• Engine revision f73bfc4522
• Dart version 3.7.0
• DevTools version 2.42.2
[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0-rc3) [5.1s]
• Android SDK at /Users/saurabh.d/Library/Android/sdk
• Platform android-35, build-tools 35.0.0-rc3
• ANDROID_HOME = /Users/saurabh.d/Library/Android/sdkexport
• Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
This is the JDK bundled with the latest Android Studio installation on this machine.
To manually set the JDK path, use: `flutter config --jdk-dir="path/to/jdk"`.
• Java version OpenJDK Runtime Environment (build 21.0.3+-79915917-b509.11)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 15.4) [1,702ms]
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 15F31d
• CocoaPods version 1.16.2
[✓] Chrome - develop for the web [10ms]
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2024.2) [10ms]
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 21.0.3+-79915917-b509.11)
[✓] Connected device (5 available) [12.8s]
• iPhone 15 Pro (mobile) • 71BC4438-7013-438F-AAE5-EC174AD6F935 • ios • com.apple.CoreSimulator.SimRuntime.iOS-17-5 (simulator)
• macOS (desktop) • macos • darwin-arm64 • macOS 14.5 23F79 darwin-arm64
• Mac Designed for iPad (desktop) • mac-designed-for-ipad • darwin • macOS 14.5 23F79 darwin-arm64
• Chrome (web) • chrome • web-javascript • Google Chrome 133.0.6943.128
[✓] Network resources [3.0s]
• All expected network resources are available.
• No issues found!