PlatformException opening normal PDF
Describe the bug Unable to show/open a simple PDF, common PDF readers simply open it.
To Reproduce Steps to reproduce the behavior:
import 'package:flutter/material.dart';
import 'package:pdfx/pdfx.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true,
),
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> {
late PdfController _pdfController;
@override
void initState() {
super.initState();
_pdfController = PdfController(
document: PdfDocument.openAsset('assets/20220520_1827_IT.pdf'),
);
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
title: Text(widget.title),
),
body: PdfView(controller: _pdfController),
);
}
}
Expected behavior Simply show the PDF.
Screenshots If applicable, add screenshots to help explain your problem.
Smartphone (please complete the following information):
- Device: iPhone 16 Pro
- OS: iOS 18.2
Same exact issue here. I have tried numerous PDFs from various sources, some open and some do not.
I confirmed that the PDF posted by @enricobenedos results in the PlatformException in my app as well.
Not sure if it's relevant, but here are the details of various PDFs that opened (green) or generated the PlatformException (red). It seems like pdfs generated by later versions of the Adobe PDF Library are the ones that won't open.
Also: this exception only occurs in iOS; the package works correctly in Android.
any updates?
FYI: we used the errorBuilder to show the pdf in the browser as fallback