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

Screenshot parts of the PDF #48

Closed
deepu opened this issue Jul 7, 2021 · 3 comments
Closed

Screenshot parts of the PDF #48

deepu opened this issue Jul 7, 2021 · 3 comments

Comments

@deepu
Copy link

deepu commented Jul 7, 2021

Hey, firstly great plugin. it's working pretty smooth for most of what I need.

However I am stuck when I try to capture screenshot of whatever is displaying on the screen as an image.
I tried wrapping PDFViewer with the Screenshot plugin (https://pub.dev/packages/screenshot) but it just shows me empty screen without any text

My code

class CreateNotesView extends GetView<CreateNotesController> {
  @override
  Widget build(BuildContext context) {
    ScreenshotController screenshotController = ScreenshotController();
    return Scaffold(
      appBar: AppBar(
        title: Text('CreateNotesView'),
        centerTitle: true,
      ),
      body: Screenshot(
        controller: screenshotController,
        child: PdfViewer.openFile(
          controller.notesPdf.path,
        ),
      ),
      floatingActionButton: IconButton(
          onPressed: () {
            print('pressed');
            screenshotController.capture().then((value) {
              print('screenshot Done');
              Get.defaultDialog(
                content: Image.memory(value!)
              );
            }).catchError((onError) {
              print(onError);
            });
          },
          icon: Icon(Icons.camera)),
    );
  }
}

When I take screenshot it shows like this.
As you can see, the outline, borders, drop shadows et al are captured but the actual content inside the PDF is missing from the screenshot. Any tips on how to go about resolving this ?

IMG_9A6D6BE220D5-1

@espresso3389
Copy link
Owner

On the bottom of screenshot Readme,

Platform Views are not supported. (Example: Google Maps, Camera etc)

I'm not sure what they describing by the word "Platform Views" but it does not seem to support Texture, which is heavily used in pdf_render plugin:

But I'm not sure what really impacts on the screenshot feature so far.

@espresso3389
Copy link
Owner

By the way, if you just need some kind of document image, pdf_render also provides low and raw level API that renders page image one by one.

It can generate dart:ui Image so that it can be saved to PNG file or anything:

...
final pageImage = await page.render();
final image = await pageImage.createImageDetached();
final pngData = await image.toByteData(ImageByteFormat.png);

@deepu
Copy link
Author

deepu commented Jul 7, 2021

Thanks this helped.
I rendered pngdata and now able to take screenshot of that Image

Thanks a ton again

@deepu deepu closed this as completed Jul 7, 2021
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

No branches or pull requests

2 participants