From 60323803c09c7dd731ed696e5de3e57ce0571c60 Mon Sep 17 00:00:00 2001 From: immankumarsync Date: Thu, 21 Aug 2025 20:34:25 +0530 Subject: [PATCH 1/3] FLUT-967617: PDF Viewer public APIs --- .../flutter/annotations-overview.md | 46 +++++++++++++++- .../PDF-Viewer/flutter/bookmark-navigation.md | 2 +- .../PDF/PDF-Viewer/flutter/form-filling.md | 12 ++-- .../PDF/PDF-Viewer/flutter/getting-started.md | 39 +++++++++++++ .../flutter/lock-unlock-annotations.md | 2 +- .../PDF/PDF-Viewer/flutter/magnification.md | 2 +- .../flutter/open-a-document-from-base64.md | 2 +- .../flutter/open-a-document-from-memory.md | 5 +- .../PDF/PDF-Viewer/flutter/open-a-document.md | 2 +- .../PDF/PDF-Viewer/flutter/page-navigation.md | 55 +++++++++++++++++++ .../flutter/select-deselect-annotations.md | 11 +++- .../PDF/PDF-Viewer/flutter/sticky-notes.md | 24 +++++--- .../PDF/PDF-Viewer/flutter/text-markup.md | 38 ++++++++++++- .../PDF/PDF-Viewer/flutter/text-search.md | 4 ++ 14 files changed, 216 insertions(+), 28 deletions(-) diff --git a/Document-Processing/PDF/PDF-Viewer/flutter/annotations-overview.md b/Document-Processing/PDF/PDF-Viewer/flutter/annotations-overview.md index 5dc1f748e..66308fa67 100644 --- a/Document-Processing/PDF/PDF-Viewer/flutter/annotations-overview.md +++ b/Document-Processing/PDF/PDF-Viewer/flutter/annotations-overview.md @@ -18,4 +18,48 @@ The `SfPdfViewer` supports the following annotation types: 2. Squiggly 3. Strikethrough 4. Underline -5. Sticky Note \ No newline at end of file +5. Sticky Note + +## Setting the Default Author for Annotations + +You can define a default author name for all annotations added to the PDF document using the [author](https://pub.dev/documentation/syncfusion_flutter_pdfviewer/latest/pdfviewer/PdfAnnotationSettings/author.html) property of the [annotationSettings](https://pub.dev/documentation/syncfusion_flutter_pdfviewer/latest/pdfviewer/PdfViewerController/annotationSettings.html). This helps identify who created the annotations, especially in collaborative or review workflows. + +The following code explains how to set a default author name for the annotations. + +{% tabs %} +{% highlight dart %} + +void setDefaultAuthor() { + // Sets the default author. + _pdfViewerController.annotationSettings.author = 'John Doe'; +} + +{% endhighlight %} +{% endtabs %} + +## Setting the Author and Subject for Individual Annotations + +In addition to setting a default author for all annotations, you can assign a specific [author](https://pub.dev/documentation/syncfusion_flutter_pdfviewer/latest/pdfviewer/Annotation/author.html) and [subject](https://pub.dev/documentation/syncfusion_flutter_pdfviewer/latest/pdfviewer/Annotation/subject.html) to each annotation individually using an [Annotation](https://pub.dev/documentation/syncfusion_flutter_pdfviewer/latest/pdfviewer/Annotation-class.html) instance. + +The following code explains how to set the author name and subject for individual annotation. + +{% tabs %} +{% highlight dart %} + +/// Sets the author and subject for the last annotation in the PDF document. +void setMetadataForLastAnnotation() { + // Get the list of annotations in the PDF document. + List annotations = _pdfViewerController.getAnnotations(); + + if (annotations.isNotEmpty) { + // Get the last annotation from the list. + Annotation lastAnnotation = annotations.last; + + // Set the author and subject for the last annotation. + lastAnnotation.author = 'John Doe'; + lastAnnotation.subject = 'Reviewed'; + } +} + +{% endhighlight %} +{% endtabs %} diff --git a/Document-Processing/PDF/PDF-Viewer/flutter/bookmark-navigation.md b/Document-Processing/PDF/PDF-Viewer/flutter/bookmark-navigation.md index e8cf5c29e..42d54ac4a 100644 --- a/Document-Processing/PDF/PDF-Viewer/flutter/bookmark-navigation.md +++ b/Document-Processing/PDF/PDF-Viewer/flutter/bookmark-navigation.md @@ -22,7 +22,7 @@ The built-in bookmark view in the `SfPdfViewer` can be opened using the [openBoo The following code example explains the opening of the built-in bookmark view programmatically. {% tabs %} -{% highlight dart hl_lines="1 15" %} +{% highlight dart hl_lines="1 25" %} final GlobalKey _pdfViewerKey = GlobalKey(); diff --git a/Document-Processing/PDF/PDF-Viewer/flutter/form-filling.md b/Document-Processing/PDF/PDF-Viewer/flutter/form-filling.md index ede0ddbf9..60994ec7b 100644 --- a/Document-Processing/PDF/PDF-Viewer/flutter/form-filling.md +++ b/Document-Processing/PDF/PDF-Viewer/flutter/form-filling.md @@ -32,7 +32,7 @@ Add or edit the form data programmatically in the document using the [getFormFie ### Adding or Editing text box data -Add or edit the text of the text box programmatically by changing the [text](https://pub.dev/documentation/syncfusion_flutter_pdfviewer/latest/pdfviewer/PdfTextFormField/text.html) property. +Add or edit the text of the text box programmatically by changing the [text](https://pub.dev/documentation/syncfusion_flutter_pdfviewer/latest/pdfviewer/PdfTextFormField/text.html) property of the [PdfTextFormField](https://pub.dev/documentation/syncfusion_flutter_pdfviewer/latest/pdfviewer/PdfTextFormField-class.html). {% tabs %} {% highlight dart hl_lines="17 18 19 20" %} @@ -73,7 +73,7 @@ Widget build(BuildContext context) { ### Adding or Editing checkbox data -Check or uncheck the checkbox programmatically by changing the [isChecked](https://pub.dev/documentation/syncfusion_flutter_pdfviewer/latest/pdfviewer/PdfCheckboxFormField/isChecked.html) property. +Check or uncheck the checkbox programmatically by changing the [isChecked](https://pub.dev/documentation/syncfusion_flutter_pdfviewer/latest/pdfviewer/PdfCheckboxFormField/isChecked.html) property of the [PdfCheckboxFormField](https://pub.dev/documentation/syncfusion_flutter_pdfviewer/latest/pdfviewer/PdfCheckboxFormField-class.html). {% tabs %} {% highlight dart hl_lines="17 18 19 20" %} @@ -114,7 +114,7 @@ Widget build(BuildContext context) { ### Editing combo box data -Select an item from the combo box programmatically using the [selectedItem](https://pub.dev/documentation/syncfusion_flutter_pdfviewer/latest/pdfviewer/PdfComboBoxFormField/selectedItem.html) property. +Select an item from the combo box programmatically using the [selectedItem](https://pub.dev/documentation/syncfusion_flutter_pdfviewer/latest/pdfviewer/PdfComboBoxFormField/selectedItem.html) property of the [PdfComboBoxFormField](https://pub.dev/documentation/syncfusion_flutter_pdfviewer/latest/pdfviewer/PdfComboBoxFormField-class.html). The item to be selected must be one of the available [items](https://pub.dev/documentation/syncfusion_flutter_pdfviewer/latest/pdfviewer/PdfComboBoxFormField/items.html) in the [PdfComboBoxFormField](https://pub.dev/documentation/syncfusion_flutter_pdfviewer/latest/pdfviewer/PdfComboBoxFormField-class.html). {% tabs %} {% highlight dart hl_lines="17 18 19 20" %} @@ -155,7 +155,7 @@ Widget build(BuildContext context) { ### Editing radio button data -Select an item from the radio buttons programmatically using the [selectedItem](https://pub.dev/documentation/syncfusion_flutter_pdfviewer/latest/pdfviewer/PdfRadioFormField/selectedItem.html) property. +Select an item from the radio buttons programmatically using the [selectedItem](https://pub.dev/documentation/syncfusion_flutter_pdfviewer/latest/pdfviewer/PdfRadioFormField/selectedItem.html) property of the [PdfRadioFormField](https://pub.dev/documentation/syncfusion_flutter_pdfviewer/latest/pdfviewer/PdfRadioFormField-class.html). The item to be selected must be one of the available [items](https://pub.dev/documentation/syncfusion_flutter_pdfviewer/latest/pdfviewer/PdfRadioFormField/items.html) in the [PdfRadioFormField](https://pub.dev/documentation/syncfusion_flutter_pdfviewer/latest/pdfviewer/PdfRadioFormField-class.html). {% tabs %} {% highlight dart hl_lines="17 18 19 20" %} @@ -196,7 +196,7 @@ Widget build(BuildContext context) { ### Editing list box data -Select one or more items from the list box programmatically using the [selectedItems](https://pub.dev/documentation/syncfusion_flutter_pdfviewer/latest/pdfviewer/PdfListBoxFormField/selectedItems.html) property. +Select one or more items from the list box programmatically using the [selectedItems](https://pub.dev/documentation/syncfusion_flutter_pdfviewer/latest/pdfviewer/PdfListBoxFormField/selectedItems.html) property of the [PdfListBoxFormField](https://pub.dev/documentation/syncfusion_flutter_pdfviewer/latest/pdfviewer/PdfListBoxFormField-class.html). The selected items must be chosen from the available [items](https://pub.dev/documentation/syncfusion_flutter_pdfviewer/latest/pdfviewer/PdfListBoxFormField/items.html) in the [PdfListBoxFormField](https://pub.dev/documentation/syncfusion_flutter_pdfviewer/latest/pdfviewer/PdfListBoxFormField-class.html). {% tabs %} {% highlight dart hl_lines="17 18 19 20" %} @@ -237,7 +237,7 @@ Widget build(BuildContext context) { ### Adding or Editing signature data -Add or remove the signature in a signature form field programmatically by assigning the image bytes or `null` to the [signature](https://pub.dev/documentation/syncfusion_flutter_pdfviewer/latest/pdfviewer/PdfSignatureFormField/signature.html) property. +Add or remove the signature in a signature form field programmatically by assigning the image bytes or `null` to the [signature](https://pub.dev/documentation/syncfusion_flutter_pdfviewer/latest/pdfviewer/PdfSignatureFormField/signature.html) property of the [PdfSignatureFormField](https://pub.dev/documentation/syncfusion_flutter_pdfviewer/latest/pdfviewer/PdfSignatureFormField-class.html) {% tabs %} {% highlight dart hl_lines="17 18 19 20 21 22" %} diff --git a/Document-Processing/PDF/PDF-Viewer/flutter/getting-started.md b/Document-Processing/PDF/PDF-Viewer/flutter/getting-started.md index e77af0b95..4fae38ad9 100644 --- a/Document-Processing/PDF/PDF-Viewer/flutter/getting-started.md +++ b/Document-Processing/PDF/PDF-Viewer/flutter/getting-started.md @@ -96,4 +96,43 @@ Widget build(BuildContext context) { {% endhighlight %} {% endtabs %} +## Using the controller Property in SfPdfViewer + +The [controller](https://pub.dev/documentation/syncfusion_flutter_pdfviewer/latest/pdfviewer/SfPdfViewer/controller.html) property in the SfPdfViewer widget allows you to interact with the PDF document programmatically using the [PdfViewerController](https://pub.dev/documentation/syncfusion_flutter_pdfviewer/latest/pdfviewer/PdfViewerController-class.html). This controller provides access to various methods and properties such as [jumpToPage](https://pub.dev/documentation/syncfusion_flutter_pdfviewer/latest/pdfviewer/PdfViewerController/jumpToPage.html), [zoomLevel](https://pub.dev/documentation/syncfusion_flutter_pdfviewer/latest/pdfviewer/PdfViewerController/zoomLevel.html), [pageCount](https://pub.dev/documentation/syncfusion_flutter_pdfviewer/latest/pdfviewer/PdfViewerController/pageCount.html), and annotation management. + +The following code explains how to initialize, attach, and dispose the [PdfViewerController](https://pub.dev/documentation/syncfusion_flutter_pdfviewer/latest/pdfviewer/PdfViewerController-class.html). + +{% tabs %} +{% highlight dart hl_lines="1 5 10 21" %} + +late PdfViewerController _pdfViewerController; + +@override +initState() { + _pdfViewerController = PdfViewerController(); + super.initState(); +} + +@override +void dispose() { + _pdfViewerController.dispose(); + super.dispose(); +} + +@override +Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar(title: Text('Syncfusion Flutter PdfViewer')), + body: SfPdfViewer.asset( + 'assets/flutter-succinctly.pdf', + controller: _pdfViewerController, + ), + ), + ); +} + +{% endhighlight %} +{% endtabs %} + N> You can refer to our [Flutter PDF Viewer](https://www.syncfusion.com/flutter-widgets/flutter-pdf-viewer) feature tour page for its groundbreaking feature representations. You can also explore our [Flutter PDF Viewer example](https://flutter.syncfusion.com/#/pdf-viewer/getting-started), which shows you how to render and configure the PDF Viewer. \ No newline at end of file diff --git a/Document-Processing/PDF/PDF-Viewer/flutter/lock-unlock-annotations.md b/Document-Processing/PDF/PDF-Viewer/flutter/lock-unlock-annotations.md index cb55607b4..c87395dae 100644 --- a/Document-Processing/PDF/PDF-Viewer/flutter/lock-unlock-annotations.md +++ b/Document-Processing/PDF/PDF-Viewer/flutter/lock-unlock-annotations.md @@ -73,7 +73,7 @@ void lockUnderlineAnnotations() { ## Lock the Selected Annotation -To lock the selected annotation, access the selected annotation instance and set the `isLocked` property to true. The selected annotation instance may be obtained from the `onAnnotationSelected` callback. The following example explains locking the selected annotation in a PDF document. +To lock the selected annotation, access the selected annotation instance and set the `isLocked` property to true. The selected annotation instance may be obtained from the [onAnnotationSelected](https://pub.dev/documentation/syncfusion_flutter_pdfviewer/latest/pdfviewer/SfPdfViewer/onAnnotationSelected.html) callback. The following example explains locking the selected annotation in a PDF document. {% tabs %} {% highlight dart %} diff --git a/Document-Processing/PDF/PDF-Viewer/flutter/magnification.md b/Document-Processing/PDF/PDF-Viewer/flutter/magnification.md index b59df7112..1911b37ea 100644 --- a/Document-Processing/PDF/PDF-Viewer/flutter/magnification.md +++ b/Document-Processing/PDF/PDF-Viewer/flutter/magnification.md @@ -55,7 +55,7 @@ Widget build(BuildContext context) { ## Set and Adjust the Maximum Zoom Level -The `SfPdfViewer` allows you to set and adjust the maximum zoom level for the PDF document being displayed using the `maxZoomLevel` property. The following code example explains the same. +The `SfPdfViewer` allows you to set and adjust the maximum zoom level for the PDF document being displayed using the [maxZoomLevel](https://pub.dev/documentation/syncfusion_flutter_pdfviewer/latest/pdfviewer/SfPdfViewer/maxZoomLevel.html) property. The following code example explains the same. {% tabs %} {% highlight dart hl_lines="6" %} diff --git a/Document-Processing/PDF/PDF-Viewer/flutter/open-a-document-from-base64.md b/Document-Processing/PDF/PDF-Viewer/flutter/open-a-document-from-base64.md index 905c5ddc4..33101e717 100644 --- a/Document-Processing/PDF/PDF-Viewer/flutter/open-a-document-from-base64.md +++ b/Document-Processing/PDF/PDF-Viewer/flutter/open-a-document-from-base64.md @@ -1,7 +1,7 @@ --- layout: post title: Open a Document From base64 in Flutter PDF Viewer | Syncfusion -description: Learn here about opening a PDF document from memory in Syncfusion® Flutter PDF Viewer widget (SfPdfViewer). +description: Learn here about opening a PDF document from base64 string in Syncfusion® Flutter PDF Viewer widget (SfPdfViewer). platform: flutter control: SfPdfViewer documentation: ug diff --git a/Document-Processing/PDF/PDF-Viewer/flutter/open-a-document-from-memory.md b/Document-Processing/PDF/PDF-Viewer/flutter/open-a-document-from-memory.md index d31cda191..682aa8c0b 100644 --- a/Document-Processing/PDF/PDF-Viewer/flutter/open-a-document-from-memory.md +++ b/Document-Processing/PDF/PDF-Viewer/flutter/open-a-document-from-memory.md @@ -12,13 +12,12 @@ documentation: ug The [SfPdfViewer.memory](https://pub.dev/documentation/syncfusion_flutter_pdfviewer/latest/pdfviewer/SfPdfViewer/SfPdfViewer.memory.html) creates a widget that displays the PDF document obtained from the [Uint8List](https://api.flutter.dev/flutter/dart-typed_data/Uint8List-class.html). The following code example explains the same. {% tabs %} -{% highlight dart hl_lines="4 5" %} +{% highlight dart hl_lines="4" %} @override Widget build(BuildContext context) { return Scaffold( - body: SfPdfViewer.memory( - bytes)); + body: SfPdfViewer.memory(bytes)); } {% endhighlight %} diff --git a/Document-Processing/PDF/PDF-Viewer/flutter/open-a-document.md b/Document-Processing/PDF/PDF-Viewer/flutter/open-a-document.md index 5ea45c3be..ce124d70c 100644 --- a/Document-Processing/PDF/PDF-Viewer/flutter/open-a-document.md +++ b/Document-Processing/PDF/PDF-Viewer/flutter/open-a-document.md @@ -23,7 +23,7 @@ The `SfPdfViewer` supports the following constructor types: ## Load the Document with the Specified Page -The `SfPdfViewer` allows you to load the document with the specified page using the `initialPageNumber` property. The following code example explains the same. +The `SfPdfViewer` allows you to load the document with the specified page using the [initialPageNumber](https://pub.dev/documentation/syncfusion_flutter_pdfviewer/latest/pdfviewer/SfPdfViewer/initialPageNumber.html) property. The following code example explains the same. {% tabs %} {% highlight dart hl_lines="6" %} diff --git a/Document-Processing/PDF/PDF-Viewer/flutter/page-navigation.md b/Document-Processing/PDF/PDF-Viewer/flutter/page-navigation.md index df611ea1b..334dbf15b 100644 --- a/Document-Processing/PDF/PDF-Viewer/flutter/page-navigation.md +++ b/Document-Processing/PDF/PDF-Viewer/flutter/page-navigation.md @@ -13,6 +13,61 @@ Navigate to the desired pages instantly either by using the page navigation dial ![Page navigation dialog](images/page-navigation/page_navigation_dialog.png) +N> +To use the PdfViewerController methods or access properties, the controller must be attached to the SfPdfViewer widget using the [controller](https://pub.dev/documentation/syncfusion_flutter_pdfviewer/latest/pdfviewer/SfPdfViewer/controller.html) parameter. + +## Obtain the total page count and the current page number + +The [pageCount](https://pub.dev/documentation/syncfusion_flutter_pdfviewer/latest/pdfviewer/PdfViewerController/pageCount.html) property returns the total number of pages in a PDF document. And the [pageNumber](https://pub.dev/documentation/syncfusion_flutter_pdfviewer/latest/pdfviewer/PdfViewerController/pageNumber.html) property returns the current page number displayed in the PDF Viewer. + +{% tabs %} +{% highlight dart hl_lines="34 35" %} + +late PdfViewerController _pdfViewerController; +int _pageNumber = 0; +int _pageCount = 0; + +@override +initState() { + _pdfViewerController = PdfViewerController(); + super.initState(); +} + +@override +Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar( + title: Text('Syncfusion Flutter PdfViewer'), + actions: [ + SizedBox( + width: 100, + height: 50, + child: TextField( + decoration: InputDecoration( + labelText: '$_pageNumber / $_pageCount', + ), + ), + ), + ], + ), + body: SfPdfViewer.network( + 'https://cdn.syncfusion.com/content/PDFViewer/flutter-succinctly.pdf', + controller: _pdfViewerController, + onDocumentLoaded: (PdfDocumentLoadedDetails details) { + setState(() { + _pageNumber = _pdfViewerController.pageNumber; + _pageCount = _pdfViewerController.pageCount; + }); + }, + ), + ), + ); +} + +{% endhighlight %} +{% endtabs %} + ## Navigate to the Desired Page Programmatically The [jumpToPage](https://pub.dev/documentation/syncfusion_flutter_pdfviewer/latest/pdfviewer/PdfViewerController/jumpToPage.html) controller method helps you to navigate to the specified page number in a PDF document. The following code example explains the same. diff --git a/Document-Processing/PDF/PDF-Viewer/flutter/select-deselect-annotations.md b/Document-Processing/PDF/PDF-Viewer/flutter/select-deselect-annotations.md index 50da8679b..397131fb5 100644 --- a/Document-Processing/PDF/PDF-Viewer/flutter/select-deselect-annotations.md +++ b/Document-Processing/PDF/PDF-Viewer/flutter/select-deselect-annotations.md @@ -7,7 +7,7 @@ control: SfPdfViewer documentation: ug --- -# Select and Deselect Annotations in Flutter PDF Viewer Widget (SfPdfViewer) +# Select and Deselect Annotations in Flutter PDF Viewer (SfPdfViewer) This section will go through the various functions available in the `SfPdfViewer` for selecting and deselecting annotations in a PDF document. @@ -63,7 +63,12 @@ Widget build(BuildContext context) { ### Customizing Selector Appearance -The `annotationSettings` property of `PdfViewerController` allows you to customize the default selector color. The following example explains how to customize the selector color for locked and unlocked annotations. +The [selector](https://pub.dev/documentation/syncfusion_flutter_pdfviewer/latest/pdfviewer/PdfAnnotationSettings/selector.html) property of the [annotationSettings](https://pub.dev/documentation/syncfusion_flutter_pdfviewer/latest/pdfviewer/PdfViewerController/annotationSettings.html) allows you to customize the annotation selector color. + +* [color](https://pub.dev/documentation/syncfusion_flutter_pdfviewer/latest/pdfviewer/PdfAnnotationSelectorSettings/color.html) - Specifies the selector color when the selected annotation is not locked. +* [lockedColor](https://pub.dev/documentation/syncfusion_flutter_pdfviewer/latest/pdfviewer/PdfAnnotationSelectorSettings/lockedColor.html) - Specifies the selector color when the selected annotation is locked. + +The following example explains how to customize the selector color for locked and unlocked annotations. {% tabs %} {% highlight dart %} @@ -102,7 +107,7 @@ void deselectAnnotation(Annotation selectedAnnotation) { ### Annotation Deselected Callback -The callback provided to the `onAnnotationDeselected` property is triggered when an annotation is deselected interactively or programmatically. The following code sample explains how to use this callback. +The callback provided to the [onAnnotationDeselected](https://pub.dev/documentation/syncfusion_flutter_pdfviewer/latest/pdfviewer/SfPdfViewer/onAnnotationDeselected.html) property is triggered when an annotation is deselected interactively or programmatically. The following code sample explains how to use this callback. {% tabs %} {% highlight dart hl_lines="7 8 9 10" %} diff --git a/Document-Processing/PDF/PDF-Viewer/flutter/sticky-notes.md b/Document-Processing/PDF/PDF-Viewer/flutter/sticky-notes.md index 355254b1c..25d8bc30c 100644 --- a/Document-Processing/PDF/PDF-Viewer/flutter/sticky-notes.md +++ b/Document-Processing/PDF/PDF-Viewer/flutter/sticky-notes.md @@ -88,23 +88,26 @@ void addStickyNoteAnnotation() { ## Sticky Note Annotation Settings -In the sticky note annotation mode, the annotation will be added with a default appearance. You can modify the annotation after it has been added to the pages. However, if you need to define the appearance before adding sticky note annotations to the document, you can change its default settings using the [PdfViewerController.annotationSettings.stickyNote](https://pub.dev/documentation/syncfusion_flutter_pdfviewer/latest/pdfviewer/PdfAnnotationSettings/stickyNote.html). For that, you need to obtain the default sticky note annotation settings. +In the sticky note annotation mode, the annotation will be added with a default appearance. You can modify the annotation after it has been added to the pages. However, if you need to define the appearance before adding sticky note annotations to the document, you can change its default settings using the [stickyNote](https://pub.dev/documentation/syncfusion_flutter_pdfviewer/latest/pdfviewer/PdfAnnotationSettings/stickyNote.html) property of the [annotationSettings](https://pub.dev/documentation/syncfusion_flutter_pdfviewer/latest/pdfviewer/PdfViewerController/annotationSettings.html). -The following example explains how to obtain the default sticky note annotation settings and modify some of their properties. Similarly, you can modify all the other properties. +The following example explains how to customize the default appearance of the sticky note annotations. {% tabs %} {% highlight dart %} void customizeDefaultStickyNoteSettings() { - // Obtain the default sticky note annotation settings from the PdfViewerController instance. - PdfStickyNoteAnnotationSettings stickyNoteSettings = - _pdfViewerController.annotationSettings.stickyNote; + // Obtain the default annotation settings from the PdfViewerController instance. + PdfAnnotationSettings annotationSettings = + _pdfViewerController.annotationSettings; + + // Assign the customized appearance to the sticky note annotations + annotationSettings.stickyNote = PdfStickyNoteAnnotationSettings() + ..color = Colors.yellow; // Set the default color // Modify the default properties. - stickyNoteSettings.icon = - PdfStickyNoteIcon.comment; // Set the default icon to Comment. - stickyNoteSettings.color = Colors.yellow; // Stroke color - stickyNoteSettings.opacity = 0.75; // 75% Opacity + annotationSettings.stickyNote.icon = + PdfStickyNoteIcon.note; // Set the default icon to Note. + annotationSettings.stickyNote.opacity = 0.75; // 75% Opacity } {% endhighlight %} @@ -132,6 +135,9 @@ void editSelectedStickyNoteAnnotation(Annotation selectedAnnotation) { // Change the text of the selected sticky note annotation. selectedAnnotation.text = "Changed the comment to note."; + + // Change the position of the selected sticky note annotation. + selectedAnnotation.position = const Offset(50, 50); } } diff --git a/Document-Processing/PDF/PDF-Viewer/flutter/text-markup.md b/Document-Processing/PDF/PDF-Viewer/flutter/text-markup.md index 032f5a1cb..919a969f9 100644 --- a/Document-Processing/PDF/PDF-Viewer/flutter/text-markup.md +++ b/Document-Processing/PDF/PDF-Viewer/flutter/text-markup.md @@ -65,4 +65,40 @@ void disableAnnotationMode() { Text markups can be added to a PDF document using text selection without enabling the [annotationMode](https://pub.dev/documentation/syncfusion_flutter_pdfviewer/latest/pdfviewer/PdfViewerController/annotationMode.html). Select the text you want in a PDF document, and a context menu with the text markup options will appear after you complete your selection. You can select any text markup options to add an annotation to a text in the PDF document. -![Text selection context menu in Flutter PDF Viewer.](images/annotations/flutter-pdf-viewer-text-selection-context-menu.png) \ No newline at end of file +![Text selection context menu in Flutter PDF Viewer.](images/annotations/flutter-pdf-viewer-text-selection-context-menu.png) + +## Text Markup Annotation Settings + +Text markup annotations will be added with a default appearance specified in the [annotationSettings](https://pub.dev/documentation/syncfusion_flutter_pdfviewer/latest/pdfviewer/PdfViewerController/annotationSettings.html). You can modify the annotation after it has been added to the pages. However, if you want to define the appearance before adding text markup annotations to the document, you can update the default settings using the corresponding annotation settings in [annotationSettings](https://pub.dev/documentation/syncfusion_flutter_pdfviewer/latest/pdfviewer/PdfViewerController/annotationSettings.html). + +The following example demonstrates how to customize the default appearance of all text markup annotations. + +{% tabs %} +{% highlight dart %} + +void customizeDefaultTextMarkupSettings() { + // Obtain the default annotation settings from the PdfViewerController instance. + PdfAnnotationSettings annotationSettings = + _pdfViewerController.annotationSettings; + + // Customize the default settings of Highlight annotations + annotationSettings.highlight = PdfTextMarkupAnnotationSettings() + ..color = Colors.green + ..opacity = 0.5; + + // Customize the default settings of Underline annotations + annotationSettings.underline = PdfTextMarkupAnnotationSettings() + ..color = Colors.black + ..opacity = 0.6; + + // Customize the default settings of Strikethrough annotations + annotationSettings.strikethrough.color = Colors.red; + annotationSettings.strikethrough.opacity = 0.9; + + // Customize the default settings of Squiggly annotations + annotationSettings.squiggly.color = Colors.black; + annotationSettings.squiggly.opacity = 0.4; +} + +{% endhighlight %} +{% endtabs %} diff --git a/Document-Processing/PDF/PDF-Viewer/flutter/text-search.md b/Document-Processing/PDF/PDF-Viewer/flutter/text-search.md index b80bedda3..71a20aad1 100644 --- a/Document-Processing/PDF/PDF-Viewer/flutter/text-search.md +++ b/Document-Processing/PDF/PDF-Viewer/flutter/text-search.md @@ -19,6 +19,10 @@ On mobile and desktop platforms, the search will be performed asynchronously, so Whereas on the web platform, the search will be performed synchronously, so the result will be returned only after completing the search on all the pages. This is because `isolate` is not supported for the web platform yet. +The [isSearchCompleted](https://pub.dev/documentation/syncfusion_flutter_pdfviewer/latest/pdfviewer/PdfTextSearchResult/isSearchCompleted.html) property of [PdfTextSearchResult](https://pub.dev/documentation/syncfusion_flutter_pdfviewer/latest/pdfviewer/PdfTextSearchResult-class.html) indicates whether the text search process has completed when it is performed asynchronously on mobile and desktop platforms. + +The [hasResult](https://pub.dev/documentation/syncfusion_flutter_pdfviewer/latest/pdfviewer/PdfTextSearchResult/hasResult.html) property of [PdfTextSearchResult](https://pub.dev/documentation/syncfusion_flutter_pdfviewer/latest/pdfviewer/PdfTextSearchResult-class.html) indicates whether the text search yields any results. + To differentiate the highlighted texts, the current text instance highlight color will be dark, while the rest of the instances will be light. The following code example explains how to perform the text search and retrieve the results. N> Import **'package:syncfusion_flutter_pdf/pdf.dart'** in the Dart code if you use the [TextSearchOption](https://pub.dev/documentation/syncfusion_flutter_pdf/latest/pdf/TextSearchOption.html) parameter. From 1c9cee0068a148ee241ec8007926e761bd1b8ed3 Mon Sep 17 00:00:00 2001 From: immankumarsync Date: Fri, 22 Aug 2025 15:57:44 +0530 Subject: [PATCH 2/3] FLUT-967617: PDF Viewer public APIs --- .../PDF/PDF-Viewer/flutter/select-deselect-annotations.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Document-Processing/PDF/PDF-Viewer/flutter/select-deselect-annotations.md b/Document-Processing/PDF/PDF-Viewer/flutter/select-deselect-annotations.md index 397131fb5..ac4094519 100644 --- a/Document-Processing/PDF/PDF-Viewer/flutter/select-deselect-annotations.md +++ b/Document-Processing/PDF/PDF-Viewer/flutter/select-deselect-annotations.md @@ -9,7 +9,7 @@ documentation: ug # Select and Deselect Annotations in Flutter PDF Viewer (SfPdfViewer) -This section will go through the various functions available in the `SfPdfViewer` for selecting and deselecting annotations in a PDF document. +This section will go through the various functions available in the `SfPdfViewer` to select and deselect annotations in a PDF document. ## Select an Annotation From 72406b95ff6db982d03da93b864520068c92b895 Mon Sep 17 00:00:00 2001 From: Imman Kumar <93641486+immankumarsync@users.noreply.github.com> Date: Mon, 25 Aug 2025 11:28:26 +0530 Subject: [PATCH 3/3] FLUT-967617: PDF Viewer public APIs --- .../PDF/PDF-Viewer/flutter/select-deselect-annotations.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Document-Processing/PDF/PDF-Viewer/flutter/select-deselect-annotations.md b/Document-Processing/PDF/PDF-Viewer/flutter/select-deselect-annotations.md index ac4094519..397131fb5 100644 --- a/Document-Processing/PDF/PDF-Viewer/flutter/select-deselect-annotations.md +++ b/Document-Processing/PDF/PDF-Viewer/flutter/select-deselect-annotations.md @@ -9,7 +9,7 @@ documentation: ug # Select and Deselect Annotations in Flutter PDF Viewer (SfPdfViewer) -This section will go through the various functions available in the `SfPdfViewer` to select and deselect annotations in a PDF document. +This section will go through the various functions available in the `SfPdfViewer` for selecting and deselecting annotations in a PDF document. ## Select an Annotation