[Feature request]: Advanced pdf features
Is your feature request related to a problem? Please describe
PDFs are a big topic for importing and exporting. Featuring text support, ... would help people using the app in production
Describe your feature request!
Add this
Additional context
We need to create our own library for this. https://github.com/DavBfr/dart_pdf does not support importing pdfs in the free tier.
Code of Conduct
- [X] I agree to follow this project's Code of Conduct
This is a good package. And I have some advices for rendering pdf. There is a package pdfrx backed by pdfium that support some advanced pdf features. Specially, so far Butterfly only imports pdf to images as canvas background. Butterfly's Renderer use canvas to draw backgroud which it is not better for rendering pdf clearly. Maybe put canvas on pdfrx viewer widget ?https://github.com/espresso3389/pdfrx?tab=readme-ov-file#additional-customizations. It provides Per-page Customization using Widget and Per-page Customization using Canvas.
I'm usually against non-canvas renderers. My whole rendering system relies on the canvas and it allows saving performance when creating new elements by just saving the last rendering. A widget would mean building an extra widget tree to display these.
My other idea was a "dynamic image" builder. It doesn't convert it on import, instead it saves the PDF and depending on the zoom level, it renders the image
I'm not sure meaning of "dynamic image" builder. Isn't this a pdf render? I think pdfium directly render as an image depending on the zoom level. And I guess that you want to render pdf only by canvas. But comparing with pdfium, pdfium is a mature library. I think rendering by canvas may be a loss of performance.
Yeah, a real pdf renderer that renders an image and paints it on the canvas. The image render part uses pdfium under the hood in the current version, so it doesn't make a difference . If we use widgets or canvas
Oh, I see.
I just looked at it and pdfrx seems like to have a canvas system inside it that I can use. Putting it on my todo list
Oh looks like it cannot create pdfs... need to look for a different solution
Pdfrx use pdfium. You can create pdf by pdfium api directly. btw pdfrx may not bind all pdfium api with ffigen, you ffigen them.
Yeah that's my problem. Only loading functions of pdfium are binded. Also we need to use pdf.js on web.
I'm currently thinking about https://lib.rs/crates/printpdf. With flutter_rust_bridge it is easy to create bindings for dart and since it doesn't depend on native code, we can support all platforms.
Cool, rust is good. But I think pdfium is a mature library which also supports wasm now.
Hmm, okay... I'm not a big c++ pro but maybe I can do some things with ffigen and pdfium to get my own bindings to pdfium...
Found out ffigen doesn't really support web... Are you familiar in creating bindings in dart?
https://github.com/ajrcarey/pdfium-render has rust bindings
No, I only know https://github.com/espresso3389/pdfrx/wiki/Enable-Pdfium-WASM-support
This looks wonderful, I will try it
Okay looks like pdfrx gets editing/saving features some time in the future: https://github.com/espresso3389/pdfrx/issues/421.
For now i think i will keep the pdf package for now. For starting with advanced pdf features we need to do this:
- Saving the real pdf file instead of rendering on import
- If the pdf is visible, only render this part (with the specific resolution)
Added in 2.4.0-beta.3. I think "advanced" pdf features like highlighting or more will come very far in the future since the pdf library we use currently only allows this in a premium plan