Closed xpwmaosldk closed 13 hours ago
Do you want to manupulate PDF page image? If so, you'd better use PdfDocument.openData to load the document and then create page image.
final doc = PdfDocument.openData(...);
final pdfImage = await doc.pages[0].render();
// Get raw pixel data RGBA or BGRA depending on platform
final rawRgba = pdfImage.pixels;
You can access the raw RGBA data and then you can use any kind of Image processing library or Dart:ui to manipulate the image.
NOTE: you should dispose pdfImage
and doc
there.
This is my code snuppet
PdfViewer.data(
pdfBytes,
...,
controller: controller,
pageOverlaysBuilder:(...)=>[
Text('pageOverlaysBuilder'),
Image(...),
]
);
How can I obtain the data that includes the overlays? I would like to perform the following tasks:
Unit8List data = controller.getCurrentPdfData()
// make file from data
I think there should be something like controller.getCurrentPdfData()
to get this.
What do you mean by "overlays"?
The components such as Text, Image, etc. are inside the pageOverlaysBuilder. I would like to retrieve the PDF data with these components that are drawn on the page.
Try https://pub.dev/packages/screenshot or such. pdfrx does not have such feature.
Thank you. I have already tried that, but I had to convert the images back into PDFs for each page, which was very costly and slow.
I'll have to look for another method.
Basically pdfrx's widgets are only to interact with user. If you want to handle PDF page images directly, use PdfDocument and so on. And, if you want to do overlay the things such as link or text, PdfPage has functions to extract them. And all you have to do is just draw them on the page image. It's not difficult but it takes some time to implement them. And, I don't want to do that because it's useless for pdfrx usage.
I'm on the web. I have loaded the document using PdfViewer.data. Is there a way to set up the overlays and get the document with the overlays included as byte data (Uint8List)?