Android 颤振:如何打开具有特定页面范围的PDF文档
我想打开具有特定页面范围的PDF文档。比如一个PDF有10页。 然后我想从第3页打开到第7页 我尝试了多个在线可用的软件包。它们不提供此功能 例如:Android 颤振:如何打开具有特定页面范围的PDF文档,android,swift,flutter,cross-platform,Android,Swift,Flutter,Cross Platform,我想打开具有特定页面范围的PDF文档。比如一个PDF有10页。 然后我想从第3页打开到第7页 我尝试了多个在线可用的软件包。它们不提供此功能 例如: -这提供了选项,但这有很多依赖性问题,因此我不想使用它 因此,请向我推荐一些库,或者如果有人有一些与此相关的代码,请提供给我。或者,如果有任何其他最佳方法可以满足给定的要求,请也向我推荐。这有助于我打开带有特定页码的pdf 步骤1:加载文档 Future<PDFDocument> _getDocument() async {
- -这提供了选项,但这有很多依赖性问题,因此我不想使用它
Future<PDFDocument> _getDocument() async {
if (await new File('../path_of_file').exists()) {
file = 1; // exist
return PDFDocument.openFile('../path_of_file');
} else {
setState(() {
showAppBar = true;
file = 0; // Does not exist
});
}
}
步骤3:使用以下命令访问构建小部件
return FutureBuilder<PDFDocument>(
future: _getDocument(),
builder: (_, snapshot) {
if (snapshot.hasData) {
return PDFView(
controller: pageController,
document: snapshot.data,
);
}
if (snapshot.hasError) {
return Center(
child: Text(
'PDF Rendering does not '
'support on the system of this version',
),
);
}
return Center(child: CircularProgressIndicator());
},
);
返回FutureBuilder(
未来:_getDocument(),
构建器:(\uux,快照){
if(snapshot.hasData){
返回PDFView(
控制器:页面控制器,
文档:snapshot.data,
);
}
if(snapshot.hasError){
返回中心(
子:文本(
“PDF呈现不可用”
“此版本系统上的支持”,
),
);
}
返回中心(子项:CircularProgressIndicator());
},
);
这有助于我打开带有特定页码的pdf
步骤1:加载文档
Future<PDFDocument> _getDocument() async {
if (await new File('../path_of_file').exists()) {
file = 1; // exist
return PDFDocument.openFile('../path_of_file');
} else {
setState(() {
showAppBar = true;
file = 0; // Does not exist
});
}
}
步骤3:使用以下命令访问构建小部件
return FutureBuilder<PDFDocument>(
future: _getDocument(),
builder: (_, snapshot) {
if (snapshot.hasData) {
return PDFView(
controller: pageController,
document: snapshot.data,
);
}
if (snapshot.hasError) {
return Center(
child: Text(
'PDF Rendering does not '
'support on the system of this version',
),
);
}
return Center(child: CircularProgressIndicator());
},
);
返回FutureBuilder(
未来:_getDocument(),
构建器:(\uux,快照){
if(snapshot.hasData){
返回PDFView(
控制器:页面控制器,
文档:snapshot.data,
);
}
if(snapshot.hasError){
返回中心(
子:文本(
“PDF呈现不可用”
“此版本系统上的支持”,
),
);
}
返回中心(子项:CircularProgressIndicator());
},
);