Skip to content
This repository has been archived by the owner on Nov 18, 2024. It is now read-only.

Example request for Texture #117

Open
mfizz1 opened this issue Apr 29, 2023 · 0 comments
Open

Example request for Texture #117

mfizz1 opened this issue Apr 29, 2023 · 0 comments

Comments

@mfizz1
Copy link

mfizz1 commented Apr 29, 2023

It is a bit beyond me and I cannot figure out what it is that I am doing or how to go about it. I want to utilize the PdfPageImageTexture.

I am trying to get the PDF and create a slideshow of all the pages. Whilst I can achieve that using just PDF view, it want to make it as efficient as possible.

Future<List<int>> pdfToTexids(String url) async {
  final file = await DefaultCacheManager().getSingleFile(url);
  final doc = await PdfDocument.openFile(file.path);
  final int pages = doc.pageCount;
  final List<int> imageTexids = [];

  for (var i = 1; i <= pages; i++) {
    final imageTexture =
        await PdfPageImageTexture.create(pdfDocument: doc, pageNumber: i);
    imageTexids.add(imageTexture.texId);
    imageTexture.dispose();
  }
  doc.dispose();
  return imageTexids;
}

I use this inside a Future Builder like this:

 Widget build(BuildContext context) {
    return FutureBuilder(
      future: pdfToTexids(
          "example.pdf.com"),
      builder: (context, snapshot) {
        if (snapshot.hasData) {
          return Texture(
            textureId: snapshot.data!.elementAt(1),
            freeze: true,
          );
        } else {
          return const SizedBox();
        }
      },
    );

  }

I only get a black box with the notification in debuG console for:

E/IMGSRV ( 463): :0: IsTextureConsistent: IMGEGLImage is not consistent

What am I doing wrong?

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

No branches or pull requests

1 participant