The pdf page display is not clear when using PdfDocumentViewBuilder.file()
using PdfDocumentViewBuilder.file() to open a pdf file,the pdf page display is not clear.but when i open the same pdf file with PdfViewer.file(),it is very clear.And I found PdfPageView can set maximumDpi,but no matter how this parameter is set ,it does not work. So what should i do to Improve the display clarity of PDF pages using PdfDocumentViewBuilder.file?
another inforamtion
Flutter 3.27.0 • channel stable • https://github.com/flutter/flutter.git Framework • revision 8495dee1fd (3 weeks ago) • 2024-12-10 14:23:39 -0800 Engine • revision 83bacfc525 Tools • Dart 3.6.0 • DevTools 2.40.2
windows version Windows 11 pro 23H2
import 'package:flutter/material.dart';
import 'package:pdfrx/pdfrx.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return const MaterialApp(
title: 'Pdfrx example',
home: MainPage(),
);
}
}
class MainPage extends StatefulWidget {
const MainPage({super.key});
@override
State<MainPage> createState() => _MainPageState();
}
class _MainPageState extends State<MainPage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
leading: IconButton(
icon: const Icon(Icons.menu),
onPressed: () {},
),
title: const Text('Pdfrx example'),
),
body: PdfDocumentViewBuilder.file(
'D:/c.pdf',
builder: (context, document) => ListView.builder(
padding: const EdgeInsets.all(5),
itemExtent: document?.pages.first.height ?? 800,
itemCount: document?.pages.length ?? 0,
// cacheExtent: 500,
itemBuilder: (context, index) {
return Container(
height: document?.pages.first.height,
width: document?.pages.first.width,
child: PdfPageView(
document: document,
pageNumber: index + 1,
alignment: Alignment.center,
),
);
},
),
)
// PdfViewer.file(
// 'D:/c.pdf',
// passwordProvider: () => 'test',
// ),
);
}
}
Please note that the width/height returned by PdfPage.width/PdfPage.width, is points (height in pixels at 72 dpi), not in pixel.
And, if you want to calculate the PDF resolution by yourself, you can use PdfPageView.pageSizeCallback.
@espresso3389 Thanks for your generosity reminder . I noticed biggestSize and pageSize have a fixed proportional relationship and the calculation logic of PageSize in pdf_widgets.dart ,it helps me
close