flutter_pdf_render
flutter_pdf_render copied to clipboard
Image is 180 rotated and horizontally inversed
final document = await PdfDocument.openData(await file.readAsBytes()); for (var i = 0; i < document.pageCount; i++) { final page = await document.getPage(i + 1); // Starts from 1 var imgPDF = await page.render( width: page.width.toInt(), height: page.height.toInt()); ui.Image img = await imgPDF.createImageIfNotAvailable();
the image ends up being invested, even tho pdf is normal.
What platform are you using? And could you please give me the sample PDF file if possible.
It's web.

I think this is the issue: https://github.com/mozilla/pdf.js/issues/10400
@paqio
The things are too much complicated... You can see the example code renders the image correctly with your PDF file if you're on Flutter stable (**related issue):

The current render method on Web platform has been mis-implemented and thus the GUI side internal code flips the image upside-down on the rendering process to correct it. It means that the behavior is not-correct but regareded as designed and expected.
The critical issue here is that the Web behavior is different from the ones of other platforms. So I should fix the problem though it breaks the backward compatibility...
Flutter 2.8.1 • channel stable • https://github.com/flutter/flutter.git Framework • revision 77d935af4d (10 weeks ago) • 2021-12-16 08:37:33 -0800 Engine • revision 890a5fca2e Tools • Dart 2.15.1
So you are saying that in your example it flipps? or? Is there a quick fix for me at the moment?
Because i am using the workaround already window.workaround_for_flutter_93615 = true;
I updated to the latest stable 2.10.2, issue remains
@paqio For what purpose do you use the raw RGBA image? If it is simply passed to Flutter widget, you can flip the image on GUI side; otherwise PdfPageImage.buffer contains the raw RGBA data and you can easily flip the data on your hand.
Anyway, I'll fix the issue next week...
i need an ui.Image to merge them into one. Ended up using pdfx for now, maybe you can check their way of handling the render
@paqio
i need an ui.Image to merge them into one. Ended up using pdfx for now, maybe you can check their way of handling the render
Do you want to conbine page images into one to form a large one? Or generate multipage?
Any updates on this?
Any update will be appreciated.
At least for me this seems to be fixed now in version 1.3.0. Thanks @espresso3389
I'm getting this in flutter web, plugin version 1.3.1. Doesn't happen on android.
Does anyone have some Flutter web example that easily reproduces the issue?
can you use transform in widget
Container( padding: const EdgeInsets.all(10.0), color: Colors.grey, child: Center( child: **Transform( alignment: Alignment.center, transform: Matrix4.identity()..scale(1, -1),** child: Image.memory(_pageImage.buffer.asUint8List(), fit: BoxFit.contain))))