rackberg / flutter_pdf_renderer

Flutter Plugin to render a PDF file.

Home Page:https://pub.dartlang.org/packages/flutter_pdf_renderer

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Load file downloaded

gjaber opened this issue · comments

Hi, how can I load a file downloaded from network?
Plugin tries always to load from "flutter_assets".
Tks.

I have the same question

Hi @gjaber, thank you for creating this issue.
I'm working on the solution right now.

@lgArlequin Thank you too for using the plugin.

I have the same problem

commented

Same here, hopefully this will be the package to stick with.
Side question, is it possible click internal links like contents page, search and bookmark pages and use bottom navigation?

Thanks for the hard work

Hi all,

sorry that you have to wait so long for the fix. I was really busy with my new job and still am.
I see that the feature you requested needs to be implemented as soon as possible.

I would appreciate it, if some of you want to help me getting this done by contributing and creating pull-requests.

Again, I am trying to solve this issue right now.

Thank you for your patience!

I do not know if this can help you, but I'm using it with another plugin to first download the pdf in a temporary directory and then show it, maybe with this and with the possibility of pointing it to any file path, it can work.

Future<File> createFileOfPdfUrl() async {
    final url = 'http://example.com/example.pdf';
    final filename = url.substring(url.lastIndexOf("/") + 1);
    String dir = (await getTemporaryDirectory()).path;
    File file = new File('$dir/$filename');
    bool exist = false;
    try {
      await file.length().then((len) {
        exist = true;
      });
    } catch (e) {
      print(e);
    }
    if (!exist) {
      var request = await HttpClient().getUrl(Uri.parse(url));
      var response = await request.close();
      var bytes = await consolidateHttpClientResponseBytes(response);
      await file.writeAsBytes(bytes);
    }
    return file;
  }

The source:
https://github.com/albo1337/flutter_full_pdf_viewer/blob/master/example/lib/main.dart

@lgArlequin The code snippet to download the file helped me a lot.
Thank you very much.

I managed to render the downloaded pdf file on android with my plugin after changing some code.
Stay tuned for the next commits.

Hi all,

just released version 1.3.0 with support to load a pdf file from an absolute path.
I've also updated the example project which downloads a pdf file from an url you typed in.
After downloading the file it will be rendered.

This works for android only at the moment.
Will continue to create the same solution for iOS.

Hi again,

@gjaber @lgArlequin @GustavoDMS @l-k22

I've finished implementing the code to support iOS devices to download a pdf file and render it.
Just update to the new version 1.3.1

See the example here: https://pub.dartlang.org/packages/flutter_pdf_renderer#-example-tab-

Hope this will be useful for you!

If you need further help let me know.
If it works for you please write a comment so I know when to close this issue.

Thank you very much!

I'm closing this issue now.