Open a Document From URL in Flutter PDF Viewer (SfPdfViewer)
5 Sep 20251 minute to read
The SfPdfViewer.network creates a widget that displays the PDF document obtained from a URL. The following code example explains the same.
@override
Widget build(BuildContext context) {
return Scaffold(
body: SfPdfViewer.network(
'https://cdn.syncfusion.com/content/PDFViewer/flutter-succinctly.pdf'));
}To load a PDF from network using SfPdfViewer.network on macOS, network access must be enabled in your macOS application. In your macos/Runner/DebugProfile.entitlements file, add the following lines inside the <dict> tag to enable network access in your application:
<key>com.apple.security.network.client</key>
<true/>NOTE
Due to CORS security restrictions in a web application, some PDFs obtained from URLs might not be loaded on the
SfPdfViewerweb platform. Kindly refer to the Flutter forum for more information on this issue.
This issue can be resolved by configuring the CORS settings on the requested server or by disabling the security settings in chrome.dart as mentioned in the steps below:
- Go to flutter\bin\cache and remove a file named: flutter_tools.stamp.
- Go to flutter\packages\flutter_tools\lib\src\web and open the file chrome.dart.
- Find ’–disable-extensions’.
- Add ’–disable-web-security’.