Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for viewing PDF's #243

Open
RadJKW opened this issue Apr 13, 2022 · 7 comments · May be fixed by #364
Open

Support for viewing PDF's #243

RadJKW opened this issue Apr 13, 2022 · 7 comments · May be fixed by #364

Comments

@RadJKW
Copy link

RadJKW commented Apr 13, 2022

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?

@RadJKW
Copy link
Author

RadJKW commented Apr 27, 2022

@ardera Could you elaborate on this?

@top-master
Copy link

top-master commented Sep 17, 2022

"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.

@ardera
Copy link
Owner

ardera commented Sep 19, 2022

@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.

@bojidartonchev
Copy link
Contributor

@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 bojidartonchev linked a pull request Sep 21, 2023 that will close this issue
@eximius313
Copy link

@bojidartonchev, do I understand well, that with your fork it will be possible to display PDF file on the screen?

@bojidartonchev
Copy link
Contributor

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.

@eximius313
Copy link

thanks @bojidartonchev!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants