-
Notifications
You must be signed in to change notification settings - Fork 847
How to save text markup annotations in the Flutter PDF Viewer (SfPdfViewer) so that they appear again when reopened. #2332
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
Comments
Hi @minhto2811, We can save the annotation made in the PDF document using the PdfViewerController.saveDocument method. You can use the bytes obtained from this method to replace the document from the original location. |
Hi @minhto2811, |
Update: I just tried again and it works. As you said, it wasn't attached to the view. Sorry for the inconvenience, and sincerely thank you for your support. I'm certain that the PdfViewerController is attached to the SfPdfViewer widget — the debug values confirm that. Here's the relevant part of my code: class PdfView extends StatelessWidget {
const PdfView(
{super.key,
required this.path,
required this.initialPageNumber,
this.onPageChanged,
required this.key1,
this.onHyperlinkClicked,
required this.controller});
final String path;
final int initialPageNumber;
final void Function(PdfPageChangedDetails)? onPageChanged;
final GlobalKey<SfPdfViewerState> key1;
final Function(PdfHyperlinkClickedDetails)? onHyperlinkClicked;
final PdfViewerController controller;
@override
Widget build(BuildContext context) {
return SfPdfViewer.file(
key: key1,
File(path),
initialPageNumber: initialPageNumber,
onPageChanged: onPageChanged,
onHyperlinkClicked: onHyperlinkClicked,
controller: controller,
canShowPageLoadingIndicator: false,
);
}
} |
Use case
In the Flutter PDF Viewer (SfPdfViewer), users can add text markup annotations (such as highlights, underlines, and strikethroughs) to a document. To ensure these annotations persist after the app is closed and reopened, it is necessary to save the annotations data separately. Later, when the document is loaded again, the saved annotations must be re-imported into the viewer so they reappear as before.
Proposal
Support saving and restoring text markup annotations in the Flutter PDF Viewer (SfPdfViewer), allowing users to view previously added annotations when reopening the document.
The text was updated successfully, but these errors were encountered: