Closed Fethi-Hamdani closed 4 years ago
Do you use FutureBuilder ?
yes, i copied the example
the pdf file i'm trying to display is from device's storage not assets, can that be the issue?
I don't think there is a problem with this. I use a similar method and I have no performance issues. I must mention that I am working on large pdf files.
!!! You should try the release version for full performance.
PDFDocument _document;
Future<PDFDocument> _getDocument() async {
return _document = await PDFDocument.openFile(your path+ "/file.pdf");
}
FutureBuilder<PDFDocument>(
future: _getDocument(),
builder: (_, snapshot) {
if(snapshot.hasdata) {
return PDFView()... }
}
)
@Fethi1 where you run project? On real device in debug mod or emulator in debug mode?
i run it on a real device, i have tried it on both debug and release and in different phones and the same thing happen, especially for pages that has images, it takes some time to load. the app i'm developing is supposed to fetch pdf files on device and display each file on a new Route
You can play with render option (render docs)
PDFView(
controller: pageController,
renderer: (PDFPage page) => page.render(
// for example set to 1.25-1.5
// the quality of the final result may decrease
width: page.width * 2,
height: page.height * 2,
format: PDFPageFormat.JPEG,
backgroundColor: '#FFFFFF',
),
);
pages are converted to an image and part of the time is spent on transfer from dart side to platform and back
@SergeShkurko it seems converted page to an image spent lots of time when i use animateToPage
or other animation api .There is a black area on the bottom.what should i do to solve the problem?
@SergeShkurko please change the example as I described in https://github.com/rbcprolabs/packages.flutter/issues/46#issuecomment-615361536
You shouldn't load the PDF this way into a FutureBuilder
. This results in many repeated calls to the function and is discouraged in the Flutter documentation (yes, I know it's cached in a variable but still, this is not the suggested way of handling it).
@atheist1 usage jumpTo or minimize delay
@deakjahn i change api un 3.0.0, it is no longer required
option renderer was not working until 3.0.0, now fixed
when the pdf file is loaded pages takes time to load even in release which is pretty annoying for book readers and it is even worse for pages that contain images, is there any to make it faster?