flutter-pi
flutter-pi copied to clipboard
Support for viewing PDF's
My application requires video playback and pdf viewing on a raspberry pi.
I switched to flutter-pi with the news that gstreamer is being used. My testing showed that using flutter-pi and gstreamer (video_player) works much better than dart_vlc.
However, now I can no longer view my pdf documents using https://pub.dev/packages/printing. The package relies on pdfium to be compiled for the platform. My current implementation results in this error Error getting printing info: MissingPluginException(No implementation found for method printingInfo on channel net.nfet.printing)
.
I've tried a few other pdf packages designed for android but no luck so far. Is there any solution available?
@ardera Could you elaborate on this?
"viewing"?
As said on #250:
"flutter-pi can only run without desktop. Desktop support is not planned and won't be implemented. You can try using arm64 and the official linux desktop embedder, or sony's flutter-elinux, or toyotas embedder."
This repository is all about removing desktop/viewing need, which "without X" means, if you need more than CLI don't use.
@top-master not sure I agree, flutter is a GUI framework so of course you can talk about viewing PDFs inside flutter. Opening a PDF viewer to view the pdf would not make sense however, but I'm not sure that's what the printing plugin does.
That printing plugin could work in flutter-pi if the native code would be ported to flutter-pi. It supports offscreen rendering of PDFs to a bitmap (See here), the bitmap you can either import into a GL texture or dart:ui Image
and present it.
@RadJKW I am currently working on an implementation for this using ImageMagick's MagickWand C API. You can observe the progress on my fork (branch feature/printing
).
@bojidartonchev, do I understand well, that with your fork it will be possible to display PDF file on the screen?
Hi @eximius313,
I am using the pdf plugin to generate a pdf, then rasterize it and send it to thermal printer for printing. My implementation is rasterizing it as a bitmap, so you will need to decode it on flutter side.
await for (var page in Printing.raster(await doc.save())) {
final image = i.decodeImage(page.pixels)!;
bytes += generator.image(image);
}
The esc_pos_utils I am using for printing is a bit outdated and didn't work with the new image plugin and I didn't have time for investigating it, so I proceed using image_v3 instead. But if you need it only for rendering, image should do the job.
thanks @bojidartonchev!