{
  "$schema": "https://ai.syncfusion.com/schema/registry-item.json",
  "name": "pdf-viewer-form-filling",
  "framework": "maui",
  "type": "registry:component",
  "component": "PdfViewer",
  "variant": "form-filling",
  "dependencies": [
    "Syncfusion.Maui.PdfViewer"
  ],
  "description": "PDF viewer supports form field editing, saving, XFDF import/export, and annotations.",
  "meta": {
    "essentialStudioRelease": "2026 Volume 3 (v35.1.37)",
    "license": "commercial-or-community",
    "licenseNote": "The Syncfusion package is licensed. The composition in this file is source you own and edit. See https://ai.syncfusion.com/licensing.md",
    "requiresLicenseKey": true,
    "requiresServerEndpoint": false,
    "platformIndex": "https://ai.syncfusion.com/maui/llms.txt",
    "skillPack": "syncfusion/maui-ui-components-skills",
    "docs": "https://ai.syncfusion.com/gallery/maui/pdf-viewer-form-filling.md"
  },
  "files": [
    {
      "target": "src/components/pdf-viewer-form-filling/PdfViewer.xaml",
      "content": "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n<ContentPage xmlns=\"http://schemas.microsoft.com/dotnet/2021/maui\"\n             xmlns:x=\"http://schemas.microsoft.com/winfx/2009/xaml\"\n             xmlns:pdf=\"clr-namespace:Syncfusion.Maui.PdfViewer;assembly=Syncfusion.Maui.PdfViewer\"\n             xmlns:model=\"clr-namespace:MAUI.Controls.PdfViewer.FormFilling\"\n             x:Class=\"MAUI.Controls.PdfViewer.FormFilling.PdfViewerView\"\n             x:DataType=\"model:PdfViewerViewModel\"\n             Title=\"PDF Viewer - Form Filling\">\n      <ContentPage.Resources>\n        <Style TargetType=\"Button\">\n            <Setter Property=\"BorderWidth\" Value=\"0\" />\n            <Setter Property=\"FontSize\" Value=\"18\" />\n            <Setter Property=\"Padding\" Value=\"4\" />\n            <Setter Property=\"VerticalOptions\" Value=\"Center\" />\n            <Setter Property=\"VisualStateManager.VisualStateGroups\">\n                <VisualStateGroupList>\n                    <VisualStateGroup x:Name=\"CommonStates\">\n                        <VisualState x:Name=\"Normal\">\n                            <VisualState.Setters>\n                                <Setter Property=\"TextColor\" Value=\"#99000000\" />\n                                <Setter Property=\"BackgroundColor\" Value=\"Transparent\" />\n                            </VisualState.Setters>\n                        </VisualState>\n                        <VisualState x:Name=\"Disabled\">\n                            <VisualState.Setters>\n                                <Setter Property=\"TextColor\" Value=\"#44000000\" />\n                                <Setter Property=\"BackgroundColor\" Value=\"Transparent\" />\n                            </VisualState.Setters>\n                        </VisualState>\n                        <VisualState x:Name=\"Pressed\">\n                            <VisualState.Setters>\n                                <Setter Property=\"TextColor\" Value=\"#99000000\" />\n                                <Setter Property=\"BackgroundColor\" Value=\"#0F000000\" />\n                            </VisualState.Setters>\n                        </VisualState>\n                    </VisualStateGroup>\n                </VisualStateGroupList>\n            </Setter>\n        </Style>\n    </ContentPage.Resources>\n    <ContentPage.Content>\n        <Grid RowDefinitions=\"40,*\">\n            <HorizontalStackLayout Grid.Row=\"0\" Spacing=\"20\" Margin=\"20,0,0,0\"\n                        HorizontalOptions=\"Start\">\n                <Button Text=\"&#xe712;\" \n                        Command=\"{Binding OpenFileCommand}\"\n                        IsVisible=\"{OnPlatform MacCatalyst=false}\"\n                        FontFamily=\"MauiMaterialAssets\"/>\n                <Button Text=\"&#xe75f;\" x:Name=\"Save\" FontFamily=\"MauiMaterialAssets\"  Clicked=\"Save_Clicked\" Margin=\"0,0,3,0\"/>\n                <Button x:Name=\"Import\" Text=\"&#xe782;\" FontFamily=\"MauiMaterialAssets\"  Clicked=\"Import_Clicked\"/>\n                <Button x:Name=\"Export\" Text=\"&#xe781;\" FontFamily=\"MauiMaterialAssets\"  Clicked=\"Export_Clicked\"/>\n                <Button x:Name=\"ToggleFieldEditing\" Text=\"Toggle field editing\"  Clicked=\"OnToggleEditingClicked\"/>\n            </HorizontalStackLayout>\n            <syncfusion:SfPdfViewer x:Name=\"pdfViewer\" ShowToolbars=\"False\" Grid.Row=\"1\" DocumentSource=\"{Binding DocumentStream}\"/>\n        </Grid>\n    </ContentPage.Content>\n</ContentPage>\n"
    },
    {
      "target": "src/components/pdf-viewer-form-filling/PdfViewer.xaml.cs",
      "content": "using Syncfusion.Maui.PdfViewer;\n\nnamespace MAUI.Controls.PdfViewer.FormFilling\n{\n    public partial class PdfViewerView : ContentPage\n    {\n\n        public PdfViewerView(PdfViewerViewModel viewModel)\n        {\n            InitializeComponent();\n            BindingContext = viewModel;\n        }\n\n        private void OnToggleEditingClicked(object? sender, EventArgs e) =>\n            pdfViewer.AllowEditFormFields = !pdfViewer.AllowEditFormFields;\n\n private async void Save_Clicked(object sender, EventArgs e)\n        {\n            string targetFile = Path.Combine(FileSystem.Current.AppDataDirectory, \"Saved.pdf\");\n            using FileStream outputStream = File.Create(targetFile);\n            pdfViewer.SaveDocument(outputStream);\n            await DisplayAlertAsync(\"Document Saved\", \"The document has been saved to the file \" + targetFile, \"OK\");\n        }\n        /// <summary>\n        /// Handles the event when the \"Import\" button is clicked, importing annotations from an XFDF file.\n        /// </summary>\n        private async void Import_Clicked(object sender, EventArgs e)\n        {\n            string fileName = Path.Combine(FileSystem.Current.AppDataDirectory, \"Export.xfdf\");\n            if (File.Exists(fileName))\n            {\n                Stream inputStream = File.OpenRead(fileName);\n                inputStream.Position = 0;\n                pdfViewer.ImportFormData(inputStream, Syncfusion.Pdf.Parsing.DataFormat.XFdf);\n                await DisplayAlertAsync(\"Form data imported\", \"Form data from the \" + fileName + \" file are imported\", \"OK\");\n            }\n            else\n                await DisplayAlertAsync(\"No files to import\", \"There are no xfdf files to import. Please export the form data to an xfdf file and then import. \", \"OK\");\n        }\n\n        /// <summary>\n        /// Handles the event when the \"Export\" button is clicked, exporting annotations to an XFDF file.\n        /// </summary>\n        private async void Export_Clicked(object sender, EventArgs e)\n        {\n            Stream xfdfStream = new MemoryStream();\n            pdfViewer.ExportFormData(xfdfStream, Syncfusion.Pdf.Parsing.DataFormat.XFdf);\n            await CopyFileToAppDataDirectory(xfdfStream, \"Export.xfdf\");\n        }\n        /// <summary>\n        /// Copies the contents of the input stream to a file in the application's data directory.\n        /// </summary>\n        /// <param name=\"inputStream\">The input stream containing the data to be copied.</param>\n        /// <param name=\"filename\">The name of the target file.</param>\n        /// <returns>A task representing the asynchronous operation.</returns>\n        public async Task CopyFileToAppDataDirectory(Stream inputStream, string filename)\n        {\n            // Create an output filename\n            string targetFile = Path.Combine(FileSystem.Current.AppDataDirectory, filename);\n            // Copy the file to the AppDataDirectory\n            using FileStream outputStream = File.Create(targetFile);\n            await inputStream.CopyToAsync(outputStream);\n            await DisplayAlertAsync(\"Form data exported\", \"The form data are exported to the file \" + targetFile, \"OK\");\n        }\n\n    }\n}\n"
    }
  ]
}